: query-make ( class quot -- statements )
#! query, input, outputs, secondary queries
- over unparse "table" set
+ over db-table "table" set
[ sql-props ] dip
[ 0 sql-counter rot with-variable ] curry
{ "" { } { } { } } nmake
things drop-table
] with-db
] unit-test
+
+! Tables can have different names than the name of the tuple
+TUPLE: foo slot ;
+C: <foo> foo
+foo "BAR" { { "slot" "SOMETHING" INTEGER +not-null+ } } define-persistent
+
+TUPLE: hi bye ;
+C: <hi> hi
+hi "HELLO"
+{ { "bye" "BUHBYE" INTEGER { +foreign-id+ foo "SOMETHING" } } } define-persistent
+
+[ T{ foo { slot 1 } } T{ hi { bye 1 } } ] [
+ test.db [
+ foo create-table
+ hi create-table
+ 1 <foo> insert-tuple
+ f <foo> select-tuple
+ 1 <hi> insert-tuple
+ f <hi> select-tuple
+ hi drop-table
+ foo drop-table
+ ] with-db
+] unit-test
: >reference-string ( string pair -- string )
first2
- [ [ unparse " " glue ] [ db-columns ] bi ] dip
+ [ [ db-table " " glue ] [ db-columns ] bi ] dip
swap [ column-name>> = ] with find nip
[ no-column ] unless*
column-name>> "(" ")" surround append ;