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

test(referential-action-set-null): add SQL tests for 1:1, 1:n relations with SET NULL referential actions #15728

Closed
wants to merge 14 commits into from

Conversation

jkomyno
Copy link
Contributor

@jkomyno jkomyno commented Oct 10, 2022

To run tests:

  • cd package/client
  • pnpm test:functional referential-action-set-null/tests_1-to-1.ts
  • pnpm test:functional referential-action-set-null/tests_1-to-n.ts

These tests expect the following environment variables (which are already used by the test codebase):

  • TEST_FUNCTIONAL_MYSQL_URI
  • TEST_FUNCTIONAL_POSTGRES_URI
  • TEST_FUNCTIONAL_COCKROACH_URI (unnecessary when TEST_SKIP_COCKROACHDB is defined)
  • TEST_MSSQL_URI (unnecessary when TEST_SKIP_MSSQL is defined)

Outcome

  • For both 1:1 and 1:n relations:
    • postgres doesn't validate DDL statements that set a SET NULL referential action on a foreign key constraint whose referenced column (or one of the referenced columns) is NOT NULL, all other database throw a validation error in this case.
    • postgres fails at runtime with a not-null constraint violation error when UPDATE / DELETE statements trigger the SET NULL referential action on a column defined as NOT NULL
  • sqlserver fails at runtime on 1:1 NULL relations because NULL conflicts with UNIQUE indexes in that particular database

TODOs

  • fix cockroach and postgres in insert + update + delete tests
  • fix Migration engine error: db error: ERROR: database “PRISMA_DB_NAME” is being accessed by other users
  • Skip miniproxy
  • Fix buildkite CI
    • on postgres: error: database "PRISMA_DB_NAME" does not exist
    • on sqlserver: Login failed for user 'sa'.
  • (LOW PRIORITY, can be done after we go GA with referential integrity) define TEST_FUNCTIONAL_MARIADB_URI in CI as "mysql://root:root@localhost:4306/PRISMA_DB_NAME"

@jkomyno jkomyno changed the title test(referential-action-set-null): add 'create table' tests for 1:1 NOT NULL relation test(referential-action-set-null): add SQL tests for 1:1 relations Oct 10, 2022
@jkomyno jkomyno changed the title test(referential-action-set-null): add SQL tests for 1:1 relations test(referential-action-set-null): add SQL tests for 1:1 relations with SET NULL referential action Oct 10, 2022
@jkomyno jkomyno changed the title test(referential-action-set-null): add SQL tests for 1:1 relations with SET NULL referential action test(referential-action-set-null): add SQL tests for 1:1 relations with SET NULL referential actions Oct 10, 2022
@jkomyno jkomyno added this to the 4.5.0 milestone Oct 10, 2022
@jkomyno jkomyno changed the title test(referential-action-set-null): add SQL tests for 1:1 relations with SET NULL referential actions test(referential-action-set-null): add SQL tests for 1:1, 1:n relations with SET NULL referential actions Oct 10, 2022
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.

None yet

2 participants