File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -20,9 +20,11 @@ const StmtWrapper = Ref{StmtHandle}
2020
2121# Normal constructor from filename
2222function sqliteexception (handle:: DBHandle )
23+ isopen (handle) || throw (SQLiteException (" DB is closed" ))
2324 SQLiteException (unsafe_string (C. sqlite3_errmsg (handle)))
2425end
2526function sqliteexception (handle:: DBHandle , stmt:: StmtHandle )
27+ isopen (handle) || throw (SQLiteException (" DB is closed" ))
2628 errstr = unsafe_string (C. sqlite3_errmsg (handle))
2729 stmt_text_handle = C. sqlite3_expanded_sql (stmt)
2830 stmt_text = unsafe_string (stmt_text_handle)
@@ -77,7 +79,8 @@ DBInterface.connect(::Type{DB}) = DB()
7779DBInterface. connect (:: Type{DB} , f:: AbstractString ) = DB (f)
7880DBInterface. close! (db:: DB ) = _close_db! (db)
7981Base. close (db:: DB ) = _close_db! (db)
80- Base. isopen (db:: DB ) = db. handle != C_NULL
82+ Base. isopen (db:: DB ) = isopen (db. handle)
83+ Base. isopen (handle:: DBHandle ) = handle != C_NULL
8184
8285function finalize_statements! (db:: DB )
8386 # close stmts
Original file line number Diff line number Diff line change @@ -1019,4 +1019,11 @@ end
10191019 tbl_b = DBInterface. execute (db_b, " select myfunc(1) as x" ) |> columntable
10201020 @test tbl_a. x == [2 ]
10211021 @test tbl_b. x == [10 ]
1022+
1023+ # Throw an error when interfacing with a closed database
1024+ close (db_b)
1025+ @test_throws SQLiteException (" DB is closed" ) DBInterface. execute (
1026+ db_b,
1027+ " select myfunc(1) as x" ,
1028+ )
10221029end
You can’t perform that action at this time.
0 commit comments