Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2010YOUY01 opened this issue Jun 29, 2024 · 1 comment · Fixed by #13019
Closed

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

2010YOUY01 opened this issue Jun 29, 2024 · 1 comment · Fixed by #13019
Labels
bug Something isn't working

Comments

@2010YOUY01
Copy link
Contributor

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

@2010YOUY01 2010YOUY01 added the bug Something isn't working label Jun 29, 2024
@alamb
Copy link
Contributor

alamb commented Jun 30, 2024

I think it would be fine to have negate work for booleans (and basically be a noop as it seems in postgres)

Thank you for the report @2010YOUY01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants