Keyword values

9 views
Skip to first unread message

Timur

unread,
Oct 13, 2015, 11:20:20 AM10/13/15
to Monger, a Clojure MongoDB driver
Hi all,

Is there a way to preserve keyword values of maps? For instance when I save a map {:k :val} the returned type is {:k "val"}. Is there a way to preserve these as keywords? 

Regards,

Timur 

Michael Klishin

unread,
Oct 13, 2015, 11:22:17 AM10/13/15
to Monger, a Clojure MongoDB driver
2015-10-13 18:11 GMT+03:00 Timur <timur...@gmail.com>:
Is there a way to preserve keyword values of maps? For instance when I save a map {:k :val} the returned type is {:k "val"}. Is there a way to preserve these as keywords? 

There is no. MongoDB is blissfully unaware of keywords and we are unwilling to try attaching
"metadata" to such values to be able to reconstruct them back to keywords after deserialisation.
--

Timur

unread,
Oct 13, 2015, 11:33:00 AM10/13/15
to Monger, a Clojure MongoDB driver
Why did you opt for converting them as plain strings but not keyword strings, e.g., "string" instead of ":string". They are at the end not strings but keywords :) 

Michael Klishin

unread,
Oct 13, 2015, 12:20:40 PM10/13/15
to clojure...@googlegroups.com, Timur


On 13 Oct 2015 at 18:33:01, Timur (timur...@gmail.com) wrote:
> > Why did you opt for converting them as plain strings but not keyword
> strings, e.g., "string" instead of ":string". They are at the
> end not strings but keywords :)

Right, so consider this: you have a map with two keys:

{:a “:a” :b :b}

which, once you load it from MongoDB, would look like

{:a “:a” :b ":b”}

Now, how do you know which value was originally a string and which was a keyword? 

That’s what I mean when I say «we are unwilling to try attaching
"metadata" to such values to be able to reconstruct them back to keywords after deserialisation.»

Storing language-specific values in a data store is not a very wise idea. It *will* trip you up,
the question is when, not if.
--
@michaelklishin, github.com/michaelklishin
Reply all
Reply to author
Forward
0 new messages