db.sqlite: make sure select-tuple throws sql-table-missing etc.
parent
d66ea1e09c
commit
f8de0c1caa
|
@ -1,20 +1,20 @@
|
|||
! Copyright (C) 2008 Chris Double, Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: accessors alien.c-types alien.data arrays calendar.format
|
||||
calendar.parser combinators db db.errors db.sqlite.ffi db.types
|
||||
io.backend io.encodings.string io.encodings.utf8 kernel math
|
||||
namespaces present sequences serialize urls ;
|
||||
calendar.parser combinators db db.errors db.sqlite.errors
|
||||
db.sqlite.ffi db.types io.backend io.encodings.string
|
||||
io.encodings.utf8 kernel math namespaces present sequences
|
||||
serialize urls ;
|
||||
IN: db.sqlite.lib
|
||||
|
||||
ERROR: sqlite-error < db-error n string ;
|
||||
ERROR: sqlite-sql-error < sql-error n string ;
|
||||
|
||||
: sqlite-other-error ( n -- * )
|
||||
dup sqlite-error-messages nth sqlite-error ;
|
||||
|
||||
: sqlite-statement-error ( -- * )
|
||||
SQLITE_ERROR
|
||||
db-connection get handle>> sqlite3_errmsg sqlite-sql-error ;
|
||||
db-connection get handle>> sqlite3_errmsg
|
||||
parse-sqlite-sql-error throw ;
|
||||
|
||||
: sqlite-check-result ( n -- )
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
USING: accessors arrays db db.sqlite db.tuples db.types io.directories
|
||||
io.files.temp kernel layouts literals math.parser namespaces sequences
|
||||
sorting splitting tools.test ;
|
||||
USING: accessors arrays db db.errors db.sqlite db.tuples
|
||||
db.types io.directories io.files.temp kernel layouts literals
|
||||
math.parser namespaces sequences sorting splitting tools.test ;
|
||||
|
||||
IN: db.sqlite.tests
|
||||
|
||||
: normalize ( str -- str' )
|
||||
|
@ -247,3 +248,9 @@ watch "WATCH" {
|
|||
num-test3 new select-tuple
|
||||
] with-db num>>
|
||||
] unit-test
|
||||
|
||||
[
|
||||
TUPLE: no-table name ;
|
||||
no-table "NO_TABLE" { { "name" "NAME" VARCHAR } } define-persistent
|
||||
test.db [ no-table new select-tuple ] with-db
|
||||
] [ sql-table-missing? ] must-fail-with
|
||||
|
|
|
@ -331,7 +331,9 @@ M: sqlite-db-connection compound ( string seq -- new-string )
|
|||
} case ;
|
||||
|
||||
M: sqlite-db-connection parse-db-error
|
||||
dup n>> {
|
||||
{ 1 [ string>> parse-sqlite-sql-error ] }
|
||||
[ drop ]
|
||||
} case ;
|
||||
dup sqlite-error? [
|
||||
dup n>> {
|
||||
{ 1 [ string>> parse-sqlite-sql-error ] }
|
||||
[ drop ]
|
||||
} case
|
||||
] when ;
|
||||
|
|
Loading…
Reference in New Issue