fix: return MatrixOne foreign key metadata - #21
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
SQLForeignKeysreturns an empty result against MatrixOne even when the requested table has a valid foreign-key constraint. This breaks pyodbcCursor.foreignKeys()and other ODBC schema-introspection clients.Tested with:
maincommitc6b2ac9c1eaff0db867e845723a8ce1d2102928fbcc10fec25e5cbc7f1febb70f280c0d94bcac2c3Root cause
The inherited MySQL catalog query self-joins
INFORMATION_SCHEMA.KEY_COLUMN_USAGEforeign-key rowAto a second rowDrepresenting the referenced primary-key column, then requiresD.CONSTRAINT_NAME IS NOT NULL.MatrixOne exposes the foreign-key row, including all
REFERENCED_*fields, but does not expose a separate primary-key row inKEY_COLUMN_USAGE. The self-join therefore removes every valid foreign key.SHOW CREATE TABLEandINFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTSboth confirm that the constraint exists.Fix
REFERENTIAL_CONSTRAINTSon MatrixOne releases that do not expose it consistently; report the currently supportedNO ACTIONrule.Reproduction
Before this change,
rowsis empty. The same result occurs when calling the ANSI/Unicode ODBC API directly.Before / after
v9.7.0-mo.3): five validSQLForeignKeysargument combinations each returned 0 rows.myodbc9w.dllreturned exactly one row withparent.id -> child.parent_id,KEY_SEQ=1, andFK_NAME=fk_direct.Regression coverage
mo_odbc_deepnow:SQLGetFunctionsreportsSQL_API_SQLFOREIGNKEYS;SQLForeignKeysand asserts table names, column names, key sequence, foreign-key name, and exact row count.KEY_COLUMN_USAGE(server known issue) from a driver returning no row when the source metadata exists.Test scope
RelWithDebInfobuild: PASS; Unicode and ANSI driver targets compile.main: PASS.SQLForeignKeysW: PASSHYT00: PASS, 1.002 sHY008: PASS, 0.531 sNo Power BI scenario or Power BI-owned environment was modified by this change.