Skip to content

Extract ForeignKeyMetadata from LibsqlDatabaseMetaData #209

Closed

Description

@magnusp

Goal

Move imported and exported foreign key shaping out of LibsqlDatabaseMetaData. Two near-copy 30-line methods build a 13-field record at different offsets, and a set of static helpers serves only them.

Depends on

#208. Same file.

Pin

LibsqlDatabaseMetaDataTest covers imported and exported keys, cross reference, empty databases, and constraint names. The xerial DBMetaDataTest covers column counts, named keys, mixed case, and incorrect references. DatabaseMetaDataIT covers the live path.

Scope

  • Create ForeignKeyMetadata with the raw row record, fromImported, fromExported, the JDBC row record, and the sort comparators.
  • Move the mappers from 704 to 769 and the helpers from 779 to 904.
  • Leave the two SQL strings in MetadataSql.

Preserve

  • The index asymmetries between imported and exported rows, including the primary-key column fallback.
  • KEY_SEQ is the pragma sequence plus one. DEFERRABILITY is always initially deferred.
  • nameOrEmpty turns null into "" for foreign key and primary key name, while getPrimaryKeys leaves the primary key name null.
  • primaryKeyName matches only CONSTRAINT <name> PRIMARY KEY, never an inline key.
  • foreignKeyName keeps the reverse index rule.
  • Exported primary key names stay blank unless the parent column set contains the column.

Acceptance

  • ForeignKeyMetadata.java exists and holds the moved logic unchanged.
  • LibsqlDatabaseMetaData.java is under 800 lines.
  • ./mvnw -pl libsql-jdbc -am test green with no assertion edited.
  • ./mvnw -pl libsql-conformance -am verify green.

Activity

  1. added
    P2Normal priority: edge case, feature gap, or test/process improvement
    on Oct 24, 2026
  2. added a commit that references this issue on Oct 24, 2026
    8295875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal priority: edge case, feature gap, or test/process improvement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions