Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Union broken in SQLite #40

Open
rmhsilva opened this issue Feb 17, 2017 · 3 comments
Open

Union broken in SQLite #40

rmhsilva opened this issue Feb 17, 2017 · 3 comments

Comments

@rmhsilva
Copy link

The union family of commands generate parentheses, which are invalid in SQLite.

e.g. from README

(union-queries
 (select (:name :birthday) (from :fulltime))
 (select (:name :birthday) (from :parttime)))
;=> #<SXQL-OP: (SELECT name, birthday FROM fulltime) UNION (SELECT name, birthday FROM parttime)>

For SQLite, this should generate:

SELECT name, birthday FROM fulltime UNION SELECT name, birthday FROM parttime

Without the brackets around the SELECT statements.

@jackcarrozzo
Copy link

You can fix this by removing the parens on line 208 of src/operator.lisp:

;; original format string is ~~{(~~A)~~^ ~a ~~}
(append (list (format nil ,(format nil "~~{~~A~~^ ~a ~~}" keyword)

And lo,

SXQL> (yield (union-queries
                              (select (:name :birthday) (from :fulltime))
                              (select (:name :birthday) (from :parttime))))
"SELECT name, birthday FROM fulltime UNION SELECT name, birthday FROM parttime"
NIL
SXQL> 

@jackcarrozzo
Copy link

FWIW- I checked that the new syntax (lacking parens) is compatible with mysql and postgres too - it is. I'm happy to submit a PR but someone is going to have to show me how to run the tests, cuz I've only figured out how to test one file at a time.

@rmhsilva
Copy link
Author

Ahaa, nice. I had a quick look through the code to try and figure out where they parens were coming from, but gave up pretty quickly because I don't actually need Unions right now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants