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

Implement deferrable foreign keys for SAP HANA #6104

Merged
merged 2 commits into from Feb 19, 2022

Conversation

alumni
Copy link
Contributor

@alumni alumni commented May 20, 2020

Related feature request: #6098, #2191.

I've added deferrable (check time) options for foreign keys on SAP HANA. See <references_specification> in the CREATE TABLE and ALTER TABLE specification:

<references_specification> ::= 
  REFERENCES <referenced_table> [ ( <referenced_column_name_list> ) ]
  [ <referential_triggered_action> ]
  [ <constraint_enforcement> ]
  [ <constraint_check_time> ]
<constraint_check_time> ::= INITIALLY { IMMEDIATE | DEFERRED }

as well as the REFERENTIAL_CONSTRAINTS system table in their official documentation:

Column name Data type Description
CHECK_TIME STRING The time when the constraint is checked: INITIALLY_IMMEDIATE or INITIALLY DEFERRED.

Notes:

  • The implementation is using the already defined deferrable attribute in RelationOptions, that has the possible values INITIALLY IMMEDIATE and INITIALLY DEFERRED, same as the specification for the REFERENCES SQL expression.
  • In the REFERENTIAL_CONSTRAINTS table, the possible values are INITIALLY_IMMEDIATE (with underscore) and INITIALLY DEFERRED (with space).

@imnotjames
Copy link
Contributor

You need to add tests for this feature.

@pleerock
Copy link
Member

Looks like no response from author, closing it.

@pleerock pleerock closed this Nov 10, 2021
@alumni
Copy link
Contributor Author

alumni commented Nov 10, 2021 via email

@alumni
Copy link
Contributor Author

alumni commented Nov 10, 2021

BTW, we maintain a lot of patches for the HANA driver locally, we just avoid creating PRs for this reason. We test them as part of our E2E, but since we have no idea how to run the TypeORM tests with HANA locally + the slow PR review process makes us avoid submitting PRs.

@pleerock pleerock reopened this Nov 23, 2021
@pleerock
Copy link
Member

It can be a good contribution if you find the way to setup SAP Hana on CI.

Then it will simplify process of merging (at least we can be sure nothing was broke).
Also it will simplify your experience when you upgrade ORM version.

@alumni
Copy link
Contributor Author

alumni commented Nov 23, 2021

@pleerock The easiest way would be with a HANA Cloud instance. The only required setup in that case would be the hostname and the credentials. Then every time the tests are run a DB schema could be created for that run and dropped when it's over. The main question would be how to get access to a HANA Cloud instance (it could get quite pricey) - maybe SAP could donate it?

@pleerock
Copy link
Member

We need something free. Can't we simply setup something in a docker container for our CI?

@alumni
Copy link
Contributor Author

alumni commented Nov 24, 2021

@pleerock HANA Cloud (v4.0) has a free trial (I think it's limited to 30 days but can be extended to 90 days). Not sure how to get the free 1 year advertised on their website.

There's also the possibility to run HANA express (v2.0) inside a container, it seems it's free up to 32gb memory:

@pleerock
Copy link
Member

HANA Cloud (v4.0) has a free trial (I think it's limited to 30 days but can be extended to 90 days). Not sure how to get the free 1 year advertised on their website.

if it has a time period limit its not an option for us.

There's also the possibility to run HANA express (v2.0) inside a container, it seems it's free up to 32gb memory:

would be great if someone can contribute and setup sap-hana-express-edition container in our CI, so we can run tests inside it.

@AlexMesser AlexMesser merged commit 1f54c70 into typeorm:master Feb 19, 2022
@AlexMesser
Copy link
Collaborator

thank you for contribution!

@alumni alumni deleted the sap-hana-deferrable-foreign-keys branch January 3, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants