Repository navigation
fix(jdbc): only report isAutoIncrement for a real AUTOINCREMENT primary key - #56
Merged
Merged
Conversation
magnusp
force-pushed
the
fix/38-autoincrement-detection
branch
from
October 21, 2026 21:37
0cb9c38 to
a5ed7c5
Compare
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.
Closes #38. Part of #54.
What changed
LibsqlResultSetMetaData.isAutoIncrementno longer scans the wholeCREATE TABLEtext for the wordAUTOINCREMENT. It now checks the definition of the matching column.LibsqlResultSetMetaData.isAutoIncrementColumn(String createSql, String columnName), so DatabaseMetaData.getColumns reports wrong types and sizes #42 can reuse the detection forgetColumnsinstead of reimplementing the parsing.CREATE TABLEstatement, skipping comments, string literals, and quoted identifiers, splits the table body into column and table constraint definitions, and looks for an unquotedAUTOINCREMENTkeyword in the matching column definition or table-levelPRIMARY KEY (column AUTOINCREMENT)constraint.myautoincrement, a table-levelPRIMARY KEY (id AUTOINCREMENT)constraint, and a quoted identifier namedAUTOINCREMENT. The existing real-AUTOINCREMENT, comment, and string-literal tests remain.Contract decision
Parity with xerial 3.53.4.0. Probed xerial 3.53.4.0 directly for the cases below:
isAutoIncrementcreate table t(myautoincrement integer primary key)falsecreate table t(id integer primary key autoincrement)truecreate table t(id integer primary key /* AUTOINCREMENT */)falsecreate table t(id integer primary key, note text default 'AUTOINCREMENT')falsecreate table t(id integer, primary key(id autoincrement))truecreate table t("AUTOINCREMENT" integer primary key)falseThe fix matches all six.
Evidence
Failing before the fix (new test on
f38bd24):Passing after the fix:
Deviations
feat/jdbc-xerial-conformance(PR feat(jdbc): add xerial conformance suite and harden metadata #28) instead ofmain. The code this issue references (isAutoIncrementscanningCREATE TABLE,SqlTableReference) exists only on that branch;origin/mainstill hardcodesisAutoIncrementtofalseand has no table context. Implementing isAutoIncrement false-positives on identifiers containing AUTOINCREMENT #38 directly onmainwould require editingLibsqlResultSet.java(Lane A) and duplicating feat(jdbc): add xerial conformance suite and harden metadata #28. GitHub will retarget this PR tomainwhen feat(jdbc): add xerial conformance suite and harden metadata #28 merges.