stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.94k stars 174 forks source link

returning doesn't seem to work with the sqlite3 implementation #1533

Open noam-honig opened 1 month ago

noam-honig commented 1 month ago

Describe the bug

returning doesn't seem to work with the sqlite3 implementation

Link to the blitz that caused the error

https://stackblitz.com/edit/sqlite3-persist-not-9hojbj?file=test.js

Steps to reproduce

Run

import sqlite3 from 'sqlite3';
const db = new sqlite3.Database(':memory:');

// based on https://www.sqlite.org/lang_returning.html

db.all(
  `CREATE TABLE t0(
  a INTEGER PRIMARY KEY,
  b DATE DEFAULT CURRENT_TIMESTAMP,
  c INTEGER
)`,
  (err, res) => {
    db.all(
      `INSERT INTO t0(c) VALUES(random()) RETURNING *;
  `,
      (err, res) => {
        console.log({ err, res });
      }
    );
  }
);

see the error:


{
  err: Error: SQLITE_ERROR: near "RETURNING": syntax error
      at sqliteError (/home/projects/sqlite3-persist-not-9hojbj/node_modules/sqlite3/lib/sqlite3.pure.js:1:94706)
      at 51656 (/home/projects/sqlite3-persist-not-9hojbj/node_modules/sqlite3/lib/sqlite3.pure.js:1:12557)
      at _emscripten_asm_const_int (/home/projects/sqlite3-persist-not-9hojbj/node_modules/sqlite3/lib/sqlite3.pure.js:1:84040)
      at ccall (/home/projects/sqlite3-persist-not-9hojbj/node_modules/sqlite3/lib/sqlite3.pure.js:1:5494)
      at Object.eval (/home/projects/sqlite3-persist-not-9hojbj/node_modules/sqlite3/lib/sqlite3.pure.js:1:5844)
      at eval (/home/projects/sqlite3-persist-not-9hojbj/node_modules/sqlite3/lib/pure/statement.js:31:35)
      at processTicksAndRejections (node:internal/process/task_queues:192:998)
      at _0x41ac03 (https://sqlite3persistnot9hojbj-5fwv.w-credentialless-staticblitz.com/blitz.134daa3c.js:40:506247) {
    errno: 1,
    code: 'SQLITE_ERROR'
  },
  res: undefined
}

Expected behavior

Expected the returning to work as it does with other sqlite implementation https://www.sqlite.org/lang_returning.html

Parity with Local

Screenshots

No response

Platform

Additional context

No response