-
Notifications
You must be signed in to change notification settings - Fork 21
chore: re-write filter at from.at(-1) into queries where
#1373
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
Merged
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d5849f2
chore: re-write filter at `from.at(-1)` into queries `where`
patricebender b10362e
comment
patricebender 851da26
clean up the ref after re-write
patricebender 1860ba9
Merge remote-tracking branch 'origin/main' into patrice/infix-leaf
patricebender 9a68024
cleanup ref properly
patricebender b3ae93b
try something
patricebender 2db4549
also do this for DELETE
patricebender 8bb2263
also update
patricebender 3532c05
Merge branch 'main' into patrice/infix-leaf
patricebender 8d184aa
Merge branch 'main' into patrice/infix-leaf
patricebender 6f9d2a2
Merge remote-tracking branch 'origin/main' into patrice/infix-leaf
patricebender 938fc77
simplify coding, improve error message
patricebender 17bc6cd
consider all steps
patricebender bf9f5e3
indent
patricebender e62537f
consider case where there is no where
patricebender 0280995
add a test for the weird query
patricebender File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -322,7 +322,7 @@ describe('(exist predicate) scoped queries', () => { | |
| WHERE EXISTS ( | ||
| SELECT 1 from bookshop.Books as $B | ||
| where $B.author_ID = author.ID and ($B.ID=201 or $B.ID=202) | ||
| ) and (author.ID=4711 or author.ID=4712) and (author.name='foo' or author.name='bar')` | ||
| ) and ((author.ID=4711 or author.ID=4712) and (author.name='foo' or author.name='bar'))` | ||
|
|
||
| expectCqn(transformed).to.equal(expected) | ||
| }) | ||
|
|
@@ -450,11 +450,11 @@ describe('(exist predicate) scoped queries', () => { | |
| $a.ID | ||
| } | ||
| WHERE EXISTS ( | ||
| SELECT 1 from bookshop.Books as $B | ||
| where $B.author_ID = $a.ID | ||
| SELECT 1 from bookshop.Books as $B2 | ||
| where $B2.author_ID = $a.ID | ||
| ) and EXISTS ( | ||
| SELECT 1 from bookshop.Books as $b2 | ||
| where $b2.author_ID = $a.ID | ||
| SELECT 1 from bookshop.Books as $b | ||
| where $b.author_ID = $a.ID | ||
| )` | ||
|
|
||
| expectCqn(transformed).to.equal(expected) | ||
|
|
@@ -497,15 +497,15 @@ describe('(exist predicate) scoped queries', () => { | |
| $a.ID | ||
| } | ||
| WHERE EXISTS ( | ||
| SELECT 1 from bookshop.Books as $B | ||
| where $B.author_ID = $a.ID | ||
| SELECT 1 from bookshop.Books as $B2 | ||
| where $B2.author_ID = $a.ID | ||
| and EXISTS ( | ||
| SELECT 1 from bookshop.Genres as $g | ||
| where $g.ID = $B.genre_ID | ||
| where $g.ID = $B2.genre_ID | ||
| ) | ||
| ) and EXISTS ( | ||
| SELECT 1 from bookshop.Books as $b2 | ||
| where $b2.author_ID = $a.ID | ||
| SELECT 1 from bookshop.Books as $b | ||
| where $b.author_ID = $a.ID | ||
| )` | ||
|
|
||
| expectCqn(transformed).to.equal(expected) | ||
|
|
@@ -533,11 +533,11 @@ describe('(exist predicate) scoped queries', () => { | |
| and EXISTS ( | ||
| SELECT 1 from bookshop.Books as $B3 where $B3.author_ID = $a.ID | ||
| and EXISTS ( | ||
| SELECT 1 from bookshop.Genres as $g where $g.ID = $B3.genre_ID | ||
| SELECT 1 from bookshop.Genres as $g2 where $g2.ID = $B3.genre_ID | ||
| ) | ||
| ) | ||
| ) and EXISTS ( | ||
| SELECT 1 from bookshop.Genres as $g2 where $g2.ID = $b.genre_ID | ||
| SELECT 1 from bookshop.Genres as $g where $g.ID = $b.genre_ID | ||
| )` | ||
|
|
||
| expectCqn(transformed).to.equal(expected) | ||
|
|
@@ -556,14 +556,14 @@ describe('(exist predicate) scoped queries', () => { | |
| $a.ID | ||
| } | ||
| WHERE EXISTS ( | ||
| SELECT 1 from bookshop.Books as $B where $B.author_ID = $a.ID | ||
| SELECT 1 from bookshop.Books as $B2 where $B2.author_ID = $a.ID | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. alias order changes because infix filter at leaf are put at the very front of the queries |
||
| ) and EXISTS ( | ||
| SELECT 1 from bookshop.Books as $b2 where $b2.author_ID = $a.ID | ||
| SELECT 1 from bookshop.Books as $b where $b.author_ID = $a.ID | ||
| and | ||
| ( | ||
| EXISTS ( | ||
| SELECT 1 from bookshop.Authors as $c where $c.ID = $b2.coAuthor_ID_unmanaged | ||
| ) or $b2.title = 'Sturmhöhe' | ||
| SELECT 1 from bookshop.Authors as $c where $c.ID = $b.coAuthor_ID_unmanaged | ||
| ) or $b.title = 'Sturmhöhe' | ||
| ) | ||
| )` | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,7 +65,7 @@ describe('infix filter on entities', () => { | |
| ] as Books {ID} where price > 5 group by price having price order by price limit 5`, model) | ||
| expect(query).to.deep.equal( | ||
| cds.ql`SELECT from bookshop.Books as Books {Books.ID} | ||
| WHERE (Books.price > 5) and (Books.price < 12.13) | ||
| WHERE Books.price < 12.13 and Books.price > 5 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only wrap in parens if really needed |
||
| GROUP BY Books.price, Books.title | ||
| HAVING Books.price and Books.title | ||
| ORDER BY Books.price, Books.title DESC | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done according to your wish @stewsk