Handbook
Glossary
<insert-user-assigned-statement> ( class -- object )
High-level tuple/database integration
ยป
Tuple database protocol
Prev:
<insert-db-assigned-statement> ( class -- object )
Next:
<update-tuple-statement> ( class -- object )
Vocabulary
db
.
tuples
Inputs
class
a
class
Outputs
object
an
object
Word description
A database-specific hook for generating the SQL for an insert statement with a user-assigned primary key.
Definition
USING:
db
;
IN:
db.tuples
HOOK:
<insert-user-assigned-statement>
db-connection
( class -- object )
Methods
USING:
accessors
db.postgresql
db.postgresql.private
db.queries
db.tuples
db.types
kernel
nmake
sequences
;
M:
postgresql-db-connection
<insert-user-assigned-statement>
[
"insert into "
0%
0%
"("
0%
dup
[
", "
0%
]
[
column-name>>
0%
]
interleave
")"
0%
" values("
0%
[
", "
0%
]
[
dup
type>>
+random-id+
=
[
[
bind-name%
slot-name>>
f
random-id-generator
]
[
type>>
]
bi
<generator-bind>
1,
]
[
bind%
]
if
]
interleave
");"
0%
]
query-make
;
USING:
db.sqlite.private
db.tuples
;
M:
sqlite-db-connection
<insert-user-assigned-statement>
<insert-db-assigned-statement>
;