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

issues-485 Fix syntax error #505

Merged

Conversation

ikrivosheev
Copy link
Member

PR Info

Bug Fixes

  • Fix syntax error when have empty Condition

@ikrivosheev ikrivosheev self-assigned this Nov 5, 2022
Copy link
Contributor

@nitnelave nitnelave left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should add a test with the negation of an empty any/all?


assert_eq!(statement, r#"SELECT `id` FROM `glyph`"#);
assert_eq!(statement, r#"SELECT `id` FROM `glyph` WHERE FALSE"#);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's some unfortunate interaction between 2 features here:

  • Collapsing an empty any/all into a boolean
  • Not adding an any/all that's empty.

This should be any(TRUE, FALSE), so TRUE

Copy link
Member

@tyt2y3 tyt2y3 Nov 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is reasonable

Copy link
Member

@tyt2y3 tyt2y3 Nov 28, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: I am trying to understand why it outputs FALSE here:

I imagine the expected output to be:

SELECT `id` FROM `glyph` WHERE TRUE OR FALSE

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah found it

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 6, 2022

Maybe we should add a test with the negation of an empty any/all?

Agreed.

Actually, I think we should remove the behaviour Not adding an any/all that's empty, this would make the reasoning much easier. It was added in the first place to tackle the same problem. If we got a more proper solution, there is no reason to keep that.

@nitnelave
Copy link
Contributor

Just got bitten by this bug again, with an any(not(any()), not(any())) which evaluated to true instead of false.

@ikrivosheev ikrivosheev force-pushed the fix/issues-485_empty_conditional branch from b6f44db to 8a6448a Compare November 25, 2022 16:48
@tyt2y3
Copy link
Member

tyt2y3 commented Nov 28, 2022

@nitnelave Can you go over this again and may be add some tests as you see fit?

@ikrivosheev
Copy link
Member Author

@tyt2y3 I think, we can compress conditional when we add it.

@tyt2y3
Copy link
Member

tyt2y3 commented Nov 28, 2022

we can compress conditional when we add it.

I imagine TRUE OR FALSE rarely appears in real life, so might not worth the effort?

@nitnelave
Copy link
Contributor

I'm of the opinion that the query builder should not try to be too smart, since that's the role of the DB. They'll have no problem with an extra "OR FALSE" in the query.

@ikrivosheev
Copy link
Member Author

@nitnelave @tyt2y3 ok.

@ikrivosheev ikrivosheev force-pushed the fix/issues-485_empty_conditional branch from c4cb627 to 993a174 Compare November 29, 2022 19:59
@ikrivosheev ikrivosheev requested review from nitnelave and billy1624 and removed request for nitnelave November 29, 2022 20:00
@ikrivosheev ikrivosheev merged commit e291d4b into SeaQL:master Nov 30, 2022
@ikrivosheev ikrivosheev deleted the fix/issues-485_empty_conditional branch November 30, 2022 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Negating an empty condition results in a syntax error
4 participants