Age | Commit message (Collapse) | Author |
|
The `having` function duplicated the intended functionality of `select`, but in
a bad way. It only applied to a restricted case, and its existence meant that
`select` provided an escape-hatch with which we could cause some unexpected
behaviour. By consolidating the two functions into `select` we remove the
escape hatch as well as simplify the model.
Selection on grouped queries may now introduce a new subquery, but only in
situations where the behaviour is unpredictable (ie. selecting on non-grouped
attributes).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The compiler handled them by converting most things to strings and embedding
them in the query, but now I'm trying to put more of them in as query
parameters. The advantage is that his handles types that might be database
specific, or something.
At the moment sequences are handled in the same way as before (with each
element being a separate parameter), but this may be changed in future.
|
|
When converting dotted fields to maps there's one possible case where it can do
the wrong thing. This should now throw an AssertionError rather than silently
doing the wrong thing.
|
|
|
|
Essentially just prefixes a subobject name in front of all fields in a query,
with a dot separating the new prefix and the original name.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Also: the fix I mentioned in my last commit message may be a little bit hard to
do, but even without explicitly detecting it it will explode in an obvious way.
|
|
So now something like this:
(-> (table :users)
(project {:id :user.id, :email :user.email, :person :person.id})
(join (-> (table :people)
(project {:id :person.id, :first-name :person.first-name}))))
will result in a map like this for each result:
{:user {:id 1, :email "..."}, :person {:id 1, :first-name "..."}}
Although I've just thought of an issue that will need to be detected where an
error should be thrown. I'll deal with that now and commit it soon.
|
|
|
|
|
|
|
|
|
|
In the compiler there was one call to `table-name` which should have been
`field-name`.
|
|
|
|
|
|
|
|
|
|
Add take and drop functionality to the queries, so now you can use the take and
drop functions in a similar way to how they work on seqs in clojure.
Move jdbc interface stuff into clojure-sql.jdbc, so if you're using jdbc you
can include it yourself. (If you're not using jdbc then it shouldn't bother
you).
Given the default compilation target is actually postgres, document that.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
n-ary operators with no arguments would break everything (compiling to "()").
This should no longer be the case. Additionally, unary operators (ie. negation)
now compile properly in the one arg case.
Operator aliases allow us to change how we refer to things like the "~" regex
operator in postgresql. At the moment it's aliased as "$".
Additionally: booleans now compile to upper case.
|
|
Fix compilation of cross joins.
Remove the sort clauses on queries when they become subqueries in joins because
then the sorting means nothing (although when take/drop stuff is added the sort
will be relevant, so we'll see about that).
Favour the left side of a join, which is mostly only relevant for the outer
join case (and technically it's not quite right for full-outer joins, maybe,
but I'll get to that later).
|
|
`sort-by` is now called `sort`. This is just because I think it makes more
sense and nothing more.
Grouping has been added with `group` and `having`. They behave as you'd expect
from SQL, except that joining with a table which has a `group` or `having`
clause will move that query in as a subquery. I wasn't sure how else to ensure
their composition, so this way maintains the semantics (which is the most
important part) at the potential cost of some efficiency in performing the
query. I'm not sure that there exists a more general solution. I would assume
not.
The join stuff has been fixed a bit (some valid renames were rejected as
invalid) and standardised a bit (exceptions are now more similar). A bunch of
things have been added to the join stuff as a result of the above grouping
things, too. A bunch of changes all around, basically.
The compiler has also had a few small changes made to it, and has been enhanced
to support the grouping stuff.
|
|
|