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>
49 HELP: <low-level-binding>
53 { $description "A 64-bit integer. Whether this number is signed or unsigned depends on the database backend." } ;
56 { $description "A byte array." } ;
59 { $description "Either true or false." } ;
62 { $description "A date without a time component." } ;
65 { $description "A date and a time." } ;
68 { $description "Corresponds to Factor's 64-bit floating-point numbers." } ;
71 { $description "A serialized Factor object." } ;
74 { $description "A small integer, at least 32 bits in length. Whether this number is signed or unsigned depends on the database backend." } ;
77 { $description "The SQL null type." } ;
80 { $description "A real number of unlimited precision. May not be supported on all databases." } ;
82 HELP: SIGNED-BIG-INTEGER
83 { $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 } "." } ;
86 { $description "Stores a string that is longer than a " { $link VARCHAR } ". SQLite uses this type for strings; it does not handle " { $link VARCHAR } " strings." } ;
89 { $description "A timestamp without a date component." } ;
92 { $description "A Factor timestamp." } ;
94 HELP: UNSIGNED-BIG-INTEGER
95 { $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 } "." } ;
97 { INTEGER SIGNED-BIG-INTEGER UNSIGNED-BIG-INTEGER } related-words
100 { $description "A Factor " { $link "urls" } " object." } ;
103 { $description "The SQL varchar type. This type can take an integer as an argument." }
104 { $examples { $unchecked-example "{ VARCHAR 256 }" "" } } ;
106 HELP: user-assigned-id-spec?
108 { "specs" "a sequence of sql specs" }
109 { "?" "a boolean" } }
110 { $description "Tests if any of the sql specs has the type " { $link +user-assigned-id+ } "." } ;
114 { "spec" null } { "obj" object } }
115 { $description "" } ;
120 { $description "" } ;
124 { "string" string } { "obj" object }
125 { "hash" hashtable } }
126 { $description "" } ;
128 HELP: db-assigned-id-spec?
130 { "specs" "a sequence of sql specs" }
131 { "?" "a boolean" } }
132 { $description "Tests if any of the sql specs has the type " { $link +db-assigned-id+ } "." } ;
134 HELP: find-primary-key
136 { "specs" "a sequence of sql-specs" }
137 { "seq" "a sequence of sql-specs" } }
138 { $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." }
139 { $notes "This is a low-level word." } ;
142 { $description "" } ;
146 { "name" "a slot name" } { "tuple" tuple }
147 { "value" "the value stored in the slot" } }
148 { $description "Returns the value stored in a tuple slot, where the tuple slot is a string." } ;
151 { $description "" } ;
153 HELP: lookup-create-type
156 { "string" string } }
157 { $description "" } ;
159 HELP: lookup-modifier
162 { "string" string } }
163 { $description "" } ;
168 { "string" string } }
169 { $description "" } ;
171 HELP: low-level-binding
172 { $description "" } ;
177 { "string" string } }
178 { $description "" } ;
182 { "type" "a sql type" } }
183 { $description "Throws an error containing a sql type that is unsupported or the result of a typo." } ;
188 { $description "" } ;
192 { "string" string } { "tuple" tuple }
194 { $description "Returns the offset of a tuple slot accessed by name." } ;
196 HELP: persistent-table
199 { "hash" hashtable } }
200 { $description "" } ;
205 { "?" "a boolean" } }
206 { $description "" } ;
208 HELP: random-id-generator
209 { $description "" } ;
214 { "?" "a boolean" } }
215 { $description "" } ;
217 HELP: remove-db-assigned-id
221 { $description "" } ;
227 { $description "" } ;
229 HELP: remove-relations
232 { "newcolumns" null } }
233 { $description "" } ;
237 { "value" null } { "name" null } { "obj" object } }
238 { $description "" } ;
242 { "class" class } { "spec" null }
244 { $description "" } ;
247 { $description "" } ;
249 HELP: unknown-modifier
250 { $values { "modifier" string } }
251 { $description "Throws an error containing an unknown sql modifier." } ;
253 ARTICLE: "db.types" "Database types"
254 "The " { $vocab-link "db.types" } " vocabulary maps Factor types to database types." $nl
256 { $subsection +db-assigned-id+ }
257 { $subsection +user-assigned-id+ }
258 { $subsection +random-id+ }
259 "Null and boolean types:"
261 { $subsection BOOLEAN }
263 { $subsection VARCHAR }
266 { $subsection INTEGER }
267 { $subsection BIG-INTEGER }
268 { $subsection SIGNED-BIG-INTEGER }
269 { $subsection UNSIGNED-BIG-INTEGER }
270 { $subsection DOUBLE }
274 { $subsection DATETIME }
276 { $subsection TIMESTAMP }
277 "Factor byte-arrays:"
279 "Arbitrary Factor objects:"
280 { $subsection FACTOR-BLOB }
282 { $subsection URL } ;