refactor sqlite bind
parent
1789a58bbf
commit
c9db0fdee1
|
@ -23,7 +23,7 @@ PRIVATE>
|
|||
: sql-bind-command ( sequence string -- )
|
||||
f f <statement> [
|
||||
sqlite-maybe-prepare [
|
||||
handle>> '[ [ _ ] 2dip 1+ swap sqlite-bind-text ] each-index
|
||||
handle>> swap sqlite-bind-sequence
|
||||
] [
|
||||
sqlite-result-set new-result-set advance-row
|
||||
] bi
|
||||
|
@ -32,7 +32,7 @@ PRIVATE>
|
|||
: sql-bind-query ( in-sequence string -- out-sequence )
|
||||
f f <statement> [
|
||||
sqlite-maybe-prepare [
|
||||
handle>> '[ [ _ ] 2dip 1+ swap sqlite-bind-text ] each-index
|
||||
handle>> swap sqlite-bind-sequence
|
||||
] [
|
||||
statement>result-sequence
|
||||
] bi
|
||||
|
|
|
@ -8,6 +8,9 @@ IN: db2.sqlite.lib
|
|||
|
||||
: ?when ( object quot -- object' ) dupd when ; inline
|
||||
|
||||
: assoc-with ( object sequence quot -- obj curry )
|
||||
swapd [ [ -rot ] dip call ] 2curry ; inline
|
||||
|
||||
: sqlite-check-result ( n -- )
|
||||
{
|
||||
{ SQLITE_OK [ ] }
|
||||
|
@ -107,3 +110,6 @@ IN: db2.sqlite.lib
|
|||
|
||||
: sqlite-next ( prepared -- ? )
|
||||
sqlite3_step sqlite-step-has-more-rows? ;
|
||||
|
||||
: sqlite-bind-sequence ( handle sequence -- )
|
||||
[ 1+ swap sqlite-bind-text ] assoc-with each-index ;
|
||||
|
|
Loading…
Reference in New Issue