Merge branch 'master' of git://factorcode.org/git/factor
commit
476b31844a
basis/db
postgresql
queries
sqlite
types
extra/webapps
calculator
counter
|
@ -230,6 +230,7 @@ M: postgresql-db persistent-table ( -- hashtable )
|
|||
|
||||
{ +foreign-id+ { f f "references" } }
|
||||
|
||||
{ +on-update+ { f f "on update" } }
|
||||
{ +on-delete+ { f f "on delete" } }
|
||||
{ +restrict+ { f f "restrict" } }
|
||||
{ +cascade+ { f f "cascade" } }
|
||||
|
|
|
@ -114,6 +114,9 @@ M: sequence where ( spec obj -- )
|
|||
[ " or " 0% ] [ dupd where ] interleave drop
|
||||
] in-parens ;
|
||||
|
||||
M: NULL where ( spec obj -- )
|
||||
drop column-name>> 0% " is NULL" 0% ;
|
||||
|
||||
: object-where ( spec obj -- )
|
||||
over column-name>> 0% " = " 0% bind# ;
|
||||
|
||||
|
|
|
@ -178,6 +178,7 @@ M: sqlite-db persistent-table ( -- assoc )
|
|||
{ +random-id+ { "integer" "integer" f } }
|
||||
{ +foreign-id+ { "integer" "integer" "references" } }
|
||||
|
||||
{ +on-update+ { f f "on update" } }
|
||||
{ +on-delete+ { f f "on delete" } }
|
||||
{ +restrict+ { f f "restrict" } }
|
||||
{ +cascade+ { f f "cascade" } }
|
||||
|
|
|
@ -229,7 +229,7 @@ T{ book
|
|||
"Now we've created a book. Let's save it to the database."
|
||||
{ $code <" USING: db db.sqlite fry io.files ;
|
||||
: with-book-tutorial ( quot -- )
|
||||
'[ "book-tutorial.db" temp-file sqlite-db _ with-db ] call ;
|
||||
'[ "book-tutorial.db" temp-file <sqlite-db> _ with-db ] call ;
|
||||
|
||||
[
|
||||
book recreate-table
|
||||
|
|
|
@ -472,7 +472,12 @@ TUPLE: exam id name score ;
|
|||
T{ exam } select-tuples
|
||||
] unit-test
|
||||
|
||||
[ 4 ] [ T{ exam } count-tuples ] unit-test ;
|
||||
[ 4 ] [ T{ exam } count-tuples ] unit-test
|
||||
|
||||
[ ] [ T{ exam { score 10 } } insert-tuple ] unit-test
|
||||
|
||||
[ 10 ]
|
||||
[ T{ exam { name NULL } } select-tuples first score>> ] unit-test ;
|
||||
|
||||
TUPLE: bignum-test id m n o ;
|
||||
: <bignum-test> ( m n o -- obj )
|
||||
|
|
|
@ -26,8 +26,8 @@ SINGLETONS: +db-assigned-id+ +user-assigned-id+ +random-id+ ;
|
|||
UNION: +primary-key+ +db-assigned-id+ +user-assigned-id+ +random-id+ ;
|
||||
|
||||
SYMBOLS: +autoincrement+ +serial+ +unique+ +default+ +null+ +not-null+
|
||||
+foreign-id+ +has-many+ +on-delete+ +restrict+ +cascade+ +set-null+
|
||||
+set-default+ ;
|
||||
+foreign-id+ +has-many+ +on-update+ +on-delete+ +restrict+ +cascade+
|
||||
+set-null+ +set-default+ ;
|
||||
|
||||
SYMBOL: IGNORE
|
||||
|
||||
|
@ -91,7 +91,7 @@ ERROR: not-persistent class ;
|
|||
|
||||
: relation? ( spec -- ? ) [ +has-many+ = ] deep-find ;
|
||||
|
||||
SYMBOLS: INTEGER BIG-INTEGER SIGNED-BIG-INTEGER UNSIGNED-BIG-INTEGER
|
||||
SINGLETONS: INTEGER BIG-INTEGER SIGNED-BIG-INTEGER UNSIGNED-BIG-INTEGER
|
||||
DOUBLE REAL BOOLEAN TEXT VARCHAR DATE TIME DATETIME TIMESTAMP BLOB
|
||||
FACTOR-BLOB NULL URL ;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ TUPLE: calculator < dispatcher ;
|
|||
! Deployment example
|
||||
USING: db.sqlite furnace.alloy namespaces http.server ;
|
||||
|
||||
: calculator-db ( -- params db ) "calculator.db" sqlite-db ;
|
||||
: calculator-db ( -- db ) "calculator.db" <sqlite-db> ;
|
||||
|
||||
: run-calculator ( -- )
|
||||
<calculator>
|
||||
|
|
|
@ -32,7 +32,7 @@ M: counter-app init-session* drop 0 count sset ;
|
|||
! Deployment example
|
||||
USING: db.sqlite furnace.alloy namespaces ;
|
||||
|
||||
: counter-db ( -- params db ) "counter.db" sqlite-db ;
|
||||
: counter-db ( -- db ) "counter.db" <sqlite-db> ;
|
||||
|
||||
: run-counter ( -- )
|
||||
<counter-app>
|
||||
|
|
Loading…
Reference in New Issue