From de54e9ed44f08c3d7dacf6763d19c0d42ea20568 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Thu, 18 Aug 2011 16:14:37 +0200 Subject: [PATCH] add support for RETURNING --- ssql-postgresql.scm | 1 + tests/run.scm | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ssql-postgresql.scm b/ssql-postgresql.scm index 6de8460..7071e5d 100644 --- a/ssql-postgresql.scm +++ b/ssql-postgresql.scm @@ -22,6 +22,7 @@ (define-operators *postgresql-translator* (limit prefix) (offset prefix) + (returning prefix "RETURNING" ", ") (random function)) (register-sql-engine! connection? *postgresql-translator*) diff --git a/tests/run.scm b/tests/run.scm index 4b653ac..851a9be 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -6,7 +6,7 @@ (define *test-postgresql-translator* (derive-object (*postgresql-translator* self super) ((escape-string string) - (super (ssql-connection) string)))) + (string-translate* string '(("'" . "''")))))) (register-sql-engine! (lambda (x) (eq? x #t)) *test-postgresql-translator*) @@ -23,6 +23,10 @@ (test "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) \ No newline at end of file