fix potential infinite loop, minor docs updates
parent
2a435b154f
commit
5be907e857
|
@ -116,7 +116,7 @@ HELP: execute-statement*
|
|||
|
||||
HELP: execute-statement
|
||||
{ $values { "statement" statement } }
|
||||
{ $description } ;
|
||||
{ $description "" } ;
|
||||
|
||||
ARTICLE: "db" "Database library"
|
||||
{ $subsection "db-custom-database-combinators" }
|
||||
|
|
|
@ -80,11 +80,14 @@ GENERIC: execute-statement* ( statement type -- )
|
|||
M: object execute-statement* ( statement type -- )
|
||||
drop query-results dispose ;
|
||||
|
||||
: execute-one-statement ( statement -- )
|
||||
dup type>> execute-statement* ;
|
||||
|
||||
: execute-statement ( statement -- )
|
||||
dup sequence? [
|
||||
[ execute-statement ] each
|
||||
[ execute-one-statement ] each
|
||||
] [
|
||||
dup type>> execute-statement*
|
||||
execute-one-statement
|
||||
] if ;
|
||||
|
||||
: bind-statement ( obj statement -- )
|
||||
|
|
|
@ -518,6 +518,7 @@ string-encoding-test "STRING_ENCODING_TEST" {
|
|||
! [ ] [ T{ exam f f "Kenny" 60 } insert-tuple ] unit-test
|
||||
! [ ] [ T{ exam f f "Cartman" 41 } insert-tuple ] unit-test
|
||||
[ ] [ 10 [ random-exam insert-tuple ] times ] unit-test
|
||||
[ 5 ] [ <query> T{ exam { score T{ interval { from { 0 t } } { to { 100 t } } } } } >>tuple 5 >>limit select-tuples length ] unit-test
|
||||
! [ ] [ T{ exam { name "Kenny" } } >query ] unit-test
|
||||
! [ ] [ query ] unit-test
|
||||
;
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
! Copyright (C) 2008 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: classes hashtables help.markup help.syntax io.streams.string kernel sequences strings ;
|
||||
USING: classes hashtables help.markup help.syntax io.streams.string kernel sequences strings db.tuples math ;
|
||||
IN: db.types
|
||||
|
||||
HELP: (lookup-type)
|
||||
{ $values
|
||||
{ "obj" object }
|
||||
{ "string" string } }
|
||||
{ $description "" } ;
|
||||
|
||||
HELP: +autoincrement+
|
||||
{ $description "" } ;
|
||||
|
||||
|
@ -55,7 +49,7 @@ HELP: <low-level-binding>
|
|||
{ $description "" } ;
|
||||
|
||||
HELP: BIG-INTEGER
|
||||
{ $description "A 64-bit integer." } ;
|
||||
{ $description "A 64-bit integer. Whether this number is signed or unsigned depends on the database backend." } ;
|
||||
|
||||
HELP: BLOB
|
||||
{ $description "A serialized Factor object. The database library automatically serializes the object for a SQL insert or update and deserializes it on a tuple query." } ;
|
||||
|
@ -73,13 +67,13 @@ HELP: DOUBLE
|
|||
{ $description "Corresponds to Factor's 64bit floating-point numbers." } ;
|
||||
|
||||
HELP: FACTOR-BLOB
|
||||
{ $description "" } ;
|
||||
{ $description "A serialized Factor object." } ;
|
||||
|
||||
HELP: INTEGER
|
||||
{ $description "" } ;
|
||||
{ $description "A small integer, at least 32 bits in length. Whether this number is signed or unsigned depends on the database backend." } ;
|
||||
|
||||
HELP: NULL
|
||||
{ $description "" } ;
|
||||
{ $description "The SQL null type." } ;
|
||||
|
||||
HELP: REAL
|
||||
{ $description "" } ;
|
||||
|
@ -94,16 +88,18 @@ HELP: TIME
|
|||
{ $description "" } ;
|
||||
|
||||
HELP: TIMESTAMP
|
||||
{ $description "" } ;
|
||||
{ $description "A Factor timestamp." } ;
|
||||
|
||||
HELP: UNSIGNED-BIG-INTEGER
|
||||
{ $description "" } ;
|
||||
{ $description "For portability, if a number is known to be 64bit, then this datatype may be used. Some databases, like SQLite, cannot store arbitrary bignums as BIGINT types. If storing arbitrary bignums, use " { $link FACTOR-BLOB } "." } ;
|
||||
|
||||
{ INTEGER SIGNED-BIG-INTEGER UNSIGNED-BIG-INTEGER } related-words
|
||||
|
||||
HELP: URL
|
||||
{ $description "" } ;
|
||||
{ $description "A Factor " { $link "urls" } " object." } ;
|
||||
|
||||
HELP: VARCHAR
|
||||
{ $description "" } ;
|
||||
{ $description "The SQL varchar type. This type can take an integer as an argument." } ;
|
||||
|
||||
HELP: assigned-id-spec?
|
||||
{ $values
|
||||
|
@ -135,18 +131,19 @@ HELP: db-assigned-id-spec?
|
|||
|
||||
HELP: find-primary-key
|
||||
{ $values
|
||||
{ "specs" null }
|
||||
{ "specs" "an array of sql-specs" }
|
||||
{ "obj" object } }
|
||||
{ $description "" } ;
|
||||
{ $description "Returns the row from the sql-specs array that was defined by " { $link define-persistent } "." }
|
||||
{ $notes "This is a low-level word." } ;
|
||||
|
||||
HELP: generator-bind
|
||||
{ $description "" } ;
|
||||
|
||||
HELP: get-slot-named
|
||||
{ $values
|
||||
{ "name" null } { "obj" object }
|
||||
{ "value" null } }
|
||||
{ $description "" } ;
|
||||
{ "name" "a slot name" } { "tuple" tuple }
|
||||
{ "value" "the value stored in the slot" } }
|
||||
{ $description "Returns the value stored in a tuple slot, where the tuple slot is a string." } ;
|
||||
|
||||
HELP: join-space
|
||||
{ $values
|
||||
|
@ -192,23 +189,11 @@ HELP: normalize-spec
|
|||
{ "spec" null } }
|
||||
{ $description "" } ;
|
||||
|
||||
HELP: number>string*
|
||||
{ $values
|
||||
{ "n/string" null }
|
||||
{ "string" string } }
|
||||
{ $description "" } ;
|
||||
|
||||
HELP: offset-of-slot
|
||||
{ $values
|
||||
{ "string" string } { "obj" object }
|
||||
{ "n" null } }
|
||||
{ $description "" } ;
|
||||
|
||||
HELP: paren
|
||||
{ $values
|
||||
{ "string" string }
|
||||
{ "new-string" null } }
|
||||
{ $description "" } ;
|
||||
{ "string" string } { "tuple" tuple }
|
||||
{ "n" integer } }
|
||||
{ $description "Returns the offset of a tuple slot accessed by name." } ;
|
||||
|
||||
HELP: persistent-table
|
||||
{ $values
|
||||
|
@ -294,7 +279,6 @@ ARTICLE: "db.types" "Database types"
|
|||
{ $subsection BLOB }
|
||||
{ $subsection FACTOR-BLOB }
|
||||
"Factor URLs:"
|
||||
{ $subsection URL }
|
||||
;
|
||||
{ $subsection URL } ;
|
||||
|
||||
ABOUT: "db.types"
|
||||
|
|
|
@ -126,11 +126,11 @@ ERROR: no-sql-type ;
|
|||
HOOK: bind% db ( spec -- )
|
||||
HOOK: bind# db ( spec obj -- )
|
||||
|
||||
: offset-of-slot ( string obj -- n )
|
||||
: offset-of-slot ( string tuple -- n )
|
||||
class superclasses [ "slots" word-prop ] map concat
|
||||
slot-named offset>> ;
|
||||
|
||||
: get-slot-named ( name obj -- value )
|
||||
: get-slot-named ( name tuple -- value )
|
||||
tuck offset-of-slot slot ;
|
||||
|
||||
: set-slot-named ( value name obj -- )
|
||||
|
|
Loading…
Reference in New Issue