Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for java.util.Collections$SingletonList #24

Open
danpolites opened this issue Oct 7, 2014 · 0 comments
Open

Add support for java.util.Collections$SingletonList #24

danpolites opened this issue Oct 7, 2014 · 0 comments

Comments

@danpolites
Copy link

An UnsupportedOperationException is thrown when using a SingletonList in an '$in' query when using the Grails Mongo Gorm plugin. Grails has this odd behavior where you get a SingletonList when converting an http parameter to a list (params.list('userIds')) on a one item parameter. In the cases where you have multiple items in the parameter you get an ArrayList, which works fine with gmongo. The work around is to use a mutable list or cast the value to a string array.

Here is an example of a Mongo Gorm call that would fail if the collection is a SingletonList
User.collection.find([_id: ['$in': singletonListOfIds]])

java.lang.UnsupportedOperationException
    at java.util.AbstractList.set(AbstractList.java:132)
    at com.gmongo.internal.Patcher$__converAllCharSeqToString_closure2_closure4.doCall(Patcher.groovy:89)
    at com.gmongo.internal.Patcher$__converAllCharSeqToString_closure2.doCall(Patcher.groovy:87)
    at com.gmongo.internal.Patcher._converAllCharSeqToString(Patcher.groovy:84)
    at com.gmongo.internal.Patcher$__converAllCharSeqToString_closure2.doCall(Patcher.groovy:102)
    at com.gmongo.internal.Patcher._converAllCharSeqToString(Patcher.groovy:84)
    at com.gmongo.internal.Patcher$__converAllCharSeqToString_closure2_closure4.doCall(Patcher.groovy:93)
    at com.gmongo.internal.Patcher$__converAllCharSeqToString_closure2.doCall(Patcher.groovy:87)
    at com.gmongo.internal.Patcher._converAllCharSeqToString(Patcher.groovy:84)
    at com.gmongo.internal.Patcher$__converAllCharSeqToString_closure2.doCall(Patcher.groovy:102)
    at com.gmongo.internal.Patcher._converAllCharSeqToString(Patcher.groovy:84)
    at com.gmongo.internal.Patcher._convert(Patcher.groovy:73)
    at com.gmongo.internal.Patcher._convert(Patcher.groovy:69)
    at com.gmongo.internal.Patcher$__patchInternal_closure1.doCall(Patcher.groovy:32)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant