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

Incongruent exception on primary expressions #43

Closed
Nachintoch opened this issue Mar 27, 2018 · 2 comments
Closed

Incongruent exception on primary expressions #43

Nachintoch opened this issue Mar 27, 2018 · 2 comments

Comments

@Nachintoch
Copy link
Contributor

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

@andyjefferson
Copy link
Member

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

@andyjefferson
Copy link
Member

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

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

2 participants