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

fix: add placeholder for string values #733

Merged
merged 13 commits into from
Jul 15, 2024
Merged

Conversation

mariayord
Copy link
Contributor

@mariayord mariayord commented Jul 8, 2024

Fixes : cap/issues/issues/16220

@mariayord mariayord changed the title Fix: add pleaseholder for string values fix: add pleaseholder for string values Jul 8, 2024
@patricebender patricebender changed the title fix: add pleaseholder for string values fix: add placeholder for string values Jul 8, 2024
Copy link
Contributor

@johannes-vogel johannes-vogel left a comment

Choose a reason for hiding this comment

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

@BobdenOs looks good to me? What do you think?

@BobdenOs
Copy link
Contributor

BobdenOs commented Jul 8, 2024

@johannes-vogel there are val scenarios where the final result will be a string, but at this point of the code it might still be a Date objects. So while this fulfills the original description. There might be more scenarios where they should be created as place holders. Additionally it might make sense to check whether the incoming x has params already defined as true. Which we should allow to overwrite this logic.

let sql = this.expr({ param: false, __proto__: x })

let sql = x.param !== true && (typeof x.val === 'number' || x.val === null) ? this.expr({ param: false, __proto__: x }): this.expr(x)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the null it doesn't have a type. So whatever type the ? is assigned by the database null is accepted and will be returned correctly as a null.

Copy link
Contributor Author

@mariayord mariayord Jul 9, 2024

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@mariayord mariayord Jul 9, 2024

Choose a reason for hiding this comment

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

@BobdenOs Do you think the generated snapshot is wrong and in this case there should be a placeholder for null ?
I added a check to fix the test.

Copy link
Contributor

Choose a reason for hiding this comment

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

When changing behavior all snapshots are wrong by default. It is required to check the difference between the snapshots when changing the behavior. I would rather look at the integration tests whether the behavior is correct. If Postgres and HANA don't have problem with handling placeholders for null values in the select columns. I would interpretate null as placeholders.

Copy link
Contributor Author

@mariayord mariayord Jul 10, 2024

Choose a reason for hiding this comment

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

It is required to check the difference between the snapshots when changing the behavior.

I checked this , the question is if the old result of the test is correct, with no placeholder for null value.
If you say it is not the problem for db to have a null placeholder, the test result before was wrong!

Copy link
Contributor

Choose a reason for hiding this comment

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

When changing behavior all snapshots are wrong by default

I would rather look at the integration tests whether the behavior is correct.

Does SELECT([{val: null, as:'Null'}]) return [{"Null":null}] when executed on all the databases ? If that is the case then the snapshot is wrong.

@@ -53,6 +53,13 @@ describe('Bookshop - Read', () => {
expect(columns).to.contain('title')
})

test('Path expression with null value', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. the test name is incorrect
  2. there is already a test doing this as was shared with you before here

Copy link
Contributor Author

@mariayord mariayord Jul 10, 2024

Choose a reason for hiding this comment

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

  1. Please make a suggestion for the test name if you don't like it.
  2. This is an integration test (I suppose it should run with Hana, Postgres..), the other one is unit, if this is not the case please point where to add the integration test.

@mariayord mariayord merged commit 8136a45 into main Jul 15, 2024
4 checks passed
@mariayord mariayord deleted the placeholder-string-val branch July 15, 2024 10:56
@cap-bots cap-bots mentioned this pull request Jul 15, 2024
@cap-bots cap-bots mentioned this pull request Jan 28, 2025
This was referenced Jan 28, 2025
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.

3 participants