db.(sqlite.)errors: add sql-index-exists error
parent
ca19a01c1b
commit
9c9764cc2d
|
@ -43,6 +43,11 @@ TUPLE: sql-database-exists < sql-error message ;
|
|||
: <sql-database-exists> ( message -- error )
|
||||
f swap sql-database-exists boa ;
|
||||
|
||||
TUPLE: sql-index-exists < sql-error name ;
|
||||
|
||||
: <sql-index-exists> ( name -- error )
|
||||
f swap sql-index-exists boa ;
|
||||
|
||||
: ignore-error ( quot word -- )
|
||||
'[ dup @ [ drop ] [ rethrow ] if ] recover ; inline
|
||||
|
||||
|
@ -60,3 +65,6 @@ TUPLE: sql-database-exists < sql-error message ;
|
|||
|
||||
: ignore-database-exists ( quot -- )
|
||||
[ sql-database-exists? ] ignore-error ; inline
|
||||
|
||||
: ignore-index-exists ( quot -- )
|
||||
[ sql-index-exists? ] ignore-error ; inline
|
||||
|
|
|
@ -21,5 +21,13 @@ db.sqlite kernel locals tools.test ;
|
|||
{ [ sql-table-exists? ] [ table>> "foo" = ] } 1&&
|
||||
] must-fail-with
|
||||
|
||||
"create index main_index on foo(id);" sql-command
|
||||
|
||||
[
|
||||
"create index main_index on foo(id);" sql-command
|
||||
] [
|
||||
{ [ sql-index-exists? ] [ name>> "main_index" = ] } 1&&
|
||||
] must-fail-with
|
||||
|
||||
] with-db
|
||||
] with-test-file
|
||||
|
|
|
@ -14,6 +14,8 @@ AlreadyExists = " already exists"
|
|||
SqliteError =
|
||||
"table " (!(AlreadyExists).)+:table AlreadyExists
|
||||
=> [[ table >string <sql-table-exists> ]]
|
||||
| "index " (!(AlreadyExists).)+:name AlreadyExists
|
||||
=> [[ name >string <sql-index-exists> ]]
|
||||
| "no such table: " .+:table
|
||||
=> [[ table >string <sql-table-missing> ]]
|
||||
| .*:error
|
||||
|
|
Loading…
Reference in New Issue