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 unique_constraints #152

Merged
merged 1 commit into from
Dec 18, 2024
Merged

Fix unique_constraints #152

merged 1 commit into from
Dec 18, 2024

Conversation

IceS2
Copy link
Contributor

@IceS2 IceS2 commented Dec 16, 2024

This PR aims to fix an issue with getting the wrong unique constraints from a table.

You can reproduce the issue by doing the following:

  1. Create a schema SCHEMA_A
  2. Create a table SCHEMA_A.TABLE with a constraint such as CONSTRAINT_NAME UNIQUE(COL1, COL2)
  3. Create another schema SCHEMA_B
  4. create another table SCHEMA_B.TABLEwith a constraint such as CONSTRAINT_NAME UNIQUE(COL1, COL3) *Important, the constraint name must be the same.

With that setup, if you run the query you can see that for both SCHEMA_A.TABLE and SCHEMA_B_TABLE you will find the constraint being: COL1, COL2, COL1, COL3.
This happens because we're doing a cross join and filtering only by the constraint name.

The PR changes the Query to actually do a join on:

  • Constraint Name
  • Schema Name
  • Table Name
    in order to avoid this issue

Signed-off-by: Pablo Takara <[email protected]>
@bchoudhary6415 bchoudhary6415 merged commit bfe67ae into ibmdb:master Dec 18, 2024
2 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