Skip to content

Amend #3071 CREATE LOCALSTORAGE with a missing index record - #3077

Merged
mathiasrw merged 1 commit into
developfrom
fix/3070-amend
Nov 17, 2026
Merged

mathiasrw merged 1 commit into
developfrom
fix/3070-amend

Conversation

@mathiasrw

Copy link
Copy Markdown
Member

Follows up #3071 by @abhi478jeetur-rgb, which fixed #3070.

After #3071, CREATE LOCALSTORAGE DATABASE took any localStorage key with the same name as an existing database. If an app keeps JSON under that key, CREATE LOCALSTORAGE DATABASE IF NOT EXISTS settings adopted it and the next CREATE TABLE settings.t threw a TypeError.

localStorage.setItem('settings', '{"theme":"dark"}');
alasql('CREATE LOCALSTORAGE DATABASE IF NOT EXISTS settings');
alasql('ATTACH LOCALSTORAGE DATABASE settings');
alasql('CREATE TABLE settings.t (a INT)'); // TypeError

Now a record counts as a database only when it has the shape of one, with databaseid and tables, and only when the index record does not list the database. When the index lists it, the code takes the same path as before #3071, without rewriting the index record.

test/test3070.js now also checks that IF NOT EXISTS returns 0 when it repairs the index, and that a key of another app is not taken as a database. The new test fails without the change.

@mathiasrw mathiasrw added this to the v4.x Focus milestone Nov 17, 2026
@mathiasrw
mathiasrw merged commit 8048e09 into develop Nov 17, 2026
10 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.

CREATE LOCALSTORAGE DATABASE overwrites an existing database when the index record is missing

1 participant