Ryan,

FYI - The date comparison syntax appears to work fine under h2, but throws a 
exception on PSQL.  

Here’s my function

(defn calendar
  [request]
  (controller/render
    (assoc request
      :currentdate (java.util.Date.)
      :videos (model/gather :video {:where {:unlock-date {:<= 
(java.util.Date.)} :campaign_id 1}}))))


Here’ the error message:

PSQLException Can't infer the SQL type to use for an instance of 
org.joda.time.DateTime. Use setObject() with an explicit Types value to specify 
the type to use.  org.postgresql.jdbc2.AbstractJdbc2Statement.setObject 
(AbstractJdbc2Statement.java:1801)

Any ideas?

Thanks!
Marcus



On Nov 18, 2013, at 12:31 PM, Ryan Spangler <ryan.spang...@gmail.com> wrote:

> I just ran this in the Caribou repl:
> 
>     (caribou.model/gather :field {:where {:created-at {:<= (java.util.Date.)} 
> :model-id 1}})
> 
> And got a bunch of results.  No string coercion necessary!  (also, dashes not 
> underscores!)
> 
> We looked at Korma and found it lacking (similar problem as Compojure: 
> macros).  For that reason we built an entire query engine that works on data 
> directly, so that you can build up queries programmatically just like you 
> would any other data structure (!)
> 
> Check out the section on retrieving content here:  
> http://caribou.github.io/caribou/docs/content.html
> 
> You can do a bunch of cool stuff (logic operations, "in" queries, conditions 
> that span associations, selecting certain fields, seamless queries over join 
> tables etc).  
> 
> Let me know if there is something you expect out of a query engine that 
> Caribou doesn't do, we will add it (if it makes sense!)
> 
> All this stuff is in caribou-core (which you can use independently of the 
> rest of Caribou): https://github.com/caribou/caribou-core
> 
> Maybe I should call it something else to emphasize it is a standalone 
> library... (and replacement for korma)
> 
> 
> On Mon, Nov 18, 2013 at 11:07 AM, Marcus Blankenship <mar...@creoagency.com> 
> wrote:
> 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 <craft.br...@gmail.com> 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 <craft...@gmail.com> 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 <waldema...@googlemail.com> 
>>> 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 <craft...@gmail.com>:
>>>> 
>>>>> 
>>>>> 
>>>>> 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 clo...@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+u...@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+u...@googlegroups.com.
>>>>> 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 clo...@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+u...@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+u...@googlegroups.com.
>>>> 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 clo...@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+u...@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+u...@googlegroups.com.
>>> 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 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.
> 
> 
> 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 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 a topic in the Google 
> Groups "Clojure" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/clojure/ZxUUBlYf1ck/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> clojure+unsubscr...@googlegroups.com.
> 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 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.

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 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