;;from the website you linked
(/fields/  [:firstname  :first]:last  :address.state)
      ;; you can alias a field using a vector of [field alias]

Your vector argument should look like this:
[[:firstname  :first]:last  :address.state]

or like this (if you're not aliasing):

[:firstname  :last  :address.state]

or in your case exactly:
[:id]
[[:id :identity]] ;;with aliasing

is this how your 'fields-vector' looks like?

Jim

ps: I've not looked at the source of 'fields', I may be wrong...




On 26/03/13 20:12, Ryan wrote:
Thank you guys for your answer. apply was the first thing I used but I got the following error:

    java.lang.ClassCastException: clojure.lang.Keyword cannot be cast
    to clojure.lang.Associative


and i thought i am not going the right way. What i am more specifically trying to do is this:

http://sqlkorma.com/docs#select

In the link above, the select example takes a (fields ....) function so, I made the following wrapper because it was convenient to use in my project:

    (defn find-one-row [entity fields-vector where-hash-map]
      (first (select entity (apply fields fields-vector) (where
where-hash-map) (limit 1))))

...but it  throws the error i mentioned

If i hardcode the fields like this, it works fine:

    (defn find-one-row [entity where-hash-map]
      (first (select entity (fields :id) (where where-hash-map) (limit
1))))

Any ideas?


On Tuesday, March 26, 2013 9:51:34 PM UTC+2, Jim foo.bar wrote:

    On 26/03/13 19:28, Ryan wrote:
    > apply the elements of my vector as arguments to the function

    you said it yourself in your first post... :) 'apply' is what you're
    looking for!

    Jim

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



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