[Cl-perec-devel] Idea to query language

Makarov Alexey alexeys9 at mail.ru
Fri Dec 12 19:10:02 UTC 2008

I have an idea about query language.
Often I write conditions for querying objects that contains in their
slots (objects have the same class) one of values containing in the
list, and form "from" of query turn into long form "or" (or (eq slot 1)
(eq slot 2) ...), i create function that construct this condition:

(defun in (slot-name values)
`(or ,@(mapcar (lambda (v) `(eq (quote ,slot-name) ,v)) values)))

Then I can write:

(eval `(with-transaction
     (select (p)
       (from (o rank))
       (where ,(in 'name '("one" "two" "three"))))))

in PostgreSQL query language this presented as:

FROM class_table
WHERE slot IN VALUES (1::int,2,3)


In databases that query languages support this syntax construction,
transform this as is,
in databases that query language not support this syntax, extract to
long form "OR".

As I know this feature included in SQL standard.

Maybe this would be worth to include as form in cl-perec query language?
We will can be use it without quote and outer "eval".
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/cl-perec-devel/attachments/20081213/14a1370f/attachment.html>

More information about the cl-perec-devel mailing list