db4: Fixing up postgresql.

db4
Doug Coleman 2016-03-11 15:26:01 -08:00
parent 00f3b70788
commit 7b07e5a9bf
5 changed files with 16 additions and 9 deletions

View File

@ -17,6 +17,7 @@ PERSISTENT: { session "SESSIONS" }
{ "user-agent" TEXT +not-null+ }
{ "client" TEXT +not-null+ } ;
: get-session ( id -- session )
dup [ session get-state ] when ;

View File

@ -67,7 +67,11 @@ M: +random-key+ compute-generator
swap >>slot-name
set-generator ; inline
: ?cut ( seq n -- before after ) [ short head ] [ short tail ] 2bi ;
ERROR: db-column-must-be-triple extra ;
: parse-column ( seq -- db-column )
3 ?cut [ db-column-must-be-triple ] unless-empty
?first3
[ parse-name ]
[ parse-column-type ]
@ -231,7 +235,7 @@ M: integer parse-table-name throw ;
M: sequence parse-table-name
unclip swap
unclip swap
[ quote-sql-name ] [ "." join ] bi* [ "." glue ] unless-empty ;
[ ] [ "." join ] bi* [ "." glue ] unless-empty ;
M: tuple-class parse-table-name
dup name>> sql-name-replace ;

View File

@ -101,7 +101,9 @@ M: postgresql-db-connection statement>result-set ( statement -- result-set )
[ param-formats ]
} cleave
0 PQexecParams dup postgresql-result-ok? [
[ postgresql-result-error-message parse-sql-error ] [ PQclear ] bi throw
[
postgresql-result-error-message parse-sql-error
] [ PQclear ] bi throw
] unless
] with-destructors
\ postgresql-result-set new-result-set

View File

@ -23,10 +23,10 @@ M: postgresql-db-connection sql-type>string
{ CHARACTER [ "TEXT" ] }
{ DATE [ "DATE" ] }
{ TIME [ "TIME" ] }
{ DATETIME [ "DATETIME" ] }
{ DATETIME [ "TIMESTAMP" ] }
{ TIMESTAMP [ "TIMESTAMP" ] }
{ BLOB [ "BLOB" ] }
{ FACTOR-BLOB [ "BLOB" ] }
{ BLOB [ "BYTEA" ] }
{ FACTOR-BLOB [ "BYTEA" ] }
{ URL [ "TEXT" ] }
{ +db-assigned-key+ [ "INTEGER" ] }
{ +random-key+ [ "BIGINT" ] }
@ -48,10 +48,10 @@ M: postgresql-db-connection sql-create-type>string
{ CHARACTER [ "TEXT" ] }
{ DATE [ "DATE" ] }
{ TIME [ "TIME" ] }
{ DATETIME [ "DATETIME" ] }
{ DATETIME [ "TIMESTAMP" ] }
{ TIMESTAMP [ "TIMESTAMP" ] }
{ BLOB [ "BLOB" ] }
{ FACTOR-BLOB [ "BLOB" ] }
{ BLOB [ "BYTEA" ] }
{ FACTOR-BLOB [ "BYTEA" ] }
{ URL [ "TEXT" ] }
{ +db-assigned-key+ [ "SERIAL" ] }
{ +random-key+ [ "BIGINT" ] }

View File

@ -33,7 +33,7 @@ can-delete-wiki-articles? define-capability
TUPLE: article title revision ;
PERSISTENT: { article "ARTICLES" }
{ "title" { VARCHAR 256 } +not-null+ +user-assigned-key+ }
{ "title" { VARCHAR 256 } { +not-null+ +user-assigned-key+ } }
{ "revision" INTEGER +not-null+ } ; ! revision id
: <article> ( title -- article ) article new swap >>title ;