[mongoid] Integer field and non numeric strings

39 views
Skip to first unread message

Piotr Jakubowski

unread,
Feb 9, 2012, 1:01:43 PM2/9/12
to Mongoid
Hi,

I am wondering why Integer strings store strings when the string that
you assign is non numeric.
ActiveRecord assigns at that point 0, but in Mongoid when you do
integer_field = "asd" it would actually
save "asd" which is pretty strange behaviour. What is the reasoning
behind that? Shouldn't it
default to 0 if the string is non numeric?

Cheers!

Nick Hoffman

unread,
Feb 11, 2012, 1:32:05 PM2/11/12
to mon...@googlegroups.com
Hey Piotr. Mongoid should try to cast the string to an integer (Eg: "4asdf" becomes 4), or just store 0. Could you open an issue in GitHub for this, please?

brahmana

unread,
Feb 13, 2012, 2:13:30 AM2/13/12
to Mongoid
Reply all
Reply to author
Forward
0 new messages