Skip to content

Commit 84a66b1

Browse files
committed
Test ifexists and ifnotexists.
Only tested with create and drop, not createindex or dropindex.
1 parent 0a1fc8f commit 84a66b1

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/runtests.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,25 @@ SQLite.@register db big
207207
r = query(db, "SELECT big(5)")
208208
@test r[1][1] == big(5)
209209

210+
211+
db2 = SQLiteDB()
212+
query(db2, "CREATE TABLE tab1 (r REAL, s INT)")
213+
214+
@test_throws ErrorException create(db2, "tab1", [2.1 3; 3.4 8])
215+
# should not throw any exceptions
216+
create(db2, "tab1", [2.1 3; 3.4 8], ifnotexists=true)
217+
create(db2, "tab2", [2.1 3; 3.4 8])
218+
219+
@test_throws ErrorException drop(db2, "nonexistant")
220+
# should not throw anything
221+
drop(db2, "nonexistant", ifexists=true)
222+
# should drop "tab2"
223+
drop(db2, "tab2", ifexists=true)
224+
@test !in("tab2", tables(db2)[1])
225+
226+
close(db2)
227+
228+
210229
@test size(tables(db)) == (11,1)
211230

212231
close(db)

0 commit comments

Comments
 (0)