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 missing type inference to .set/.with of UPDATE #352

Merged
merged 4 commits into from
Dec 2, 2024

Conversation

stockbal
Copy link
Contributor

Adds proper type inference for .set/.with of UPDATE queries when using cds-typer classes.

All variants are now supported as documented here

let [ ID, quantity ] = [ 201, 1 ]
UPDATE (Books,ID) .with ({
  title: 'Sturmhöhe',       //>  simple value
  stock: {'-=': quantity},    //>  qbe expression
  descr: {xpr: [{ref:[descr]}, '||', 'Some addition to descr.']}
})

image
image
image

Shortcomings

When using the following variants

UPDATE.entity("Foos").set({ test: {xp: "4"} });
UPDATE.entity({} as linked.classes.entity).set({ asdf: 434 });
UPDATE`Foos`.set`x = 4`.where`x > 10`

there is no intellisense at all, so it works as before. It would be great to also get intellisense working for qbe and cqn expressions for those, but I didn't manage.

apis/ql.d.ts Show resolved Hide resolved
apis/ql.d.ts Outdated Show resolved Hide resolved
apis/ql.d.ts Outdated Show resolved Hide resolved
@daogrady
Copy link
Contributor

daogrady commented Dec 2, 2024

This looks good now! Thanks for contribution, once again. Is this PR ready to be merged or do you need to make any more changes?

@stockbal
Copy link
Contributor Author

stockbal commented Dec 2, 2024

No. I am done from my side

@daogrady daogrady enabled auto-merge (squash) December 2, 2024 12:22
@daogrady daogrady merged commit 3c27b65 into cap-js:main Dec 2, 2024
6 checks passed
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.

2 participants