Thanks for the feedback request.
When I use clojure.contrib.sql, I use it for its DML only -- no create/drop
table, etc. I usually manage the DDL outside of Clojure base using (for
example) Liquibase so I can get rollbacks and branching easily. Perhaps DML
can be factored out into a separate namespace? Also, I am not interested in
building statements in Clojure sexps, for example I am quite happy using
clojure.contrib.sql like this, which I personally find readable:
(with-connection *connection*
...
(do-prepared "
insert into password_reset (user_id, token)
select id, ? from user where user.email = ?
on duplicate key
update token = ?, creation_date = now()"
[token username token])
token)))
I suggest not getting into the SQL in sexps/naming strategies business.
That kind of thing doesn't really fall under the scope of JDBC, which
clojure.java.jdbc should be modeled around.
update-or-insert-values can probably be removed as it currently contains a
race condition depending on the transaction isolation level. One has to use
a vendor specific feature (on duplicate key update in MySQL, merge in Oracle
etc.).
The row as a structmap works well. 90% of the time I use use "select foo_bar
as \"foo-bar\"..." to get a Clojure-ish map key. Other 10% I might also
have to apply a transformation to the row, especially when working with
legacy databases. I thought having something like:
(with-query-results rs transform-fn ["
..." params...]
(first rs))
So that by the time I call (first rs), transform has already been applied,
but (map transform-fn rs) is trivial enough also.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en