You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to sort a result using a field that is not part of the entity model (perhaps by a typo), when compiling the sort section of the query, the QueryToMongoDBMapper class will eventually reach the processPrimaryExpression method; which calls getFieldNameForPrimary to get the actual name of the field in mongo documents. But since the field isn't registered within the entity contract, the metadata doesn't known it and returns null.
This will cause NucleusException in any case, with an exception message like "Primary Expressions are not supported by this mapper" (since that's the only thing that the super class does), while QueryToMongoDBMapperdoes support primary expressions. Furthermore, there's a log message that warns the user that the field isn't part of the entity, so the sorting won't take place on the datastore, this suggests that the query compilation should be successfull; but the results won't be ordered.
So I'm unsure if this is the desired behaviour, or if a exception with a clearer message should be thrown or if it should just work. In any case, this is very confusing; I really suggest a little attention to this point.
Thanks
The text was updated successfully, but these errors were encountered:
Maybe nobody has entered dodgy field names before, and so never come across it. Easiest way is for you to fork it on GitHub, and add an error trap throwing a NucleusException with sensible message saying explicitly what is the problem. Then contribute it as a PULL REQUEST. Thx
No testcase demonstrating anything, so closing. Can be reopened if complying with basic rules of this project, or if contributing a PR for whatever this is
When trying to sort a result using a field that is not part of the entity model (perhaps by a typo), when compiling the sort section of the query, the QueryToMongoDBMapper class will eventually reach the processPrimaryExpression method; which calls getFieldNameForPrimary to get the actual name of the field in mongo documents. But since the field isn't registered within the entity contract, the metadata doesn't known it and returns null.
This will cause NucleusException in any case, with an exception message like "Primary Expressions are not supported by this mapper" (since that's the only thing that the super class does), while QueryToMongoDBMapper does support primary expressions. Furthermore, there's a log message that warns the user that the field isn't part of the entity, so the sorting won't take place on the datastore, this suggests that the query compilation should be successfull; but the results won't be ordered.
So I'm unsure if this is the desired behaviour, or if a exception with a clearer message should be thrown or if it should just work. In any case, this is very confusing; I really suggest a little attention to this point.
Thanks
The text was updated successfully, but these errors were encountered: