math.ranges strings urls fry db.tuples.private ;
IN: db.tuples.tests
+: test-sqlite ( quot -- )
+ [ ] swap '[
+ "tuples-test.db" temp-file sqlite-db _ with-db
+ ] unit-test ;
+
+: test-postgresql ( quot -- )
+ [ ] swap '[
+ { "localhost" "postgres" "foob" "factor-test" }
+ postgresql-db _ with-db
+ ] unit-test ;
+
TUPLE: person the-id the-name the-number the-real
ts date time blob factor-blob url ;
{ "channel" "CHANNEL" TEXT }
{ "mode" "MODE" TEXT }
{ "contents" "CONTENTS" TEXT }
- { "date" "DATE" TIMESTAMP }
+ { "timestamp" "DATE" TIMESTAMP }
{ "annotations" { +has-many+ annotation } }
} define-persistent
{ "contents" "CONTENTS" TEXT }
} define-persistent ;
-! { "localhost" "postgres" "" "factor-test" } postgresql-db [
- ! [ paste drop-table ] [ drop ] recover
- ! [ annotation drop-table ] [ drop ] recover
- ! [ paste drop-table ] [ drop ] recover
- ! [ annotation drop-table ] [ drop ] recover
- ! [ ] [ paste create-table ] unit-test
- ! [ ] [ annotation create-table ] unit-test
-! ] with-db
+: test-paste-schema ( -- )
+ [ ] [ db-assigned-paste-schema ] unit-test
+ [ ] [ paste ensure-table ] unit-test
+ [ ] [ annotation ensure-table ] unit-test
+ [ ] [ annotation drop-table ] unit-test
+ [ ] [ paste drop-table ] unit-test
+ [ ] [ paste create-table ] unit-test
+ [ ] [ annotation create-table ] unit-test
-: test-sqlite ( quot -- )
- [ ] swap '[ "tuples-test.db" temp-file sqlite-db _ with-db ] unit-test ;
+ ;
+
+! [ test-paste-schema ] test-sqlite
+! [ test-paste-schema ] test-postgresql
-: test-postgresql ( quot -- )
- [ ] swap '[ { "localhost" "postgres" "foob" "factor-test" } postgresql-db _ with-db ] unit-test ;
: test-repeated-insert
[ ] [ person ensure-table ] unit-test
! PostgreSQL Types:
! http://developer.postgresql.org/pgdocs/postgres/datatype.html
-ERROR: unknown-modifier ;
+ERROR: unknown-modifier modifier ;
+
+: ?at ( obj assoc -- value/obj ? )
+ dupd at* [ [ nip ] [ drop ] if ] keep ;
: lookup-modifier ( obj -- string )
{
{ [ dup array? ] [ unclip lookup-modifier swap compound ] }
- [ persistent-table at* [ unknown-modifier ] unless third ]
+ [ persistent-table ?at [ unknown-modifier ] unless third ]
} cond ;
ERROR: no-sql-type ;