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 the same type is appended to the QueryBuilder twice (with difference filter clauses etc.), the order_by statement appears to have no effect.
Minimal example
Running the following code, the result does not respect the ctime ordering:
fromaiidaimportormfromaiida.engineimportcalcfunction@calcfunctiondefadd(x, y):
returnx+yx=orm.Int(1).store() # explicitly storing so that I know the order of creationy=orm.Int(3).store()
z=orm.Int(5).store()
c=add(add(x, y), z)
qb=orm.QueryBuilder()
qb.append(orm.Int, filters={'uuid': c.uuid}, tag='c')
qb.append(orm.Int, with_descendants='c')
qb.order_by({orm.Int: {'ctime': 'desc'}})
print(qb.distinct().all())
A workaround is using the tag and referring to the entity that should be ordered with that, instead of passing the type. If the above is expected behavior, I think the order_by documentation should strongly encourage the use of tags.
The text was updated successfully, but these errors were encountered:
Describe the bug
When the same type is
append
ed to the QueryBuilder twice (with difference filter clauses etc.), theorder_by
statement appears to have no effect.Minimal example
Running the following code, the result does not respect the
ctime
ordering:The printed output is (formatted for readability)
which is in ascending
ctime
order. In fact, switching fromdesc
toasc
has no effect.Counterexample: using a different type
Using a different type for the two
append
statements, the ordering works as expected:Result:
Environment
develop
(477fe30), Django backendWorkaround
A workaround is using the
tag
and referring to the entity that should be ordered with that, instead of passing the type. If the above is expected behavior, I think theorder_by
documentation should strongly encourage the use of tags.The text was updated successfully, but these errors were encountered: