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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: integration should be unique per environment #1889

Merged
merged 1 commit into from Mar 20, 2024

Conversation

TBonnin
Copy link
Collaborator

@TBonnin TBonnin commented Mar 20, 2024

The unique constraint for integration is for unique_key, environment_id and deleted_at which can be null. However null values are not considered equal by default by postgres. 馃く

from postgres doc at https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS

By default, two null values are not considered equal in this
comparison. That means even in the presence of a unique constraint it is possible to store duplicate rows that contain a null value in at least one of the constrained columns. This behavior can be changed by adding the clause NULLS NOT DISTINCT

With this constraint, editing a integration with a name that already exists shows an error

Issue ticket number and link

https://linear.app/nango/issue/NAN-615/user-managed-to-create-two-integrations-with-the-same-integration-id

Checklist before requesting a review (skip if just adding/editing APIs & templates)

  • I added tests, otherwise the reason is:
  • I added observability, otherwise the reason is:
  • I added analytics, otherwise the reason is:

Copy link

linear bot commented Mar 20, 2024

Copy link
Member

@khaliqgant khaliqgant left a comment

Choose a reason for hiding this comment

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

nice

Copy link
Contributor

@bodinsamuel bodinsamuel left a comment

Choose a reason for hiding this comment

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

There is the same issue in Connections I think

The unique constraint for integration is for unique_key, environment_id
and deleted_at which can be null. However null values are not considered
equal by default by postgres. :/

from postgres doc at https://www.postgresql.org/docs/current/ddl-constraints.html#DDL-CONSTRAINTS-UNIQUE-CONSTRAINTS
> By default, two null values are not considered equal in this
comparison. That means even in the presence of a unique constraint it is
possible to store duplicate rows that contain a null value in at least
one of the constrained columns. This behavior can be changed by adding
the clause NULLS NOT DISTINCT
@TBonnin TBonnin force-pushed the tbonnin/nan-615/fix-integration-with-same-id branch from e919108 to 66c9730 Compare March 20, 2024 20:09
@TBonnin
Copy link
Collaborator Author

TBonnin commented Mar 20, 2024

There is the same issue in Connections I think

good point. modifying the constraint for connections table as well

@TBonnin TBonnin merged commit 32c0a31 into master Mar 20, 2024
22 checks passed
@TBonnin TBonnin deleted the tbonnin/nan-615/fix-integration-with-same-id branch March 20, 2024 20:17
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

3 participants