Open vendion opened 12 years ago
I'll add a test and the appropriate fix once I've figured it out.
I've added a test which I believe is equivalent to your case, but I can't replicate the problem on my dev system. Can you try the latest commit and report back on the results?
I haven't done more than verify my hunch but I don't think this is a bug...
on line 14 you have:
_, err = db.Execute( "CREATE TABLE foo (id INTEGER PRIMARY KEY ASC, name VARCHAR(10));" )
this attempts to create the table which works fine the first time. It's not supposed to work a second time because the table already exists.
what you probably wanted was:
CREATE TABLE IF NOT EXISTS foo ...
also note, you will still get a panic because you're inserting a row with a fixed id (1) which already exists on the second run
Sorry if the bug report was a bit confusing, I was in a hurry when writing it. The main issue is that the error that the package kicks back SQL error or missing database
isn't all that helpful in knowing what is going on, this may cause an issue with more complex queries where someone may have a Syntax error or some other kind of mistake.
Using the sample code in this Gist https://gist.github.com/1901836 using go version weekly.2012-02-14 +9e53309dfa6d
If the database doesn't exist when
sqlite3.Open()
gets called gosqlite3 creates the database file just fine, but if the same code is reran while the database file still exitserr
returns non nill and the error that is returned is:I'm not sure if this is an error with gosqlite3 or not, but its not an issue with the database going bad as I can open the database with
sqlite3
and the data is intact.