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

Using 'order by' gives InvalidSortExpression #20

Open
ChristianTellefsen opened this issue Jan 9, 2012 · 1 comment
Open

Using 'order by' gives InvalidSortExpression #20

ChristianTellefsen opened this issue Jan 9, 2012 · 1 comment

Comments

@ChristianTellefsen
Copy link
Contributor

Order by seems to be broken.

Running a query like this:

Query q = em.createQuery("select e from SomeTable e where e.somefield = :somefield order by e.score desc");

Will send a query like this to Amazon:

[INFO ] com.amazonaws.request: Sending Request: POST http://sdb.amazonaws.com / Parameters: (ConsistentRead: true, Action: Select, Version: 2009-04-15, SelectExpression: select count(*) from SomeDomain-SomeTable where somefield = 'somevalue' order by score desc, )

Which gives this error:

[INFO ] com.amazonaws.request: Received error response: Status Code: 400, AWS Request ID:XXX, AWS Error Code: InvalidSortExpression, AWS Error Message: Invalid sort expression. The sort attribute must be present in at least one of the predicates, and the predicate cannot contain the is null operator.
javax.persistence.PersistenceException: Status Code: 400, AWS Request ID: XXX, AWS Error Code: InvalidSortExpression, AWS Error Message: Invalid sort expression. The sort attribute must be present in at least one of the predicates, and the predicate cannot contain the is null operator.
at com.spaceprogram.simplejpa.query.AbstractQuery.getResultList(AbstractQuery.java:216)
at com.spaceprogram.simplejpa.query.QueryImpl.getCount(QueryImpl.java:369)
at com.spaceprogram.simplejpa.LazyList.size(LazyList.java:75)

Running the exact same query without the 'order by e.score desc' clause works without error. I guess the error might have to do with passing the order by clause to AWS when doing a count.

I'm getting this issue both in the 1.6 snapshot and in the AWS SDK .jar.

@ChristianTellefsen
Copy link
Contributor Author

I added a fix for this issue in my fork, and it seems to work.

I'm unable to run all the tests, though, so it's hard to say whether I broke anything. The same number of tests are broken before and after the change, at least...

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