Re: ClojureQL: debugging generated SQL / Dates

2011-07-28 Thread Brian Marick

On Jul 27, 2011, at 7:26 PM, Brian Marick wrote:
 How *does* one provide dates to ClojureQL for transmission to Postgres?  I 
 want to do something like this:
 
 (ql/conj! (ql/table :animals) {:official_name fred :added_to_service 
 something that counts as a SQL Date})

Boy I was dumb yesterday:


user (ql/conj! (ql/table :animals)
{:official_name fred
:added_to_service (Date. (.getMillis (DateMidnight.)))})


-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick

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


Re: ClojureQL: debugging generated SQL / Dates

2011-07-28 Thread Meikel Brandmeyer
Hi,

Am 28.07.2011 um 21:10 schrieb Brian Marick:

 
 On Jul 27, 2011, at 7:26 PM, Brian Marick wrote:
 How *does* one provide dates to ClojureQL for transmission to Postgres?  I 
 want to do something like this:
 
 (ql/conj! (ql/table :animals) {:official_name fred :added_to_service 
 something that counts as a SQL Date})
 
 Boy I was dumb yesterday:
 
 
 user (ql/conj! (ql/table :animals)
{:official_name fred
:added_to_service (Date. (.getMillis (DateMidnight.)))})

Maybe just (.toDate (DateMidnight.))?

Sincerely
Meikel

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


ClojureQL: debugging generated SQL / Dates

2011-07-27 Thread Brian Marick
I'm trying to figure out how to send a jodatime date into Postgres, for example 
to generate this SQL:

SELECT animals.* FROM animals WHERE removed_from_service = '2001-11-11'

Along the way, I've discovered that the SQL queries ClojureQL prints out can't 
be the ones it actually sends. Consider, for example, this:

user (ql/select (ql/table :animals)
 (ql/where (in :official_name [1 2 2])))
SELECT animals.* FROM animals WHERE official_name IN (1,2 2)

If you run the query, it seems to work. But that SELECT won't work if you type 
it at Postgres. The correct syntax should be:

SELECT animals.* FROM animals WHERE official_name IN ('1','2 2')

Is the REPL command I typed not the right way to see what SQL is sent to the 
database?

How *does* one provide dates to ClojureQL for transmission to Postgres?  I want 
to do something like this:

(ql/conj! (ql/table :animals) {:official_name fred :added_to_service 
something that counts as a SQL Date})

-
Brian Marick, Artisanal Labrador
Contract programming in Ruby and Clojure
Occasional consulting on Agile
www.exampler.com, www.twitter.com/marick

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