Skip to content

Extract MetadataSql query builders from LibsqlDatabaseMetaData #207

Closed

Description

@magnusp

Goal

Move the metadata query builders out of LibsqlDatabaseMetaData. Nine builders use three different string-building idioms, and literal escaping is positional and repeated at four sites.

Depends on

None. First pass in the LibsqlDatabaseMetaData chain.

Pin

LibsqlDatabaseMetaDataTest covers escaping, type filters, schema ordering, index info round trips, and table types. The xerial DBMetaDataTest covers quote handling and column order. DatabaseMetaDataIT covers the live path.

Scope

  • Create MetadataSql with literal(String) and one method per query, tables, columns, imported keys, exported keys, primary keys, table types, schemas and catalogs, and index info.
  • Move escapeLiteral and the builders from 450 to 507, 671 to 702, and 909 to 1001.
  • Keep arg normalization and result shaping in the metadata class.

Preserve

  • Every SQL string byte for byte. Tests assert fragments, and the test doubles dispatch on substrings such as JOIN pragma_foreign_key_list.
  • AND TABLE_TYPE IN ('TABLE','VIEW') keeps no space after the comma.
  • types[i].toUpperCase() stays without a locale.
  • getColumns keeps passing a null originSql.
  • Empty types keeps behaving like null.

Acceptance

  • MetadataSql.java exists, and LibsqlDatabaseMetaData.java is under 950 lines.
  • The generated SQL is byte-identical. Prove it with the existing assertions, not by eye.
  • ./mvnw -pl libsql-jdbc -am test green with no assertion edited.
  • ./mvnw -pl libsql-conformance -am verify green.
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