diff --git a/basis/db/db-docs.factor b/basis/db/db-docs.factor index c668e9b933..7e711aa90c 100644 --- a/basis/db/db-docs.factor +++ b/basis/db/db-docs.factor @@ -128,14 +128,14 @@ HELP: in-transaction? HELP: query-each { $values - { "statement" statement } { "quot" quotation } } -{ $description "A combinator that calls a quotation on a sequence of SQL statements to their results query results." } ; + { "result-set" result-set } { "quot" quotation } } +{ $description "Applies the quotation to each row of the " { $link result-set } " in order." } ; HELP: query-map { $values - { "statement" statement } { "quot" quotation } + { "result-set" result-set } { "quot" quotation } { "seq" sequence } } -{ $description "A combinator that maps a sequence of SQL statements to their results query results." } ; +{ $description "Applies the quotation to each row of the " { $link result-set } " in order." } ; HELP: rollback-transaction { $description "Rolls back a transaction; no data is committed to the database. User code should make use of the " { $link with-transaction } " combinator." } ; diff --git a/basis/db/db.factor b/basis/db/db.factor index de041aee2a..e6b0549612 100644 --- a/basis/db/db.factor +++ b/basis/db/db.factor @@ -105,14 +105,14 @@ M: object execute-statement* ( statement type -- ) : sql-row-typed ( result-set -- seq ) dup #columns [ row-column-typed ] with { } map-integers ; -: query-each ( statement quot: ( statement -- ) -- ) +: query-each ( result-set quot: ( row -- ) -- ) over more-rows? [ [ call ] 2keep over advance-row query-each ] [ 2drop ] if ; inline recursive -: query-map ( statement quot -- seq ) +: query-map ( result-set quot: ( row -- row' ) -- seq ) collector [ query-each ] dip { } like ; inline : with-db ( db quot -- )