Comments (4)
From a cursory glance, I think the issue is this limitation of sqlite-wasm: "[Bindings] are only applied to the first non-empty statement in the SQL which has any bindable parameters. (Empty statements are skipped entirely.)". Since your third statement is the second statement with bindings, sqlite-wasm errors on that third statement ("index 3").
Does it work if you remove the bindings from the other 2 statements?
from sqlocal.
Yes, I tried in multiple orders. It seems to only allow bindings in one statement.
from sqlocal.
Ok, that tracks. I'm not sure why sqlite-wasm has that limitation, but it means you should separate each statement. Your example is a perfect use-case for SQLocal's transaction method.
from sqlocal.
I've added a paragraph noting this to the docs page for sql
:
Multiple statements can be passed in the query, but note that the results returned will only include results from the first value-returning statement. Also, only one statement in the query can have parameter bindings. Because of these restrictions, it is recommended to pass only one SQL statement per call to sql
.
// Warning: only returns the row with id 1.
const result = await sql`
SELECT * FROM foo WHERE id = 1;
SELECT * FROM foo WHERE id = 2;
`;
// Recommended: one statement per query
const result1 = await sql`SELECT * FROM foo WHERE id = 1;`;
const result2 = await sql`SELECT * FROM foo WHERE id = 2;`;
from sqlocal.
Related Issues (20)
- sqlocal easy connect/disconnect HOT 4
- Node support HOT 6
- Unable to parameterize table/column name in query HOT 1
- Feature: Transaction HOT 3
- Replace Sqlite3 with Libsql HOT 1
- sqlite3 result code 10: disk I/O error HOT 8
- Feature request: ability to control instantiation of sqlite db HOT 3
- Error during SvelteKit Server-side Rendering HOT 1
- Error opening WAL db with overwriteDatabaseFile HOT 5
- Using nested literals to construct queries passed to SQLocal.sql HOT 1
- Database maximum size HOT 3
- IndexedDB as a persistence option? HOT 2
- Sqlocal with pglite HOT 1
- ERR_MODULE_NOT_FOUND when compiling for Node.js HOT 4
- How do you debug or visualize the database? HOT 2
- Concurrent reads and writes HOT 6
- How to handle adding new tables to the database when using drizzle?
- no such function: REGEXP HOT 4
- File System API support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sqlocal.