Skip to content

fix: table-level PRIMARY KEY(col) rowid alias reads back NULL when the table has other columns (#686) - #715

Open
dpsiderius wants to merge 1 commit into
mainfrom
fix/686-rowid-alias-b
Open

dpsiderius wants to merge 1 commit into
mainfrom
fix/686-rowid-alias-b

Conversation

@dpsiderius

Copy link
Copy Markdown
Contributor

What

src/schema/ddl_reader.rs::rowid_alias_from_sql required a table-level
PRIMARY KEY (col) to name the table's only column before treating it
as a rowid alias. That is not SQLite's rule: a second column does not
rule it out. The reader now matches the named column against the column
list directly.

Before/after (measured against the pinned oracle)

$ sqlite3 m1.db "CREATE TABLE m1 (a INTEGER, b TEXT, PRIMARY KEY (a));
                 INSERT INTO m1 VALUES (1,'x');"
$ sqlite3 m1.db "SELECT a, b FROM m1"
1|x
$ sqlite-rs query m1.db "SELECT a, b FROM m1"   # before: |x  (a NULL)
                                                  # after:  1|x

Test matrix: table-level PK on a single INTEGER column with/without other
columns, non-INTEGER typed, composite (no alias), column-level control
(regression guard, was already correct).

Test plan

  • tests/corpus/rowid_alias_test.rs — full rule table, oracle-diffed.
  • make test, make lint, make test-corpus, make check-mvl-limit, make check-mod-files, make assurance all pass.

Refs: 001/Req-*, #705
Closes #686

spend: matched estimate

…e table has other columns (#686)

rowid_alias_from_sql's table-level PRIMARY KEY(col) branch only
recognized the rowid-alias form when the PK column was the table's
sole column. Per the oracle, only a composite key (or non-INTEGER
type) rules out the optimization -- other columns don't. Match the
constraint's named column against the column list directly instead of
requiring a single-column table.

Refs: 001/Req-4, #685
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.

fix: table-level PRIMARY KEY(col) rowid alias reads back NULL when the table has other columns

1 participant