Brian,
Yeah, and I realize I’m going to take darts for this, but coming from Django’s
ORM / Rails ActiveRecord makes Korma and these other tools feel like stone-age
tools. I’d rather do it all in SQL than fight something to get out of my way,
or reveal it’s magic.
I know I’m probably not thinking about the problem right, but here’s an example
of something that I still can’t get to work in Korma. Grrrr….
lein-repl commands
(use [`advent2.models.db] :reload-all)
(get-unlocked-videos-for-campaign 1)
models/db.clj function
(defn format-todays-date []
(let [date (java.util.Date.)]
(prn date)
(str \' (.format (java.text.SimpleDateFormat. "yyyy-MM-dd") date) \' )))
(defn get-unlocked-videos-for-campaign [campaign]
(let [c_id (:id campaign)]
(select videos (where {:unlock_date [<= (format-todays-date)] :campaign_id
c_id}))))
output
user=> (get-unlocked-videos-for-campaign 1)
#inst "2013-11-18T19:06:09.595-00:00"
Failure to execute query with SQL:
SELECT "videos".* FROM "videos" WHERE ("videos"."unlock_date" <= ? AND
"videos"."campaign_id" IS NULL) :: ['2013-11-18']
PSQLException:
Message: ERROR: operator does not exist: date <= character varying
Hint: No operator matches the given name and argument type(s). You might need
to add explicit type casts.
Position: 63
SQLState: 42883
Error Code: 0
PSQLException ERROR: operator does not exist: date <= character varying
Hint: No operator matches the given name and argument type(s). You might need
to add explicit type casts.
Position: 63 org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse
(QueryExecutorImpl.java:2102)
On Nov 18, 2013, at 10:23 AM, Brian Craft <[email protected]> wrote:
> Re: korma, and sql dsls, I've been moving between korma, honeysql, and raw
> sql, without being satisfied with any of them. Desirable traits of the db
> layer in my problem domain are 1) eliminating boilerplate (e.g. setting up
> default keys, and indexes, and performing standard joins across relations),
> 2) isolating view layers from data access layers (so the view doesn't need to
> know if a subselect or a join is required to span some relation, for
> example), 3) ability to progressively optimize by dropping back to sql when
> required, 4) ability to safely expose a general purpose query API over the
> data.
>
> korma eliminates a very, very small part of the boilerplate. It's almost not
> worth the effort. Falling back to raw sql smoothly is difficult in korma, and
> I've had to drop it entirely in places where I need performance. Honeysql
> eliminates no boilerplate, but representing queries with data structures does
> make it easy to expose a sql-like query API with db firewalling (by matching
> on the incoming structure). Korma appears to also represent queries as data
> structures, but it's not part of the documented API. You have to
> reverse-engineer it, and I expect it's subject to change.
>
>
> On Monday, November 18, 2013 8:19:28 AM UTC-8, Marcus Blankenship wrote:
> Brian, I certainly will. I’ll type up something later this week as we
> progress. The current pain point is Korma, and generally learning clojure.
>
>
>
>
> On Nov 16, 2013, at 10:25 AM, Brian Craft <[email protected]> wrote:
>
>> Marcus -- I hope you will post updates to the list with your experiences. It
>> would be very interesting.
>>
>> This thread has drifted a bit from (roughly) "What can you do with clojure
>> web tooling?" toward "What can you imagine some day doing with the clojure
>> web tooling of the future?", which are both interesting questions, but have
>> somewhat different audiences. And the answers inform each other.
>>
>>
>> On Friday, November 15, 2013 8:20:32 AM UTC-8, Marcus Blankenship wrote:
>> Me too! Thanks to everyone who’s contributed, it’s been *very* helpful!
>>
>> On Nov 14, 2013, at 10:43 AM, Waldemar Schwan <[email protected]>
>> wrote:
>>
>>> I just want to say that this is one of the most interesting discussions I
>>> followed on this mailing list.
>>>
>>> Thanks to all participants.
>>>
>>> Am 14.11.2013 um 19:24 schrieb Brian Craft <[email protected]>:
>>>
>>>>
>>>>
>>>> On Thursday, November 14, 2013 9:42:52 AM UTC-8, Jonathan Irving wrote:
>>>> I agree with much of what you write James - I'm paid to write rails and
>>>> node.js code, and I'm finding that node is encouraging me to compose
>>>> small components and basically sidestep a lot of the issues that rails
>>>> is designed to address.
>>>>
>>>> Can you give a concrete example?
>>>>
>>>> --
>>>> --
>>>> 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
>>>> ---
>>>> 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 [email protected].
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>> --
>>> --
>>> 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
>>> ---
>>> 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 [email protected].
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>> marcus blankenship
>> \\\ Partner, Problem Solver, Linear Thinker
>> \\\ 541.805.2736 \ @justzeros \ skype:marcuscreo
>>
>>
>> --
>> --
>> 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
>> ---
>> 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 [email protected].
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> marcus blankenship
> \\\ Partner, Problem Solver, Linear Thinker
> \\\ 541.805.2736 \ @justzeros \ skype:marcuscreo
>
>
> --
> --
> 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
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
marcus blankenship
\\\ Partner, Problem Solver, Linear Thinker
\\\ 541.805.2736 \ @justzeros \ skype:marcuscreo
--
--
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
---
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.