Skip to content

A negative number literal is expanded as an unary - (minus) of a positive numbers. #112

@pacesm

Description

@pacesm

Tested with version 0.4.1 in Python 3.12.12

A negative number literals are expanded as an unary minus of a positive number:

>>> import cql2 
>>> cql2.Expr("property > -2").to_text()
'(property > -1 * 2)'
>>> cql2.Expr("property > -3.14").to_text()
'(property > -1 * 3.14)'

While the result is technically correct and could be possibly reduced:

>>> cql2.Expr("property > -2").reduce().to_text()
'(property > -2)'
>>> cql2.Expr("property > -3.14").reduce().to_text()
'(property > -3.14)'

it is a bit unexpected and, IMO, the number literals should not be further expanded as expressions.

Also, the reduction might have some unexpected side effects: #111

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions