Notation to suppress auto comma insertion?
hmkly opened this issue · 2 comments
Hi,
sqlingvo is really great! Thanks so much for creating it.
I was wondering, is there a way to prevent commas from being automatically inserted into lists? For example:
Desired output: "SELECT * FROM
tableWHERE
start_date < date_sub(now(), interval 1 hour)"
Code: (select [*] (from :table) (where '(>= :start-date (date_sub (now) interval 1 hour))))
Actual output: "SELECT * FROM
table WHERE (
start-date >= date_sub(now(), interval, 1, hour))"
Notice the additional commas after 'interval' and '1' that trigger a SQL syntax error. Is there any notation available to work around this?`
Cheers!
Looks like the date_sub
function is another special case that needs to be handled in a similar ways as those:
https://github.com/r0man/sqlingvo/blob/master/src/sqlingvo/compiler.clj#L522
You can add it yourself or send a PR with proper tests ...
I think something like
(defarity compile-whitespace-args
"date_sub")
should do the trick.
Thanks r0man! Sorry for not getting back with you sooner.
For the record, the defarity approach produces: date_sub(now() interval 1 hour
, however the desired output is actually: date_sub(now(), interval 1 hour
. Note the added comma after now().
I ended up going with a different approach (using timediff and time_to_sec), so I'll close the issue as a suitable workaround to the INTERVAL syntax already exists.