Comments (3)
This looks like a difference between PostgreSQL and SQLite. According the official SQLite docs:
A dollar-sign followed by an identifier name also holds a spot for a named parameter (emphasis mine) with the name $AAAA.
So I would expect that this would work (untested):
const sqlStatement = `SELECT EXISTS( SELECT 1 FROM x WHERE z = $2 AND y = $1);`
err := sqlitex.Execute(conn, sqlStatement, &sqlitex.ExecOptions{
ResultFunc: func(stmt *sqlite.Stmt) error { /* ... */ },
Named: map[string]any{
"$1": 8,
"$2": 4,
},
})
If you come from a other sqlite Go library that respect this "postgres style", this can create issues that are hard to trace back.
Can you help point me to which Go SQLite library you are referring to? If emulating the positional parameter style is behavior another library has, it would help me weigh whether we should shim this in.
from go-sqlite.
Might have been Matts go-Sqlite3 version. Been ages when we rewrote the codebase to sqlite and our zombiezen/go-sqlite update is 5+ months old.
Maybe it never supported it and we never ran into this issue as our order just matched all the time. It was only recently that data issues in our database (see ref on first post) triggered several day investigation, and this "behavior" issue come to light.
The solution was simply to replace all instances of $1 with ?1...
Our issue is simply how easy it is to creates a silent bug if your using $1 and expect ?1 behavior. Maybe a warning is better to be put in place then changing the default behavior of go-sqlite?
from go-sqlite.
I'm closing this as "won't fix", since the general position of this library is to be largely the same as SQLite. I understand this design decision has caused some frustration on your end, but I can't see a way to improve this situation. Thanks for the feedback, and I'll keep it in mind if I see the same sorts of issues arise in the future.
from go-sqlite.
Related Issues (20)
- how to use SetCollation HOT 1
- ability to customize connection creatd by sqlitex.Pool HOT 1
- Support the VFS API HOT 1
- error creating a transaction: sqlitex.Exec: sqlite: clear bindings: interrupted
- Pool.Close blocks indefinitely when a panic happens during iteration of statement rows
- Add a Pool interface? HOT 2
- BlockOnBusy backoff period is long HOT 5
- Undefined symbols in sqlite v.1.29.0 HOT 2
- Support pointer-passing
- JSONB support
- sqlitex.Pool.Get should be able to return an error HOT 3
- Extented error codes aren't reported properly HOT 1
- Document pattern of checking for zero rows HOT 6
- file:memory does not appear to work HOT 4
- INSERT multiple VALUES? HOT 2
- Stmt.findBindName shoud be public HOT 3
- Unexpected error: "migrate database: sqlite: step: database is locked"
- [UNHELPFUL ERROR MSG] obscure panic on closed connection HOT 1
- Possible to bind arrays, for use in e.g. `IN (?)` queries? HOT 1
- should sqlitex.Save() check *perr for a nil pointer inside the error, not just *perr == nil ?
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 go-sqlite.