1 ! Copyright (C) 2008 Doug Coleman.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: help.markup help.syntax kernel strings ;
7 { $description "The database assigns a primary key to the object. The primary key is most likely a big integer, but is database-dependent." } ;
10 { $description "Allows a default value for a column to be provided." } ;
13 { $description "Makes the column a foreign key, referencing a column in another table." } ;
16 { $description "Ensures that a column is not null." } ;
19 { $description "Allows a column to be null." } ;
22 { $description "Makes a column a primary key. Only one column may be a primary key." } ;
25 { $description "Factor chooses a random number and tries to insert the tuple into the database with this number as its primary key. The default number of retries to find a unique random number is 10, though in practice it will almost certainly succeed on the first try." } ;
27 HELP: +user-assigned-id+
28 { $description "The user is responsible for choosing a primary key for tuples inserted with this database type. Keys must be unique or else the database will throw an error. Usually it is better to use a " { $link +db-assigned-id+ } "." } ;
30 HELP: <generator-bind>
31 { $values { "slot-name" object } { "key" object } { "generator-singleton" object } { "type" object } { "generator-bind" generator-bind } }
32 { $description "An internal constructor for creating objects containing parameters used for binding generated values to a tuple query." } ;
35 { $values { "key" object } { "type" object } { "value" object } { "literal-bind" literal-bind } }
36 { $description "An internal constructor for creating objects containing parameters used for binding literal values to a tuple query." } ;
39 { $description "A 64-bit integer. Whether this number is signed or unsigned depends on the database backend." } ;
42 { $description "A byte array." } ;
45 { $description "Either true or false." } ;
48 { $description "A date without a time component." } ;
51 { $description "A date and a time." } ;
54 { $description "Corresponds to Factor's 64-bit floating-point numbers." } ;
57 { $description "A serialized Factor object." } ;
60 { $description "A small integer, at least 32 bits in length. Whether this number is signed or unsigned depends on the database backend." } ;
63 { $description "The SQL null type." } ;
66 { $description "A real number of unlimited precision. May not be supported on all databases." } ;
68 HELP: SIGNED-BIG-INTEGER
69 { $description "For portability, if a number is known to be 64bit and signed, 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 } "." } ;
72 { $description "Stores a string that is longer than a " { $link VARCHAR } ". SQLite uses this type for strings; it does not handle " { $link VARCHAR } " strings." } ;
75 { $description "A timestamp without a date component." } ;
78 { $description "A Factor timestamp." } ;
80 HELP: UNSIGNED-BIG-INTEGER
81 { $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 } "." } ;
83 { INTEGER SIGNED-BIG-INTEGER UNSIGNED-BIG-INTEGER } related-words
86 { $description "A Factor " { $link "urls" } " object." } ;
89 { $description "The SQL varchar type. This type can take an integer as an argument." }
90 { $examples { $unchecked-example "{ VARCHAR 256 }" "" } } ;
92 HELP: user-assigned-id-spec?
94 { "specs" "a sequence of SQL specs" }
96 { $description "Tests if any of the SQL specs has the type " { $link +user-assigned-id+ } "." } ;
100 { "spec" "an SQL spec" } { "obj" object } }
101 { $description "A generic word that lets a database construct a literal binding." } ;
105 { "spec" "an SQL spec" } }
106 { $description "A generic word that lets a database output a binding." } ;
108 HELP: db-assigned-id-spec?
110 { "specs" "a sequence of SQL specs" }
112 { $description "Tests if any of the SQL specs has the type " { $link +db-assigned-id+ } "." } ;
114 HELP: find-primary-key
116 { "specs" "a sequence of SQL specs" }
117 { "seq" "a sequence of SQL specs" } }
118 { $description "Returns the rows from the SQL specs array that are part of the primary key. Composite primary keys are supported, so this word must return a sequence." }
119 { $notes "This is a low-level word." } ;
123 { "type" "an SQL type" } }
124 { $description "Throws an error containing an SQL type that is unsupported or the result of a typo." } ;
128 { "spec" "an SQL spec" } }
129 { $description "Normalizes an SQL spec." } ;
133 { "spec" "an SQL spec" }
135 { $description "Returns true if an SQL spec is a primary key." } ;
139 { "spec" "an SQL spec" }
141 { $description "Returns true if an SQL spec is a relation." } ;
143 HELP: unknown-modifier
144 { $values { "modifier" string } }
145 { $description "Throws an error containing an unknown SQL modifier." } ;
147 ARTICLE: "db.types" "Database types"
148 "The " { $vocab-link "db.types" } " vocabulary maps Factor types to database types." $nl
149 "Primary and foreign keys:"
157 "Null and boolean types:"
183 "Factor byte-arrays:"
184 { $subsections BLOB }
185 "Arbitrary Factor objects:"
186 { $subsections FACTOR-BLOB }
188 { $subsections URL } ;