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: properly support default, cds.on.insert and cds.on.update for UPSERT queries #425

Merged
merged 47 commits into from
Oct 22, 2024

Conversation

SamuelBrucksch
Copy link
Contributor

@SamuelBrucksch SamuelBrucksch commented Jan 24, 2024

This PR unifies the UPSERT implementation of all the database services. resulting in 2 helper functions in each database service that allow for defining the database specific JSON extraction logic and the database specific undefined check. With these special cases covered it is possible to generate INSERT and UPSERT statements that correctly apply default, @cds.on.insert and @cds.on.update values. Which currently only apply to @cap-js/hana and is a big blocker for most use cases of UPSERT and the @sap/cds/common.cds use the @cds.on.insert annotations. Which with the current UPSERT implementation could possibly be null which should be impossible as every entry in the database has to have been inserted once.

@SamuelBrucksch SamuelBrucksch changed the title support defaults for upsert feat: support defaults for upsert Jan 24, 2024
@SamuelBrucksch SamuelBrucksch marked this pull request as draft January 24, 2024 10:45
danjoa
danjoa previously requested changes Jan 29, 2024
Copy link
Contributor

@danjoa danjoa left a comment

Choose a reason for hiding this comment

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

Let's review that in one of our next syncs please ...
These are a lot of code changes all over the place, just to add support for defaults?
Particularly dislike, that we now seem to do quoting everywhere?

P.S. After the big cleanup we need extra discipline to keep it clean ;)

@BobdenOs BobdenOs changed the title feat: support defaults for upsert chore: unify UPSERT implementation Feb 22, 2024
@BobdenOs BobdenOs marked this pull request as ready for review February 22, 2024 09:28
@BobdenOs BobdenOs mentioned this pull request Mar 8, 2024
@Magoli1
Copy link

Magoli1 commented Sep 25, 2024

Hey @BobdenOs , is there any ETA on this PR? 💯

@johannes-vogel johannes-vogel dismissed danjoa’s stale review October 22, 2024 09:33

outdated from january

@BobdenOs BobdenOs changed the title chore: unify UPSERT implementation fix: properly support default, cds.on.insert and cds.on.update for UPSERT queries Oct 22, 2024
@BobdenOs BobdenOs merged commit 338e9f5 into main Oct 22, 2024
4 checks passed
@BobdenOs BobdenOs deleted the upsert-defaults branch October 22, 2024 11:12
@cap-bots cap-bots mentioned this pull request Oct 22, 2024
johannes-vogel added a commit that referenced this pull request Oct 29, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>db-service: 1.14.1</summary>

##
[1.14.1](db-service-v1.14.0...db-service-v1.14.1)
(2024-10-28)


### Fixed

* deep delete for views
([#496](#496))
([82154ef](82154ef))
* properly support `default`, `cds.on.insert` and `cds.on.update` for
`UPSERT` queries ([#425](#425))
([338e9f5](338e9f5))
* SELECT cds.hana.BINARY
([#870](#870))
([33c3ebe](33c3ebe))
</details>

<details><summary>sqlite: 1.7.5</summary>

##
[1.7.5](sqlite-v1.7.4...sqlite-v1.7.5)
(2024-10-28)


### Fixed

* properly support `default`, `cds.on.insert` and `cds.on.update` for
`UPSERT` queries ([#425](#425))
([338e9f5](338e9f5))
</details>

<details><summary>postgres: 1.10.2</summary>

##
[1.10.2](postgres-v1.10.1...postgres-v1.10.2)
(2024-10-28)


### Fixed

* properly support `default`, `cds.on.insert` and `cds.on.update` for
`UPSERT` queries ([#425](#425))
([338e9f5](338e9f5))
</details>

<details><summary>hana: 1.4.0</summary>

##
[1.4.0](hana-v1.3.2...hana-v1.4.0)
(2024-10-28)


### Added

* Improve procedure metadata lookup logic
([#862](#862))
([da629d9](da629d9))


### Fixed

* enable `cesu8` by default for `hdb` driver and encode entries streams
([#868](#868))
([d85d7e6](d85d7e6))
* Include `binary` type with `varbinary` type in `hana-client`
([#871](#871))
([f4d7caf](f4d7caf))
* nested functions in comparisons
([#861](#861))
([f3fd254](f3fd254))
* properly support `default`, `cds.on.insert` and `cds.on.update` for
`UPSERT` queries ([#425](#425))
([338e9f5](338e9f5))
* SELECT cds.hana.BINARY
([#870](#870))
([33c3ebe](33c3ebe))
* Throw error if rows in limit is missing for expand, same as in limit()
([#858](#858))
([641c3b9](641c3b9))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Johannes Vogel <31311694+johannes-vogel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next release pr to be checked for next release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants