add ensure-table
parent
bae538d9bd
commit
4398458248
|
@ -30,9 +30,11 @@ SYMBOL: person3
|
|||
SYMBOL: person4
|
||||
|
||||
: test-tuples ( -- )
|
||||
[ person drop-table ] [ drop ] recover
|
||||
[ ] [ person ensure-table ] unit-test
|
||||
[ ] [ person drop-table ] unit-test
|
||||
[ ] [ person create-table ] unit-test
|
||||
[ person create-table ] must-fail
|
||||
[ ] [ person ensure-table ] unit-test
|
||||
|
||||
[ ] [ person1 get insert-tuple ] unit-test
|
||||
|
||||
|
@ -191,8 +193,8 @@ TUPLE: annotation n paste-id summary author mode contents ;
|
|||
[ native-person-schema test-tuples ] test-sqlite
|
||||
[ assigned-person-schema test-tuples ] test-sqlite
|
||||
|
||||
[ native-person-schema test-tuples ] test-postgresql
|
||||
[ assigned-person-schema test-tuples ] test-postgresql
|
||||
! [ native-person-schema test-tuples ] test-postgresql
|
||||
! [ assigned-person-schema test-tuples ] test-postgresql
|
||||
|
||||
TUPLE: serialize-me id data ;
|
||||
|
||||
|
@ -211,7 +213,7 @@ TUPLE: serialize-me id data ;
|
|||
] [ T{ serialize-me f 1 } select-tuples ] unit-test ;
|
||||
|
||||
[ test-serialize ] test-sqlite
|
||||
[ test-serialize ] test-postgresql
|
||||
! [ test-serialize ] test-postgresql
|
||||
|
||||
TUPLE: exam id name score ;
|
||||
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
USING: arrays assocs classes db kernel namespaces
|
||||
tuples words sequences slots math
|
||||
math.parser io prettyprint db.types continuations
|
||||
mirrors sequences.lib tools.walker combinators.lib ;
|
||||
mirrors sequences.lib tools.walker combinators.lib
|
||||
combinators.cleave ;
|
||||
IN: db.tuples
|
||||
|
||||
: define-persistent ( class table columns -- )
|
||||
|
@ -73,6 +74,9 @@ HOOK: insert-tuple* db ( tuple statement -- )
|
|||
: drop-table ( class -- )
|
||||
drop-sql-statement [ execute-statement ] with-disposals ;
|
||||
|
||||
: ensure-table ( class -- )
|
||||
[ dup drop-table ] ignore-errors create-table ;
|
||||
|
||||
: insert-native ( tuple -- )
|
||||
dup class
|
||||
db get db-insert-statements [ <insert-native-statement> ] cache
|
||||
|
|
Loading…
Reference in New Issue