db4: fix inserts. updating

db4
Doug Coleman 2016-03-11 11:44:08 -08:00
parent 0177b77a01
commit 6b5998b061
5 changed files with 10 additions and 6 deletions

View File

@ -1,6 +1,6 @@
! Copyright (C) 2009 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors db.sqlite furnace.actions furnace.alloy
USING: accessors sqlite.db2 furnace.actions furnace.alloy
furnace.conversations furnace.recaptcha furnace.redirection
html.templates.chloe.compiler http.server
http.server.dispatchers http.server.responses io.streams.string

View File

@ -104,10 +104,14 @@ M:: object delete-tuple-sql ( tuple -- statement )
] if
] each ;
! XXX: include the assoc-filter?
: filter-tuple-values ( persistent tuple -- assoc )
[ columns>> ] dip
2dup call-generators
'[ _ over getter>> call( obj -- slot-value ) ] { } map>assoc
'[ _ over getter>> call( obj -- slot-value ) ] { } map>assoc ;
: filter-empty-tuple-values ( persistent tuple -- assoc )
filter-tuple-values
[ nip ] assoc-filter ;
! : where-primary-key ( statement persistent tuple -- statement )
@ -140,7 +144,7 @@ M:: object update-tuple-sql ( tuple -- statement )
M: object select-tuple-sql ( tuple -- object )
[ <select> ] dip
[ >persistent ] [ ] bi {
[ filter-tuple-values [ first2 <column-binder-in> ] map >>in ]
[ filter-empty-tuple-values [ first2 <column-binder-in> ] map >>in ]
[ drop columns>> [ <column-binder-out> ] map >>out ]
[ drop 1array >>from ]
} 2cleave ;

View File

@ -2,7 +2,7 @@
! See http://factorcode.org/license.txt for BSD license.
USING: accessors timers arrays calendar combinators
combinators.smart continuations debugger http.client fry
init io.streams.string kernel locals math math.parser db
init io.streams.string kernel locals math math.parser db2.connections
namespaces sequences site-watcher.db site-watcher.email ;
IN: site-watcher

View File

@ -7,7 +7,7 @@ IN: webapps.mason.backend.tests
{ 0 1 2 } [
! Do it in a with-transaction to simulate semantics of
! with-mason-db
"mason-test.db" <temp-sqlite-db> [
"resource:mason-test.db" <temp-sqlite-db> [
[
init-mason-db

View File

@ -1,4 +1,4 @@
USING: accessors calendar db db.tuples furnace.alloy
USING: accessors calendar furnace.alloy db2.connections orm.tuples
furnace.recaptcha.example http.server io.directories
io.encodings.ascii io.files io.servers kernel namespaces sequences
splitting webapps.utils webapps.wiki websites.concatenative ;