Storm accepts order_by clauses that mention columns not present in the output
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Storm |
New
|
Undecided
|
Unassigned |
Bug Description
Storm accepts order_by clauses that mention columns not present in the output, when this should at least generate a SQL error if not a Storm exception.
For example:
def getBuilds(self, pending=False):
"""See `ISourcePackage
if pending:
clauses = [BuildFarmJob.
else:
clauses = [BuildFarmJob.
# Use subselect as a workaround for Storm bug #674582.
and_clause = And(
subselect = Select(
result = Store.of(
return result
Note that BuildFarmJob is not mentioned in Store.find, only the subselect. Therefore, sorting by it is not feasible. However, Storm emits this SQL:
SELECT SourcePackageRe
The FROM clause includes BuildFarmJob, but it really shouldn't, because BuildFarmJob is only included in the ORDER BY. ORDER BY cannot produce sensible results when the table column is is not mentioned elsewhere, so ORDER BY should not be used to determine which tables to include in the FROM.
Because of this behaviour, ResultSet.count() will give dramatically different behaviour from len(list(