: <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
: ignore-database-exists ( quot -- )
[ sql-database-exists? ] ignore-error ; inline
+
+: ignore-index-exists ( quot -- )
+ [ sql-index-exists? ] ignore-error ; inline
{ [ 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
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