From 33cf06740e45b20084d6ac53aedfd350a766ff60 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Thu, 18 Aug 2011 17:28:25 +0200 Subject: [PATCH] add `returning' to `clauses-order' to make it composable --- ssql-postgresql.scm | 6 +++++- tests/run.scm | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ssql-postgresql.scm b/ssql-postgresql.scm index 7071e5d..5dcf3c5 100644 --- a/ssql-postgresql.scm +++ b/ssql-postgresql.scm @@ -8,7 +8,9 @@ (define *postgresql-translator* (let ((type->sql-converters `((,boolean? . boolean->sql) - ,@(*ansi-translator* 'type->sql-converters)))) + ,@(*ansi-translator* 'type->sql-converters))) + (clauses-order (append (*ansi-translator* 'clauses-order) + '(returning)))) (derive-object (*ansi-translator*) ((escape-string string) @@ -17,6 +19,8 @@ ((boolean->sql boolean) (if boolean "'t'" "'f'")) + ((clauses-order) clauses-order) + ((type->sql-converters) type->sql-converters)))) (define-operators *postgresql-translator* diff --git a/tests/run.scm b/tests/run.scm index 851a9be..85169ec 100644 --- a/tests/run.scm +++ b/tests/run.scm @@ -27,6 +27,10 @@ (test "returning" "INSERT INTO widgets VALUES ('foo', 'bar') RETURNING id, name" - (ssql->sql #t '(insert (into widgets) (values ("foo" "bar")) (returning id name))))) + (ssql->sql #t '(insert (into widgets) (values ("foo" "bar")) (returning id name)))) + + (test "compose returning" + '(insert (into widgets) (values (1 2 3)) (returning id)) + (ssql-compose #t '(insert (into widgets) (values (1 2 3))) '((returning id))))) (test-exit) \ No newline at end of file