]> gitweb.factorcode.org Git - factor.git/commitdiff
db.errors: move to db.{postgresql,sqlite}.errors.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Mar 2016 19:44:23 +0000 (12:44 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 22 Mar 2016 19:44:50 +0000 (12:44 -0700)
15 files changed:
basis/db/errors/errors.factor
basis/db/errors/postgresql/authors.txt [deleted file]
basis/db/errors/postgresql/postgresql-tests.factor [deleted file]
basis/db/errors/postgresql/postgresql.factor [deleted file]
basis/db/errors/sqlite/authors.txt [deleted file]
basis/db/errors/sqlite/sqlite-tests.factor [deleted file]
basis/db/errors/sqlite/sqlite.factor [deleted file]
basis/db/postgresql/errors/authors.txt [new file with mode: 0644]
basis/db/postgresql/errors/errors-tests.factor [new file with mode: 0644]
basis/db/postgresql/errors/errors.factor [new file with mode: 0644]
basis/db/postgresql/postgresql.factor
basis/db/sqlite/errors/authors.txt [new file with mode: 0644]
basis/db/sqlite/errors/errors-tests.factor [new file with mode: 0644]
basis/db/sqlite/errors/errors.factor [new file with mode: 0644]
basis/db/sqlite/sqlite.factor

index 88dc755b0adfb7de643d6ba740e5537b006dfbe3..f33b4c5b24001d3f8e2ba5ae77f347ff2c45714e 100644 (file)
@@ -9,54 +9,54 @@ TUPLE: sql-error location ;
 ERROR: bad-schema ;
 
 TUPLE: sql-unknown-error < sql-error message ;
+
 : <sql-unknown-error> ( message -- error )
-    \ sql-unknown-error new
-        swap >>message ;
+    f swap sql-unknown-error boa ;
 
 TUPLE: sql-table-exists < sql-error table ;
+
 : <sql-table-exists> ( table -- error )
-    \ sql-table-exists new
-        swap >>table ;
+    f swap sql-table-exists boa ;
 
 TUPLE: sql-table-missing < sql-error table ;
+
 : <sql-table-missing> ( table -- error )
-    \ sql-table-missing new
-        swap >>table ;
+    f swap sql-table-missing boa ;
 
 TUPLE: sql-syntax-error < sql-error message ;
+
 : <sql-syntax-error> ( message -- error )
-    \ sql-syntax-error new
-        swap >>message ;
+    f swap sql-syntax-error boa ;
 
 TUPLE: sql-function-exists < sql-error message ;
+
 : <sql-function-exists> ( message -- error )
-    \ sql-function-exists new
-        swap >>message ;
+    f swap sql-function-exists boa ;
 
 TUPLE: sql-function-missing < sql-error message ;
+
 : <sql-function-missing> ( message -- error )
-    \ sql-function-missing new
-        swap >>message ;
+    f swap sql-function-missing boa ;
 
 TUPLE: sql-database-exists < sql-error message ;
+
 : <sql-database-exists> ( message -- error )
-    \ sql-database-exists new
-        swap >>message ;
+    f swap sql-database-exists boa ;
 
 : ignore-error ( quot word -- )
-    '[ dup _ execute [ drop ] [ rethrow ] if ] recover ; inline
+    '[ dup @ [ drop ] [ rethrow ] if ] recover ; inline
 
 : ignore-table-exists ( quot -- )
-    \ sql-table-exists? ignore-error ; inline
+    [ sql-table-exists? ] ignore-error ; inline
 
 : ignore-table-missing ( quot -- )
-    \ sql-table-missing? ignore-error ; inline
+    [ sql-table-missing? ] ignore-error ; inline
 
 : ignore-function-exists ( quot -- )
-    \ sql-function-exists? ignore-error ; inline
+    [ sql-function-exists? ] ignore-error ; inline
 
 : ignore-function-missing ( quot -- )
-    \ sql-function-missing? ignore-error ; inline
+    [ sql-function-missing? ] ignore-error ; inline
 
 : ignore-database-exists ( quot -- )
-    \ sql-database-exists? ignore-error ; inline
+    [ sql-database-exists? ] ignore-error ; inline
diff --git a/basis/db/errors/postgresql/authors.txt b/basis/db/errors/postgresql/authors.txt
deleted file mode 100644 (file)
index b4bd0e7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/db/errors/postgresql/postgresql-tests.factor b/basis/db/errors/postgresql/postgresql-tests.factor
deleted file mode 100644 (file)
index e9be320..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-! Copyright (C) 2009 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators.short-circuit db db.errors
-db.errors.postgresql db.postgresql io.files.unique kernel namespaces
-tools.test db.tester continuations ;
-IN: db.errors.postgresql.tests
-
-[
-
-    [ "drop table foo;" sql-command ] ignore-errors
-    [ "drop table ship;" sql-command ] ignore-errors
-
-    [
-        "insert into foo (id) values('1');" sql-command
-    ] [
-        { [ sql-table-missing? ] [ table>> "foo" = ] } 1&&
-    ] must-fail-with
-
-    [
-        "create table ship(id integer);" sql-command
-        "create table ship(id integer);" sql-command
-    ] [
-        { [ sql-table-exists? ] [ table>> "ship" = ] } 1&&
-    ] must-fail-with
-
-    [
-        "create table foo(id) lol;" sql-command
-    ] [
-        sql-syntax-error?
-    ] must-fail-with
-
-] test-postgresql
diff --git a/basis/db/errors/postgresql/postgresql.factor b/basis/db/errors/postgresql/postgresql.factor
deleted file mode 100644 (file)
index 1a866f5..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-! Copyright (C) 2009 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: kernel db.errors peg.ebnf strings sequences math
-combinators.short-circuit accessors math.parser quoting
-locals ;
-IN: db.errors.postgresql
-
-EBNF: parse-postgresql-sql-error
-
-Error = "ERROR:" [ ]+
-
-TableError =
-    Error ("relation "|"table ")(!(" already exists").)+:table " already exists"
-        => [[ table >string unquote <sql-table-exists> ]]
-    | Error ("relation "|"table ")(!(" does not exist").)+:table " does not exist"
-        => [[ table >string unquote <sql-table-missing> ]]
-
-DatabaseError =
-    Error ("database")(!(" already exists").)+:database " already exists"
-        => [[ database >string <sql-database-exists> ]]
-
-FunctionError =
-    Error "function" (!(" already exists").)+:table " already exists"
-        => [[ table >string <sql-function-exists> ]]
-    | Error "function" (!(" does not exist").)+:table " does not exist"
-        => [[ table >string <sql-function-missing> ]]
-
-SyntaxError =
-    Error "syntax error at end of input":error
-        => [[ error >string <sql-syntax-error> ]]
-    | Error "syntax error at or near " .+:syntaxerror
-        => [[ syntaxerror >string unquote <sql-syntax-error> ]]
-
-UnknownError = .* => [[ >string <sql-unknown-error> ]]
-
-PostgresqlSqlError = (TableError | DatabaseError | FunctionError | SyntaxError | UnknownError) 
-
-;EBNF
-
-
-TUPLE: parse-postgresql-location column line text ;
-C: <parse-postgresql-location> parse-postgresql-location
-
-EBNF: parse-postgresql-line-error
-
-Line = "LINE " [0-9]+:line ": " .+:sql
-    => [[ f line >string string>number sql >string <parse-postgresql-location> ]] 
-
-;EBNF
-
-:: set-caret-position ( error caret-line -- error )
-    caret-line length
-    error line>> number>string length "LINE : " length +
-    - [ error ] dip >>column ;
-
-: postgresql-location ( line column -- obj )
-    [ parse-postgresql-line-error ] dip
-    set-caret-position ;
diff --git a/basis/db/errors/sqlite/authors.txt b/basis/db/errors/sqlite/authors.txt
deleted file mode 100644 (file)
index b4bd0e7..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Doug Coleman
\ No newline at end of file
diff --git a/basis/db/errors/sqlite/sqlite-tests.factor b/basis/db/errors/sqlite/sqlite-tests.factor
deleted file mode 100644 (file)
index 31eabae..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-! Copyright (C) 2009 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators.short-circuit db db.errors
-db.errors.sqlite db.sqlite io.files.temp io.files.unique kernel
-namespaces tools.test ;
-IN: db.errors.sqlite.tests
-
-[
-    "sqlite" "error-test" [
-
-        <sqlite-db> [
-
-            [
-                "insert into foo (id) values('1');" sql-command
-            ] [
-                { [ sql-table-missing? ] [ table>> "foo" = ] } 1&&
-            ] must-fail-with
-
-            "create table foo(id);" sql-command
-
-            [
-                "create table foo(id);" sql-command
-            ] [
-                { [ sql-table-exists? ] [ table>> "foo" = ] } 1&&
-            ] must-fail-with
-
-        ] with-db
-    ] cleanup-unique-file
-] with-temp-directory
diff --git a/basis/db/errors/sqlite/sqlite.factor b/basis/db/errors/sqlite/sqlite.factor
deleted file mode 100644 (file)
index c73409b..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-! Copyright (C) 2009 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: accessors combinators db kernel sequences peg.ebnf
-strings db.errors ;
-IN: db.errors.sqlite
-
-TUPLE: unparsed-sqlite-error error ;
-C: <unparsed-sqlite-error> unparsed-sqlite-error
-
-SINGLETONS: table-exists table-missing ;
-
-: sqlite-table-error ( table message -- error )
-    {
-        { table-exists [ <sql-table-exists> ] }
-    } case ;
-
-EBNF: parse-sqlite-sql-error
-
-TableMessage = " already exists" => [[ table-exists ]]
-
-SqliteError =
-    "table " (!(TableMessage).)+:table TableMessage:message
-      => [[ table >string message sqlite-table-error ]]
-    | "no such table: " .+:table
-      => [[ table >string <sql-table-missing> ]]
-    | .*:error
-      => [[ error >string <unparsed-sqlite-error> ]]
-;EBNF
diff --git a/basis/db/postgresql/errors/authors.txt b/basis/db/postgresql/errors/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/db/postgresql/errors/errors-tests.factor b/basis/db/postgresql/errors/errors-tests.factor
new file mode 100644 (file)
index 0000000..bb7f3d8
--- /dev/null
@@ -0,0 +1,31 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators.short-circuit db db.errors
+db.postgresql db.postgresql.errors io.files.unique kernel
+namespaces tools.test db.tester continuations ;
+
+[
+
+    [ "drop table foo;" sql-command ] ignore-errors
+    [ "drop table ship;" sql-command ] ignore-errors
+
+    [
+        "insert into foo (id) values('1');" sql-command
+    ] [
+        { [ sql-table-missing? ] [ table>> "foo" = ] } 1&&
+    ] must-fail-with
+
+    [
+        "create table ship(id integer);" sql-command
+        "create table ship(id integer);" sql-command
+    ] [
+        { [ sql-table-exists? ] [ table>> "ship" = ] } 1&&
+    ] must-fail-with
+
+    [
+        "create table foo(id) lol;" sql-command
+    ] [
+        sql-syntax-error?
+    ] must-fail-with
+
+] test-postgresql
diff --git a/basis/db/postgresql/errors/errors.factor b/basis/db/postgresql/errors/errors.factor
new file mode 100644 (file)
index 0000000..4633ae2
--- /dev/null
@@ -0,0 +1,58 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: kernel db.errors peg.ebnf strings sequences math
+combinators.short-circuit accessors math.parser quoting
+locals ;
+IN: db.postgresql.errors
+
+EBNF: parse-postgresql-sql-error
+
+Error = "ERROR:" [ ]+
+
+TableError =
+    Error ("relation "|"table ")(!(" already exists").)+:table " already exists"
+        => [[ table >string unquote <sql-table-exists> ]]
+    | Error ("relation "|"table ")(!(" does not exist").)+:table " does not exist"
+        => [[ table >string unquote <sql-table-missing> ]]
+
+DatabaseError =
+    Error ("database")(!(" already exists").)+:database " already exists"
+        => [[ database >string <sql-database-exists> ]]
+
+FunctionError =
+    Error "function" (!(" already exists").)+:table " already exists"
+        => [[ table >string <sql-function-exists> ]]
+    | Error "function" (!(" does not exist").)+:table " does not exist"
+        => [[ table >string <sql-function-missing> ]]
+
+SyntaxError =
+    Error "syntax error at end of input":error
+        => [[ error >string <sql-syntax-error> ]]
+    | Error "syntax error at or near " .+:syntaxerror
+        => [[ syntaxerror >string unquote <sql-syntax-error> ]]
+
+UnknownError = .* => [[ >string <sql-unknown-error> ]]
+
+PostgresqlSqlError = (TableError | DatabaseError | FunctionError | SyntaxError | UnknownError) 
+
+;EBNF
+
+
+TUPLE: parse-postgresql-location column line text ;
+C: <parse-postgresql-location> parse-postgresql-location
+
+EBNF: parse-postgresql-line-error
+
+Line = "LINE " [0-9]+:line ": " .+:sql
+    => [[ f line >string string>number sql >string <parse-postgresql-location> ]] 
+
+;EBNF
+
+:: set-caret-position ( error caret-line -- error )
+    caret-line length
+    error line>> number>string length "LINE : " length +
+    - [ error ] dip >>column ;
+
+: postgresql-location ( line column -- obj )
+    [ parse-postgresql-line-error ] dip
+    set-caret-position ;
index 12acded9c068aabd250152d09c810a10a44bec3b..12bbd56dcfbcb0d303baf81664a2d1f6e01f2325 100644 (file)
@@ -1,12 +1,10 @@
 ! Copyright (C) 2007, 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays assocs alien alien.syntax continuations io
-kernel math math.parser namespaces make prettyprint quotations
-sequences debugger db db.postgresql.lib db.postgresql.ffi
-db.tuples db.types tools.annotations math.ranges
-combinators classes classes.tuple locals words tools.walker
-db.private nmake accessors random db.queries destructors
-db.tuples.private db.postgresql db.errors.postgresql splitting ;
+USING: accessors classes.tuple combinators db
+db.postgresql.errors db.postgresql.ffi db.postgresql.lib
+db.private db.queries db.tuples db.tuples.private db.types
+destructors kernel make math math.parser namespaces nmake random
+sequences splitting ;
 IN: db.postgresql
 
 TUPLE: postgresql-db host port pgopts pgtty database username password ;
diff --git a/basis/db/sqlite/errors/authors.txt b/basis/db/sqlite/errors/authors.txt
new file mode 100644 (file)
index 0000000..b4bd0e7
--- /dev/null
@@ -0,0 +1 @@
+Doug Coleman
\ No newline at end of file
diff --git a/basis/db/sqlite/errors/errors-tests.factor b/basis/db/sqlite/errors/errors-tests.factor
new file mode 100644 (file)
index 0000000..aa16277
--- /dev/null
@@ -0,0 +1,28 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators.short-circuit db db.errors
+db.sqlite db.sqlite.errors io.files.temp io.files.unique kernel
+namespaces tools.test ;
+
+[
+    "sqlite" "error-test" [
+
+        <sqlite-db> [
+
+            [
+                "insert into foo (id) values('1');" sql-command
+            ] [
+                { [ sql-table-missing? ] [ table>> "foo" = ] } 1&&
+            ] must-fail-with
+
+            "create table foo(id);" sql-command
+
+            [
+                "create table foo(id);" sql-command
+            ] [
+                { [ sql-table-exists? ] [ table>> "foo" = ] } 1&&
+            ] must-fail-with
+
+        ] with-db
+    ] cleanup-unique-file
+] with-temp-directory
diff --git a/basis/db/sqlite/errors/errors.factor b/basis/db/sqlite/errors/errors.factor
new file mode 100644 (file)
index 0000000..1e5da3c
--- /dev/null
@@ -0,0 +1,28 @@
+! Copyright (C) 2009 Doug Coleman.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors combinators db kernel sequences peg.ebnf
+strings db.errors ;
+IN: db.sqlite.errors
+
+TUPLE: unparsed-sqlite-error error ;
+C: <unparsed-sqlite-error> unparsed-sqlite-error
+
+SINGLETONS: table-exists table-missing ;
+
+: sqlite-table-error ( table message -- error )
+    {
+        { table-exists [ <sql-table-exists> ] }
+    } case ;
+
+EBNF: parse-sqlite-sql-error
+
+TableMessage = " already exists" => [[ table-exists ]]
+
+SqliteError =
+    "table " (!(TableMessage).)+:table TableMessage:message
+      => [[ table >string message sqlite-table-error ]]
+    | "no such table: " .+:table
+      => [[ table >string <sql-table-missing> ]]
+    | .*:error
+      => [[ error >string <unparsed-sqlite-error> ]]
+;EBNF
index 9005b48f17f5ee7024b2f53aac6501f9f46e64e7..4542d800ee3b11040feb9c33a6b5ad4133dbd1f7 100644 (file)
@@ -1,13 +1,10 @@
 ! Copyright (C) 2005, 2008 Chris Double, Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien arrays assocs classes compiler db hashtables
-io.files kernel math math.parser namespaces prettyprint fry
-sequences strings classes.tuple alien.c-types continuations
-db.sqlite.lib db.sqlite.ffi db.tuples words db.types combinators
-math.intervals io locals nmake accessors vectors math.ranges random
-math.bitwise db.queries destructors db.tuples.private interpolate
-io.streams.string make db.private sequences.deep
-db.errors.sqlite ;
+USING: accessors classes.tuple combinators db db.private
+db.queries db.sqlite.errors db.sqlite.ffi db.sqlite.lib
+db.tuples db.tuples.private db.types destructors interpolate
+kernel locals math math.parser namespaces nmake random sequences
+sequences.deep ;
 IN: db.sqlite
 
 TUPLE: sqlite-db path ;