Skip to content

Fix AUTOINCREMENT not populating identity columns in IndexedDB tables - #2526

Merged
mathiasrw merged 4 commits into
developfrom
copilot/fix-autoincrement-indexeddb
Aug 25, 2026
Merged

mathiasrw merged 4 commits into
developfrom
copilot/fix-autoincrement-indexeddb

Conversation

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

AUTOINCREMENT (mapped to IDENTITY) columns were silently dropped when inserting into IndexedDB-backed tables — the column was absent entirely from query results rather than receiving an auto-incremented value.

Root cause

IDB.intoTable passed records directly to IndexedDB without applying the table's identities counter, bypassing the logic that both the in-memory table.insert path and LS.intoTable (LocalStorage) already handle.

Changes

  • src/91indexeddb.jsIDB.intoTable: Before writing records to the object store, iterate table.identities and assign the current counter value to any record missing that column, then advance the counter (or sync it forward if the user supplied an explicit value ≥ the current counter).
// Before: records inserted as-is, identity column absent
tb.add(value[i]);

// After: identity values applied, counter advanced per record
if (!userProvided) value[i][columnid] = ident.value;
if (userProvided && +value[i][columnid] >= ident.value) {
    ident.value = +value[i][columnid] + ident.step;
} else {
    ident.value += ident.step;
}
  • test/test861.js: Browser-only tests verifying AUTOINCREMENT values are populated on insert and continue incrementing across multiple INSERT statements.

Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix autoincrement not working for IndexedDB Fix AUTOINCREMENT not populating identity columns in IndexedDB tables Aug 20, 2026
Copilot AI requested a review from mathiasrw August 20, 2026 11:39

@mathiasrw mathiasrw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread test/test861.js Outdated
Comment thread test/test861.js Outdated
Comment thread src/91indexeddb.js
Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
Copilot AI requested a review from mathiasrw August 25, 2026 08:56
@mathiasrw

Copy link
Copy Markdown
Member

@copilot
Run yarn test-format-all
yarn run v1.22.22
$ prettier --list-different '{.,src,test}/*.{js,ts,json}' || (echo 'Please correct file formatting using yarn format-all and try again.' && exit 1)
test/test861.js
Please correct file formatting using yarn format-all and try again.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Process completed with exit code 1.

Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>

Copilot AI commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

@copilot
Run yarn test-format-all
yarn run v1.22.22
...

Ran prettier --write test/test861.js — formatting is now correct and yarn test-format-all should pass.

@mathiasrw
mathiasrw marked this pull request as ready for review August 25, 2026 10:37
@mathiasrw
mathiasrw merged commit bffd89e into develop Aug 25, 2026
11 checks passed
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.

AUTOINCREMENT for INDEXEDDB does not seem to work

2 participants