Skip to content

Support async sql.js initialization for ATTACH SQLITE DATABASE - #2528

Draft
mathiasrw with Copilot wants to merge 3 commits into
developfrom
copilot/fix-sql-database-constructor-error
Draft

Support async sql.js initialization for ATTACH SQLITE DATABASE#2528
mathiasrw with Copilot wants to merge 3 commits into
developfrom
copilot/fix-sql-database-constructor-error

Conversation

Copilot AI commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

ATTACH SQLITE DATABASE assumed SQL.Database was immediately available, which breaks in browser setups using modern sql.js async initialization. This caused ATTACH/USE/SELECT flows to fail with TypeError: SQL.Database is not a constructor.

  • SQLite adapter

    • Resolve sql.js from either:
      • a ready SQL.Database module, or
      • an async initializer exposed as SQL or initSqlJs
    • Cache successful initialization for reuse
    • Validate that the initialized module actually exposes Database
  • Async error handling

    • Reject cleanly when sql.js initialization fails
    • Reject cleanly when the SQLite file cannot be loaded
    • Clear failed initialization state so a later retry can succeed if the environment is corrected
  • Regression coverage

    • Add focused coverage for:
      • async sql.js initialization
      • browser-style initSqlJs
      • invalid sql.js module shape
      • initialization failure and retry
      • file-load failure
await alasql([
  'ATTACH SQLITE DATABASE inscriptions("mydb.sqlite3")',
  'USE inscriptions',
  'SELECT * FROM signatures',
]);

Copilot AI changed the title [WIP] Fix TypeError for SQL.Database not being a constructor Support async sql.js initialization for ATTACH SQLITE DATABASE Aug 20, 2026
Copilot AI requested a review from mathiasrw August 20, 2026 11:50
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.

alasql.js:19270 Uncaught TypeError: SQL.Database is not a constructor

2 participants