1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: classes hashtables help.markup help.syntax io.streams.string
4 kernel sequences strings math ;
10 HELP: +db-assigned-id+
11 { $description "The database assigns a primary key to the object. The primary key is most likely a big integer, but is database-dependent." } ;
32 { $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." } ;
40 HELP: +user-assigned-id+
41 { $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+ } "." } ;
43 HELP: <generator-bind>
44 { $values { "slot-name" object } { "key" object } { "generator-singleton" object } { "type" object } { "generator-bind" generator-bind } }
48 { $values { "key" object } { "type" object } { "value" object } { "literal-bind" literal-bind } }
51 HELP: <low-level-binding>
52 { $values { "value" object } { "low-level-binding" low-level-binding } }
56 { $description "A 64-bit integer. Whether this number is signed or unsigned depends on the database backend." } ;
59 { $description "A byte array." } ;
62 { $description "Either true or false." } ;
65 { $description "A date without a time component." } ;
68 { $description "A date and a time." } ;
71 { $description "Corresponds to Factor's 64-bit floating-point numbers." } ;
74 { $description "A serialized Factor object." } ;
77 { $description "A small integer, at least 32 bits in length. Whether this number is signed or unsigned depends on the database backend." } ;
80 { $description "The SQL null type." } ;
83 { $description "A real number of unlimited precision. May not be supported on all databases." } ;
85 HELP: SIGNED-BIG-INTEGER
86 { $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 } "." } ;
89 { $description "Stores a string that is longer than a " { $link VARCHAR } ". SQLite uses this type for strings; it does not handle " { $link VARCHAR } " strings." } ;
92 { $description "A timestamp without a date component." } ;
95 { $description "A Factor timestamp." } ;
97 HELP: UNSIGNED-BIG-INTEGER
98 { $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 } "." } ;
100 { INTEGER SIGNED-BIG-INTEGER UNSIGNED-BIG-INTEGER } related-words
103 { $description "A Factor " { $link "urls" } " object." } ;
106 { $description "The SQL varchar type. This type can take an integer as an argument." }
107 { $examples { $unchecked-example "{ VARCHAR 256 }" "" } } ;
109 HELP: user-assigned-id-spec?
111 { "specs" "a sequence of sql specs" }
112 { "?" "a boolean" } }
113 { $description "Tests if any of the sql specs has the type " { $link +user-assigned-id+ } "." } ;
117 { "spec" null } { "obj" object } }
118 { $description "" } ;
123 { $description "" } ;
127 { "string" string } { "obj" object }
128 { "hash" hashtable } }
129 { $description "" } ;
131 HELP: db-assigned-id-spec?
133 { "specs" "a sequence of sql specs" }
134 { "?" "a boolean" } }
135 { $description "Tests if any of the sql specs has the type " { $link +db-assigned-id+ } "." } ;
137 HELP: find-primary-key
139 { "specs" "a sequence of sql-specs" }
140 { "seq" "a sequence of sql-specs" } }
141 { $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." }
142 { $notes "This is a low-level word." } ;
145 { $description "" } ;
149 { "name" "a slot name" } { "tuple" tuple }
150 { "value" "the value stored in the slot" } }
151 { $description "Returns the value stored in a tuple slot, where the tuple slot is a string." } ;
154 { $description "" } ;
156 HELP: lookup-create-type
159 { "string" string } }
160 { $description "" } ;
162 HELP: lookup-modifier
165 { "string" string } }
166 { $description "" } ;
171 { "string" string } }
172 { $description "" } ;
174 HELP: low-level-binding
175 { $description "" } ;
180 { "string" string } }
181 { $description "" } ;
185 { "type" "a sql type" } }
186 { $description "Throws an error containing a sql type that is unsupported or the result of a typo." } ;
191 { $description "" } ;
195 { "string" string } { "tuple" tuple }
197 { $description "Returns the offset of a tuple slot accessed by name." } ;
199 HELP: persistent-table
202 { "hash" hashtable } }
203 { $description "" } ;
208 { "?" "a boolean" } }
209 { $description "" } ;
211 HELP: random-id-generator
212 { $description "" } ;
217 { "?" "a boolean" } }
218 { $description "" } ;
220 HELP: remove-db-assigned-id
224 { $description "" } ;
230 { $description "" } ;
232 HELP: remove-relations
235 { "newcolumns" null } }
236 { $description "" } ;
240 { "value" null } { "name" null } { "obj" object } }
241 { $description "" } ;
245 { "class" class } { "spec" null }
247 { $description "" } ;
250 { $description "" } ;
252 HELP: unknown-modifier
253 { $values { "modifier" string } }
254 { $description "Throws an error containing an unknown sql modifier." } ;
256 ARTICLE: "db.types" "Database types"
257 "The " { $vocab-link "db.types" } " vocabulary maps Factor types to database types." $nl
259 { $subsection +db-assigned-id+ }
260 { $subsection +user-assigned-id+ }
261 { $subsection +random-id+ }
262 "Null and boolean types:"
264 { $subsection BOOLEAN }
266 { $subsection VARCHAR }
269 { $subsection INTEGER }
270 { $subsection BIG-INTEGER }
271 { $subsection SIGNED-BIG-INTEGER }
272 { $subsection UNSIGNED-BIG-INTEGER }
273 { $subsection DOUBLE }
277 { $subsection DATETIME }
279 { $subsection TIMESTAMP }
280 "Factor byte-arrays:"
282 "Arbitrary Factor objects:"
283 { $subsection FACTOR-BLOB }
285 { $subsection URL } ;