From 69915c50826a55cc852ead180038b67c11060d30 Mon Sep 17 00:00:00 2001 From: Moritz Heidkamp Date: Mon, 22 Aug 2011 20:17:57 +0200 Subject: [PATCH] add `call' syntax to allow calling of arbitrary functions --- ssql.scm | 9 +++++++++ tests/ansi-test.scm | 6 +++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ssql.scm b/ssql.scm index 9d6b159..447d39e 100644 --- a/ssql.scm +++ b/ssql.scm @@ -137,6 +137,15 @@ ((insert (('into table) rest ...)) (self 'insert table rest)) + ((call (function args ...)) + (sprintf "~A(~A)" + function + (string-intersperse + (map (lambda (arg) + (self 'ssql->sql arg #t)) + args) + ", "))) + ((operator->sql type operator separator operands) (case type ((infix) diff --git a/tests/ansi-test.scm b/tests/ansi-test.scm index ec1d883..9da8550 100644 --- a/tests/ansi-test.scm +++ b/tests/ansi-test.scm @@ -64,4 +64,8 @@ (test-group "syntax" (test "set literals" "SELECT one, two FROM (1, 2)" - (ssql->sql #f '(select (columns one two) (from #(1 2)))))) \ No newline at end of file + (ssql->sql #f '(select (columns one two) (from #(1 2))))) + + (test "function calls" + "SELECT foo(99, (bar('baz')))" + (ssql->sql #f '(select (call foo 99 (call bar "baz")))))) \ No newline at end of file