Skip to content

refactor(jdbc): shape getColumns rows through named records - #230

Merged
magnusp merged 1 commit into
mainfrom
refactor/i208-columns-shaper
Oct 24, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/i208-columns-shaper

Conversation

@magnusp

@magnusp magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Fixes #208

What

Replaces the positional shaping in getColumns with named records.

  • COLUMN_COLUMNS: the 24 Col entries lifted to a static constant beside FOREIGN_KEY_COLUMNS. Values and order unchanged.
  • ColumnMetadata (new, package-private): the whole getColumns shape.
    • PragmaRow.fromRow(Row) names the nine pragma_table_xinfo positions once.
    • JdbcRow.toRow() names every one of the 24 JDBC columns.
    • columnShape/ColumnShape moved verbatim from LibsqlDatabaseMetaData, where they had no other caller.
  • getColumns now delegates to ColumnMetadata.columns(raw, COLUMN_COLUMNS) and contains no positional values.get(n).

Preserved exactly: IS_AUTOINCREMENT is the primary-key flag and the grammar result; IS_GENERATEDCOLUMN is hidden == 2 || hidden == 3; NULLABLE derives from notnull only; REMARKS stays NULL; the SQL_* and SCOPE_* columns keep their values; NUM_PREC_RADIX stays the literal 10; BUFFER_LENGTH and CHAR_OCTET_LENGTH stay 2_000_000_000. No SQL text touched.

Diff

 .../libsql/jdbc/ColumnMetadata.java           | 177 +++++++++++++++++++++
 .../libsql/jdbc/LibsqlDatabaseMetaData.java   | 159 ++++--------------
 2 files changed, 205 insertions(+), 131 deletions(-)

Line counts: LibsqlDatabaseMetaData.java 949 -> 846 (target under 900); new ColumnMetadata.java 177.

Probe

Set NULLABLE to always columnNullable in JdbcRow.toRow(), then:

LibsqlDatabaseMetaDataTest.getColumnsReportsDeclaredTypesSizesNullabilityAndAutoIncrement:349
expected: 0 but was: 1
Tests run: 54, Failures: 1, Errors: 0

Reverted; the full suite is green afterward.

Lanes

Lane Result
./mvnw -pl libsql-jdbc -am test 398 tests, 0 failures, 0 errors
./mvnw spotless:check SUCCESS
./mvnw -pl libsql-conformance -am verify 272 tests, 0 failures, 7 skipped

No test assertion edited, no pom.xml change.

@magnusp
magnusp merged commit d996c33 into main Oct 24, 2026
6 checks passed
@magnusp
magnusp deleted the refactor/i208-columns-shaper branch October 24, 2026 17:54
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.

Shape getColumns rows through named records

1 participant