Skip to content
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

DROP TABLE IF EXISTS issue. Exception: no such table: tablename (SQLite3::Exception) #88

Open
vectorselector opened this issue Apr 5, 2023 · 0 comments

Comments

@vectorselector
Copy link

vectorselector commented Apr 5, 2023

DB.open "sqlite3:./mydb.sqlite3" do |db|
db.exec "DROP TABLE IF EXISTS tablename"
end

triggers "Exception: no such table: tablename (SQLite3::Exception)"

when:

sqlite3 mydb.sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
sqlite> .tables
tablename

  1. table exists
  2. sqlite3 implements "DROP TABLE IF EXISTS tablename" which should NOT trigger any exception.
  3. crystal-sqlite3 test spec https://github.com/crystal-lang/crystal-sqlite3/blob/master/spec/db_spec.cr
    specifically invokes (lines 81-83)

drop_table_if_exists_syntax do |table_name|
"drop table if exists #{table_name}"
end

  1. I cleaned cache ~/.cache/crystal/

crystal version 1.7.3

What am I doing wrong?

@vectorselector vectorselector changed the title DROP TABLE IF EXISTS not working. Exception: no such table: tablename (SQLite3::Exception) DROP TABLE IF EXISTS issue. Exception: no such table: tablename (SQLite3::Exception) Apr 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant