google-code-export / morphia

Automatically exported from code.google.com/p/morphia
1 stars 0 forks source link

Morphia should fail when .or() is used twice #292

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
morphia-0.99.jar, mongo-java-driver-2.5.3.jar, mongodb-10gen 1.8.1

MongoDB does not allow to have multiple "$or" conditions and Morphia just 
silently uses the last "$or" condition applied. Surprisingly enough, the rich 
Query API builds the whole query structure and then just blindly sets the "$or" 
field when building MongoDB query DBObject.

This should be detected either when
a) When building MongoDB object (which is relatively easy - you just have to 
check "$or" field before setting it)
b) When .or() is called.

I think that throwing UnsupportedOperationException is adequate response in 
this case.

Original issue reported on code.google.com by Pasko.Bo...@gmail.com on 29 Jun 2011 at 7:48