Lift Mongo driver interpreting hex strings as ObjectIds

23 views
Skip to first unread message

Matt Farmer

unread,
Jun 7, 2012, 6:02:15 PM6/7/12
to lif...@googlegroups.com
Hey everybody,

So, I know this was brought up on the list before (https://groups.google.com/d/topic/liftweb/Aw0dDLyJMqo/discussion) - but I'm interested in finding out if there has been any progress or consideration made in moving toward a more accurate check distinguish ObjectIds and Strings. We've been having some serious issues with this over the past weeks because, as you might expect, if the Scala model is expecting to find a string for a particular field name and instead finds an ObjectId - things get hairy. And by hairy, I mean Exceptions getting thrown and users seeing errors or infinite loading spinners (no fun for anyone).

There was mention in the referenced thread that the existing ObjectId.isValid check was left in the code for backward compatibility, which I understand, but this has become an increasingly common problem for computer science themed chats on our site where discussion might occasionally wander to 24 character hex identifiers. Also, if there are any solutions for getting around this with the current Lift codebase, I'd love to hear them.

Cheers,
Matt

Antonio Salazar Cardozo

unread,
Jun 7, 2012, 6:04:41 PM6/7/12
to lif...@googlegroups.com
One thing we could do is change the ObjectId.isValid call to something that can be changed by the developer, along the lines of LiftRules? Obviously the default would remain a call to ObjectId.isValid, but for this case it could be overridden with a (string) => false so ObjectIds are never converted.

Does that seem reasonable, or would we have to do it another way?
Thanks,
Antonio

Tim Nelson

unread,
Jun 7, 2012, 6:26:05 PM6/7/12
to lif...@googlegroups.com
That's sounds like a great solution. I'll have MongoDB extend Factory and add a FactoryMaker for the ObjectId.isValid call.


I'll try to get this done over the weekend.

Tim

Antonio Salazar Cardozo

unread,
Jun 7, 2012, 7:04:06 PM6/7/12
to lif...@googlegroups.com
Awesome!
Reply all
Reply to author
Forward
0 new messages