Skip to content

Inconsistent behavior of '+-' arithmetic operator on Boolean type #11175

@2010YOUY01

Description

@2010YOUY01

Describe the bug

Inconsistnecy is showed in the below queries, it's better to keep the behavior consistent (PostgreSQL reject them all during planning)

> select +true, +false;
+---------------+----------------+
| Boolean(true) | Boolean(false) |
+---------------+----------------+
| true          | false          |
+---------------+----------------+
1 row(s) fetched.
Elapsed 0.008 seconds.

> select -true;
Error during planning: Negation only supports numeric, interval and timestamp types
> select -false;
Error during planning: Negation only supports numeric, interval and timestamp types

PostgreSQL behavior:

postgres=# select +true;
ERROR:  operator does not exist: + boolean
LINE 1: select +true;
               ^
HINT:  No operator matches the given name and argument type. You might need to add an explicit type cast.
postgres=# select -true;
ERROR:  operator does not exist: - boolean
LINE 1: select -true;

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions