add support for RETURNING

master
Moritz Heidkamp 13 years ago
parent 86c558e361
commit de54e9ed44

@ -22,6 +22,7 @@
(define-operators *postgresql-translator* (define-operators *postgresql-translator*
(limit prefix) (limit prefix)
(offset prefix) (offset prefix)
(returning prefix "RETURNING" ", ")
(random function)) (random function))
(register-sql-engine! connection? *postgresql-translator*) (register-sql-engine! connection? *postgresql-translator*)

@ -6,7 +6,7 @@
(define *test-postgresql-translator* (define *test-postgresql-translator*
(derive-object (*postgresql-translator* self super) (derive-object (*postgresql-translator* self super)
((escape-string string) ((escape-string string)
(super (ssql-connection) string)))) (string-translate* string '(("'" . "''"))))))
(register-sql-engine! (lambda (x) (eq? x #t)) *test-postgresql-translator*) (register-sql-engine! (lambda (x) (eq? x #t)) *test-postgresql-translator*)
@ -23,6 +23,10 @@
(test "random()" (test "random()"
"SELECT * FROM widgets ORDER BY RANDOM()" "SELECT * FROM widgets ORDER BY RANDOM()"
(ssql->sql #t `(select (columns *) (from widgets) (order (random)))))) (ssql->sql #t `(select (columns *) (from widgets) (order (random)))))
(test "returning"
"INSERT INTO widgets VALUES ('foo', 'bar') RETURNING id, name"
(ssql->sql #t '(insert (into widgets) (values ("foo" "bar")) (returning id name)))))
(test-exit) (test-exit)
Loading…
Cancel
Save