Skip to content

refactor(jdbc): extract AUTOINCREMENT grammar - #220

Merged
magnusp merged 1 commit into
mainfrom
refactor/i202-auto-increment-grammar
Oct 24, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/i202-auto-increment-grammar

Conversation

@magnusp

@magnusp magnusp commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Fixes #202

Moves the AUTOINCREMENT grammar out of LibsqlResultSetMetaData into package-private SqlAutoIncrement (same package), and points both call sites at it. The package-private seam no longer lives on the metadata class.

What moved

  • New SqlAutoIncrement.java: isAutoIncrementColumn, tableDefinitions, columnDefinitionIsAutoIncrement, tableConstraintIsAutoIncrement, indexedColumnIsAutoIncrement, skipConstraintName, isConstraintKeyword, containsKeyword.
  • LibsqlResultSetMetaData.isAutoIncrement now calls SqlAutoIncrement.isAutoIncrementColumn(...) and keeps the info.primaryKey() requirement.
  • LibsqlDatabaseMetaData.getColumns now calls SqlAutoIncrement.isAutoIncrementColumn(...) and keeps the primaryKey && guard.
  • No parse rule, message, test, dependency, pom.xml, type-mapping, declared-type, or table-resolver code changed.

Verbatim proof

Old method blocks (origin/main lines 73–88 and 529–648) vs new SqlAutoIncrement lines 11–147, whitespace-normalized (trailing whitespace trimmed, blank lines dropped):

$ git show origin/main:.../LibsqlResultSetMetaData.java | sed -n '73,88p;529,648p' > /tmp/old-grammar.txt
$ sed -n '11,147p' .../SqlAutoIncrement.java > /tmp/new-grammar.txt
$ sed 's/[[:space:]]*$//' /tmp/old-grammar.txt | grep -v '^$' > /tmp/old-n.txt
$ sed 's/[[:space:]]*$//' /tmp/new-grammar.txt | grep -v '^$' > /tmp/new-n.txt
$ diff -u /tmp/old-n.txt /tmp/new-n.txt
NORMALIZED-DIFF: empty; 128 code lines identical

The only non-code delta is the single blank separator line between the two extracted method groups; the original separator was blank line 89.

Probe

Perturbed comment skipping in SqlTokenizer so a block comment emitted its body as a WORD token, making the keyword inside /* AUTOINCREMENT */ visible to containsKeyword:

$ ./mvnw -pl libsql-jdbc -am -Dtest='LibsqlResultSetMetaDataTest#ignoresAutoIncrementInsideSqlComments' \
    -Dsurefire.failIfNoSpecifiedTests=false test
[ERROR] LibsqlResultSetMetaDataTest.ignoresAutoIncrementInsideSqlComments -- Time elapsed: 0.045 s <<< FAILURE!
Expecting value to be false but was true
	at ...LibsqlResultSetMetaDataTest.ignoresAutoIncrementInsideSqlComments(LibsqlResultSetMetaDataTest.java:128)
[ERROR] Tests run: 1, Failures: 1, Errors: 0, Skipped: 0

Reverted with git checkout -- .../SqlTokenizer.java; git status --porcelain then listed only the three intended files.

Line counts

  • LibsqlResultSetMetaData.java: 680 → 544 lines (limit < 580).
  • SqlAutoIncrement.java: 148 lines (new).
  • git diff --stat: 3 files changed, 152 insertions(+), 140 deletions(-).

Lanes

  • ./mvnw -pl libsql-jdbc -am test → 392 tests, 0 failures, 0 errors, 0 skipped.
  • ./mvnw spotless:apply → BUILD SUCCESS; ./mvnw spotless:check → BUILD SUCCESS (no reformat needed).
  • ./mvnw -pl libsql-conformance -am verify → 272 tests, 0 failures, 0 errors, 7 skipped (matches baseline).

@magnusp
magnusp merged commit 5d01c95 into main Oct 24, 2026
6 checks passed
@magnusp
magnusp deleted the refactor/i202-auto-increment-grammar branch October 24, 2026 15:11
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.

Extract the AUTOINCREMENT grammar from LibsqlResultSetMetaData

1 participant