On Tue, Sep 17, 2013 at 02:28:08AM -0700, Daniel Neal wrote:
> I'd be interested in knowing some more about your approach compared to that 
> of ClojureQL and the motivation behind it.

Sure!

The basic difference is that I tried to be a little bit more rigid in
how queries must be constructed. I tried to ensure that the generated
queries weren't just valid SQL, but that they were also sensible and
unambiguous (or, if there isn't enough information to make a sensible,
unambiguous, query, that it throws an exception).

As an example, in ClojureQL you can create the following query, which
will compile into a query without any issue:

  (join (table :users) (table :people) (where (= :uid :pid)))

but the result of this query (or even the structure of the result) is
difficult to determine by examining the code. Even worse, because the
:uid and :pid aren't from either table explicitly, this could fail on
the database if both tables have a :uid or :pid field.

The equivalent query in clojure-sql,

  (join (table :users) (table :people) :on `(= :uid :pid))

will fail, telling you there's an ambiguous field :uid in the query. If
you disambiguate :uid (by projecting :uid in either of the tables) then
it will complain about :pid.



My ideal is that you could treat a query as some opaque object about
which you can only know two things: the "shape" of the data it
specifies, and (after executing the query) the data that it specifies.
You should then be able to arbitrarily apply clojure-sql functions to
those queries to produce new opaque queries without any concern about
how the subqueries were produced (with each of the functions causing a
known, predictable, effect on the execution result).

At the moment this should be true of all the relational operators
(project/select/rename/join), the set operations (union/intersection)
and some other operations (take/drop/sort) but it's not true of the
grouping operations (group/having).


Carlo

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to