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

Null clause #56

Open
infinity-computers-dot-net opened this issue Apr 22, 2021 · 3 comments
Open

Null clause #56

infinity-computers-dot-net opened this issue Apr 22, 2021 · 3 comments

Comments

@infinity-computers-dot-net

I don't know if anyone's actually maintaining this package anymore, but I looked at the source and can't figure out how to solve it.

The problem here is sometimes I want to use a where or limit clause, and sometimes I don't. So given that select is a macro, how do I selectively include or exclude a clause?

Here's what I tried:

(defun select-from-db (my-limit my-where)
 (select columns
  (from mytable)
  (and my-limit (where my-limit)
  (and my-where (limit my-where)))

The idea being that I can pass nil for these values, and have the clauses omitted. But this doesn't work. The package complains that "you can't have null twice" or some such.

Without duplicating my code four times, how can I selectively include or exclude clauses?

@infinity-computers-dot-net
Copy link
Author

For what it's worth, I tried quasi-quote tricks; I tried writing my own macro wrapper around select, and I tried assembling an argument list at runtime. Nothing helped, because select is a macro.

@fukamachi
Copy link
Owner

I didn't notice this doesn't work while using SxQL with Mito because Mito's select-dao ignores null clauses.
It would be good if SxQL's select macro also works like it.

@Mr-Dispatch
Copy link

https://github.com/mmontone/sxql-composer might help in the meantime

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

3 participants