-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: cds failing tests #154
Conversation
@stewsk In the recent change of cqn4sql the wildcard logic no longer include the generated foreign keys. While the cds tests expect them to be returned. Any suggestions ? |
Hi @BobdenOs ,
which change are you referring to? |
db-service/lib/cqn2sql.js
Outdated
@@ -239,7 +239,8 @@ class CQN2SQLRenderer { | |||
: SELECT.columns.map(x => { | |||
const name = this.column_name(x) | |||
// REVISIT: can be removed when alias handling is resolved properly | |||
const d = elements[name] || elements[name.substring(1, name.length - 1)] | |||
// REVISIT: for some reason not all elements are available in the elements list | |||
const d = x.element || elements[name] |
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.
Better than before, anyways, but...
x.element
should always be defined, and the fallback never requiredq.elements
should contain all expected elements definitions ac cording to the result set type
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.
x.element
does not exist when x
is an expand sub select.
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.
Does an entry for that exist in q.elements
? → then x.element
should exist as well and be the same
// SELECT.from() does not accept joins | ||
select.SELECT.from = from |
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.
Why do we see joins here?
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.
We get a join when streaming from draft entities. between *.drafts
and DraftAdministrativeData
.
db-service/lib/cqn2sql.js
Outdated
// Column names like "Order" clash with "ORDER" keyword so toUpperCase is required | ||
if (s.toUpperCase() in this.class.ReservedWords || /^\d|[$' ?@./\\]/.test(s)) return '"' + s + '"' |
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.
Better add the capitalised casing to ReservedWords
Timestamp: e => `ISO(${e})`, | ||
// REVISIT: generic-virtual.test.js expects now to be returned as ISO string | ||
// test 'field with current timestamp is correctly formatted' fails otherwise |
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.
Lets fix this test please
sqlite/lib/SQLiteService.js
Outdated
Float: expr => `nullif(quote(${expr}),'NULL')->'$'`, | ||
Double: expr => `nullif(quote(${expr}),'NULL')->'$'`, |
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.
Shouldn't we keep these out as before and discussed?
…o fix-cds-tests
Replaced > fuzzyKeys('Order')
{
Order: 1,
order: 1,
'O�der': 1,
'o�der': 1,
'Or�er': 1,
'or�er': 1,
'O��er': 1,
'o��er': 1,
'Ord�r': 1,
'ord�r': 1,
'O�d�r': 1,
'o�d�r': 1,
'Or��r': 1,
'or��r': 1,
'O���r': 1,
'o���r': 1,
'Orde�': 1,
'orde�': 1,
'O�de�': 1,
'o�de�': 1,
'Or�e�': 1,
'or�e�': 1,
'O��e�': 1,
'o��e�': 1,
'Ord��': 1,
'ord��': 1,
'O�d��': 1,
'o�d��': 1,
'Or���': 1,
'or���': 1,
'O����': 1,
'o����': 1
} |
fuzzyKeys was build with the expectation that all keywords where provided in uppercase. My understanding is that the number of keys on an object should negatively impact the key lookup speed. That is why I added the question mark. My main concern with only having reasonable keys in the map is that the behaviour is different from having the check be case insensitive. So adding a secondary case insensitive check would be required to maintain functional consistency. |
Current issue is that |
I think that |
When someone combines I fixed this issue here , but this makes all the cqn4sql tests fail. |
Just to avoid that we misunderstand each other: can you provide an example for what the select looks like, what you expect it should do, and what it actually does (currently)? |
Sure here are all the scenarios: simpleinput: select * from Books output: select ID, tittle, descr, author_ID, genre_ID from Books with expandinput: select *, author { * } from Books output: select
ID,
tittle,
descr,
(select ID, name from Author where Author.ID = Books.author_ID) as author,
genre_ID
from Books expected: select
ID,
tittle,
descr,
(select ID, name from Author where Author.ID = Books.author_ID) as author,
author_ID, -- this column is currently missing
genre_ID
from Books |
Ok, I see.
the
as the effective/resulting name of If you wrote
then you would get the foreign key from the |
@patricebender - we need to have a detailed look at this when you are back. |
this reverts the cqn4sql part of the hotfix in #154 --- The problem was, that in a flat model, the foreign keys were not part of the result anymore, in case that the respective association was overwritten by the smart wildcard mechanism. E.g. by an expand. The reason was, that in case of a flat model, we skipped the foreign keys and still flattened the association. This caused the bug where overwritting an association caused the lack of the foreign key in the result. The fix here is simple, skip the association from the wildcard expansion instead. The compiler already, correctly generated the foreign key elements for us.
…ode (#176) * cqn4sql: skip assocs from wildcard expansion instead of fks in flat mode this reverts the cqn4sql part of the hotfix in #154 --- The problem was, that in a flat model, the foreign keys were not part of the result anymore, in case that the respective association was overwritten by the smart wildcard mechanism. E.g. by an expand. The reason was, that in case of a flat model, we skipped the foreign keys and still flattened the association. This caused the bug where overwritting an association caused the lack of the foreign key in the result. The fix here is simple, skip the association from the wildcard expansion instead. The compiler already, correctly generated the foreign key elements for us. * adapt test description * no debug * Update db-service/test/cqn4sql/wildcards.test.js Co-authored-by: Steffen Weinstock <[email protected]> --------- Co-authored-by: Steffen Weinstock <[email protected]>
Description
After investigating #153 I determined there are more breaking changes merged into main. As part of cleanup and refactor PRs. This PR contains fixes and analysis of why cds tests started to fail.