Handbook
Glossary
<insert-db-assigned-statement> ( class -- object )
High-level tuple/database integration
ยป
Tuple database protocol
Prev:
drop-sql-statement ( class -- object )
Next:
<insert-user-assigned-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 database-assigned primary key.
Definition
USING:
db
;
IN:
db.tuples
HOOK:
<insert-db-assigned-statement>
db-connection
( class -- object )
Methods
USING:
db.postgresql.private
db.queries
db.tuples
db.types
kernel
nmake
sequences
;
M:
postgresql-db-connection
<insert-db-assigned-statement>
[
"select add_"
0%
0%
"("
0%
dup
find-primary-key
first
2,
remove-id
[
", "
0%
]
[
bind%
]
interleave
");"
0%
]
query-make
;
USING:
accessors
db.queries
db.sqlite.private
db.tuples
db.types
kernel
nmake
sequences
;
M:
sqlite-db-connection
<insert-db-assigned-statement>
[
"insert into "
0%
0%
"("
0%
remove-db-assigned-id
dup
[
", "
0%
]
[
column-name>>
0%
]
interleave
") values("
0%
[
", "
0%
]
[
dup
type>>
+random-id+
=
[
[
slot-name>>
]
[
column-name>>
":"
prepend
dup
0%
random-id-generator
]
[
type>>
]
tri
<generator-bind>
1,
]
[
bind%
]
if
]
interleave
");"
0%
]
query-make
;