Repository navigation
feat(jdbc): read key and type metadata from SQLite pragmas - #143
Merged
Merged
Conversation
getImportedKeys, getExportedKeys, and getCrossReference now map pragma foreign_key_list rows to the JDBC shape, getTypeInfo returns the sqlite-jdbc type table, and getPrimaryKeys reports the parsed constraint name in PK_NAME. Fixes #113
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.
Fixes #113.
Contract: Hrana 3 governs transport and values, so the pragmas run through
execute;java.sqldefines the 14-column foreign-key shape, the six primary-key columns, and the 18 type-info columns; xerial/sqlite-jdbc 3.53.4.0 is the behavioral reference for row values and the type table.Changes
getImportedKeys,getExportedKeys, andgetCrossReferencereadpragma foreign_key_list(joined tosqlite_schemafor constraint names and case-corrected table names) and synthesize the xerial row shape, includingKEY_SEQ, update/delete rule constants,FK_NAME,PK_NAME, andDEFERRABILITY.getTypeInforeturns the sqlite-jdbc type table:NULL,INTEGER,REAL,TEXT,BLOB, ordered byDATA_TYPE, with the same per-type flags.getPrimaryKeysparses a namedCONSTRAINT ... PRIMARY KEYfrom the table SQL and reports it inPK_NAME; inline primary keys keep a NULLPK_NAME.Divergences and reference notes
getCrossReferencewith both a parent and a child table returns the real matching rows. xerial ends that path inlimit 0and returns no rows. Reason: the issue asks for pragma-driven key metadata, and the both-table form is the useful cross-reference query.getPrimaryKeyskeeps the driver's existingKEY_SEQordering. xerial orders primary-key columns byCOLUMN_NAME; ordering is unchanged by this PR and composites remain readable throughKEY_SEQ.DEFERRABILITYis alwaysimportedKeyInitiallyDeferred, matching xerial.pragma foreign_key_listdoes not expose deferrability.getPrimaryKeys, matching xerial.Evidence at head d6ea8b7 (base 662d066)
./mvnw -pl libsql-jdbc test -Dtest=LibsqlDatabaseMetaDataTestat trunkWHERE 0stubs and missingPK_NAMEDOCKER_CONFIG=... ./mvnw -pl libsql-itests -am -Dit.test=DatabaseMetaDataIT verify./mvnw -pl libsql-jdbc test./mvnw -pl libsql-conformance -am verify./mvnw -pl libsql-conformance -am -Pxerial-control verify./mvnw spotless:check./mvnw test-Dtest=LibsqlDatabaseMetaDataTest#emptyDatabaseReturnsWellFormedEmptyKeyMetadata./mvnw -pl libsql-jdbc -am package -DskipTestsLogs:
/tmp/xerial-parity-i113/.Files outside the plan's Files block
libsql-itests/src/test/java/com/github/magnusp/libsql/itest/DatabaseMetaDataIT.javais new. Lane 3 requires a live sqld metadata case, and the plan's Files block names no itest file.Ready for review. Not merged.