-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exec method does not support queries that return results #28
Comments
Have you consider using Query? |
Not looking for a workaround; I reported the issue so that the driver behaves as expected. |
The driver behavies as expected. |
The libSQL driver returns an error. It's described in the issue. The error is not expected in this situation, and other Go SQLite drivers handle the described situation just fine. |
Ok. I'm still not sure what is a desired behaviour here but reopening the issue for now. |
I'd say the expected behavior is to return a non-nil package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/mattn/go-sqlite3"
)
func main() {
db, err := sql.Open("sqlite3", "file:data.db")
if err != nil {
log.Fatal(err)
}
defer db.Close()
res, err := db.Exec(`pragma mmap_size=1024`)
fmt.Println("res", res)
fmt.Println("err", err)
}
|
This is more complicated in case of turso which can have not only local backend but also a remote one. Ideally what you're suggesting would be best but I have to think about all available backends before being sure. |
I see, thank you for clarifying that! |
This is still an issue. |
Ok This is a little bit off So but you can ignore the error and than query the pragma and it is set Here is my code
|
Some sqlite pragmas return a value. For example,
mmap_size
(running in sqlite shell):The libsql driver's
Exec
method fails with an "Execute returned rows" for such pragmas. In fact, it fails for any query that returns a value (such asselect 42
).I would argue that this is not an expected behavior. It's perfectly normal for an
Exec
query to return a value. Other drivers (such asmattn/go-sqlite3
andmodernc.org/sqlite
) allow this.Code to reproduce:
Result:
The text was updated successfully, but these errors were encountered: