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