Skip to content

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 <pjt1991@gmail.com>
@bchoudhary6415 bchoudhary6415 merged commit bfe67ae into ibmdb:master Dec 18, 2024
2 checks passed
devMalteK pushed a commit to devMalteK/python-ibmdbsa that referenced this pull request May 23, 2025
Signed-off-by: Pablo Takara <pjt1991@gmail.com>
Signed-off-by: deMalte <demalte@kochnetonline.de>
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