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

Querying mongodb with MongoEntity after updating with low level api results in readDateTime error #9

Closed
idonaldson opened this issue Aug 24, 2016 · 4 comments

Comments

@idonaldson
Copy link

Running into an issue with querying my user collection now that I've transitioned all my updates to low level mongodb and I'm not using grails built in user.save() method. I've looked at the users in the database with MongoHub and everything looks as it should.
Here's the criteria search:
def c = User.createCriteria() User user = c.get { or { and { eq "email", emailUsernameCommand.emailUsername eq "password", passEncrypted } and { eq "username", emailUsernameCommand.emailUsername eq "password", passEncrypted } } }
New accounts work normally, previously created accounts are generating the following error.
ERROR AccountService - Unable to authenticate user test : readDateTime can only be called when CurrentBSONType is DATE_TIME, not when CurrentBSONType is STRING. org.bson.BsonInvalidOperationException: readDateTime can only be called when CurrentBSONType is DATE_TIME, not when CurrentBSONType is STRING. at org.bson.AbstractBsonReader.verifyBSONType(AbstractBsonReader.java:655) at org.bson.AbstractBsonReader.checkPreconditions(AbstractBsonReader.java:687) at org.bson.AbstractBsonReader.readDateTime(AbstractBsonReader.java:288) at org.grails.datastore.mapping.mongo.engine.codecs.PersistentEntityCodec$SimpleDecoder$8.decode(PersistentEntityCodec.groovy:670) at org.grails.datastore.mapping.mongo.engine.codecs.PersistentEntityCodec$SimpleDecoder.decode(PersistentEntityCodec.groovy:721) at org.grails.datastore.mapping.mongo.engine.codecs.PersistentEntityCodec$SimpleDecoder.decode(PersistentEntityCodec.groovy) at org.grails.datastore.mapping.mongo.engine.codecs.PersistentEntityCodec.decode(PersistentEntityCodec.groovy:159) at com.mongodb.operation.CommandResultArrayCodec.decode(CommandResultArrayCodec.java:48) at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:53) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:81) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:40) at org.bson.codecs.configuration.LazyCodec.decode(LazyCodec.java:47) at org.bson.codecs.BsonDocumentCodec.readValue(BsonDocumentCodec.java:98) at com.mongodb.operation.CommandResultDocumentCodec.readValue(CommandResultDocumentCodec.java:56) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:81) at org.bson.codecs.BsonDocumentCodec.decode(BsonDocumentCodec.java:40) at com.mongodb.connection.CommandProtocol.execute(CommandProtocol.java:123) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:159) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:286) at com.mongodb.connection.DefaultServerConnection.command(DefaultServerConnection.java:173) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:215) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:206) at com.mongodb.operation.CommandOperationHelper.executeWrappedCommandProtocol(CommandOperationHelper.java:112) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:485) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:480) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:212) at com.mongodb.operation.FindOperation.execute(FindOperation.java:480) at com.mongodb.operation.FindOperation.execute(FindOperation.java:77) at com.mongodb.Mongo.execute(Mongo.java:772) at com.mongodb.Mongo$2.execute(Mongo.java:759) at com.mongodb.OperationIterable.iterator(OperationIterable.java:47) at com.mongodb.FindIterableImpl.iterator(FindIterableImpl.java:143) at org.grails.datastore.mapping.mongo.query.MongoQuery.executeQuery(MongoQuery.java:1019) at org.grails.datastore.mapping.mongo.query.MongoQuery.executeQuery(MongoQuery.java:882) at org.grails.datastore.mapping.query.Query.list(Query.java:567) at org.grails.datastore.mapping.query.Query.singleResult(Query.java:585) at grails.gorm.CriteriaBuilder.get(CriteriaBuilder.java:297) at org.grails.datastore.mapping.query.api.BuildableCriteria$get.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:125)

@jameskleeh
Copy link
Contributor

There is a property in one of the documents in question called "readDateTime" that is of type string. It needs to be a DATE_TIME.

@idonaldson
Copy link
Author

I've compared my user domain to what I can see in MongoHub for this particular user and everything looks like it should. Is there any way to see which property of the document is throwing the error?

@jameskleeh
Copy link
Contributor

@idonaldson Sorry, I was confused there for a second. The easiest way to tell which property it is is to put a breakpoint at AbstractBsonReader.verifyBSONType and inspect the currentName property

@idonaldson
Copy link
Author

Found the problem, thank you. Issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants