On Tue, Nov 30, 2010 at 12:00 PM, LauJensen <lau.jen...@bestinclass.dk> wrote:
> @Janico:
>
> Since we allow strings as arguments to most functions, I think you
> could simple express it like so:
>
> clojureql.core> (defn st-intersects [loc poly]
>                      (format "ST_Intersects(%s,
> ST_GeographyFromText('SRID=4326;POLYGON((%s))')"
>                              (name loc)
>                              (join-str ", " poly)))
> #'clojureql.core/st-intersects
> clojureql.core> (-> (table :place)
>                    (select (where (st-intersects :location [15, 20,
> 25, 30])))
>                    to-sql)
> ["SELECT place.* FROM place WHERE ST_Intersects(location,
> ST_GeographyFromText('SRID=4326;POLYGON((15, 20, 25, 30))')"]
>
> Would that work for you?

Yes, that works nicely. Thank you. I didn't realize you could use a
function that returns a string as a predicate.

Janico

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

Reply via email to