Task #10974 (new)
Opened 6 years ago
Last modified 6 years ago
RFE: BlitzGateway.getObjects(???, []) returns an unhelpful error
| Reported by: | spli | Owned by: | wmoore |
|---|---|---|---|
| Priority: | minor | Milestone: | Unscheduled |
| Component: | API | Version: | n.a. |
| Keywords: | n.a. | Cc: | python-team@… |
| Resources: | n.a. | Referenced By: | n.a. |
| References: | n.a. | Remaining Time: | n.a. |
| Sprint: | n.a. |
Description
It would be nice if the following could return a clearer exception message or even better, return an empty list (which would be the same behaviour as when a non-existent ID is passed to getObjects).
list(conn.getObjects('Image', []))
serverExceptionClass = ome.conditions.ApiUsageException
message = unexpected end of subtree [select obj from ome.model.core.Image obj join fetch obj.details.owner as owner join fetch obj.details.group join fetch obj.details.creationEvent where obj.id in ()]; nested exception is org.hibernate.hql.ast.QuerySyntaxException: unexpected end of subtree [select obj from ome.model.core.Image obj join fetch obj.details.owner as owner join fetch obj.details.group join fetch obj.details.creationEvent where obj.id in ()]
Change History (4)
comment:1 Changed 6 years ago by jamoore
comment:2 Changed 6 years ago by wmoore
Since getObjects() actually returns a generator, so we want to return an "empty" generator, or is it OK to return [].
Both will be handled identically in most cases, E.g.
list(conn.getObjects('Image', []))
# or
for i in conn.getObjects('Image', []):
print i
To get an "empty" generator I think you have to do something like this (which seems a bit contrived!).
def emptyGen():
for i in []:
yield i
return emptyGen()
comment:3 Changed 6 years ago by jamoore
if False: yield would work, too. I don't know if any assumptions would be violated with "return []". Probably best to use a generator.
comment:4 Changed 6 years ago by wmoore
- Owner set to wmoore
This is a very long-standing Hibernate issue: https://hibernate.atlassian.net/browse/HHH-2045
which has *amazingly* recently been fixed. We won't be upgrading to that version of Hibernate soon, and especially not on the stable line. The background issue is that the server can't know a priori (without parsing the queries) know if the user is intending the list to be us in a "in (:ids)" style query.
A method like getObjects() though can definitely check for an empty list of IDs and return immediately.