tursodatabase / go-libsql

libSQL API for Go
MIT License
77 stars 11 forks source link

Exec method doesn't support multiple statements (separated by semi-colon) #22

Open JayJamieson opened 5 months ago

JayJamieson commented 5 months ago

Exec method appears to not support multi line statement queries, it executes up until first ; then completes.

Minimal code required to reproduce.

db, err := sql.Open("libsql", url)
if err != nil {
  return nil, err
}
defer db.Close()

db.Exec(`create table foo (id integer primary key);
create table bar (id integer primary key);`)

My expectation would be the same behavior as other sqlite3 drivers mattn sqlite3 and modernc where multi statement queries are executed fully when using Exec.

My current work around is at the template level to inject a separator symbol that I can split on and run Exec in a loop. This however isn't great for larger SQL scripts.

imajacket commented 2 months ago

For me, multiple statements work for embedded replicas & syncing up to Turso, but do not work for a regular file:.db