simple update support

master
Moritz Heidkamp 13 years ago
parent fa53aa1e26
commit b95efc8ca5

@ -94,6 +94,15 @@
(string-upcase (symbol->string type)) (string-upcase (symbol->string type))
(string-join (map (lambda (x) (self 'ssql->sql x)) rest)))))) (string-join (map (lambda (x) (self 'ssql->sql x)) rest))))))
((set values)
(string-append "SET "
(string-intersperse (map (lambda (val)
(sprintf "~A = ~A"
(first val)
(self 'ssql->sql (second val))))
values)
", ")))
((operator->sql type operator separator operands) ((operator->sql type operator separator operands)
(case type (case type
((infix) ((infix)
@ -148,6 +157,7 @@
(define-operators *ansi-translator* (define-operators *ansi-translator*
(select prefix) (select prefix)
(update prefix)
(from prefix "FROM" ", ") (from prefix "FROM" ", ")
(where prefix) (where prefix)
(order prefix "ORDER BY" ", ") (order prefix "ORDER BY" ", ")

@ -27,6 +27,15 @@
"SELECT lastname, firstname FROM people ORDER BY lastname DESC, firstname" "SELECT lastname, firstname FROM people ORDER BY lastname DESC, firstname"
(ssql->sql #f '(select (columns lastname firstname) (from people) (order (desc lastname) firstname))))) (ssql->sql #f '(select (columns lastname firstname) (from people) (order (desc lastname) firstname)))))
(test-group "updates"
(test "simple case"
"UPDATE actors SET firstname = 'Rube', lastname = 'Goldberg'"
(ssql->sql #f '(update actors (set (firstname "Rube") (lastname "Goldberg")))))
(test "with condition"
"UPDATE actors SET firstname = 'Felix' WHERE (lastname = 'Winkelmann')"
(ssql->sql #f '(update actors (set (firstname "Felix")) (where (= lastname "Winkelmann"))))))
(test-group "syntax" (test-group "syntax"
(test "set literals" (test "set literals"

Loading…
Cancel
Save