Upgrade job manager's index_query method to SA2.0 #17020
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SQLAlchemy 2.0 compatibility upgrades. Ref #12541. Extracted from #16852.
Two notable edits:
Select
statement creates aCompoundSelect
object; executing it will return tuples of column values, not models. This causes a problem because the method is expected to return models in all cases. To ensure the method always returns models (regardless of whether the union is called or not), I usedaliased()
to map theJob
model to theCompoundSelect
object.UNION
andORDER BY
causes problems in SQLite. More details here: SQLAlchemy 2.0 upgrades (part 4) #16852 (comment). Solution: instead of using theJob
class to access the column collection, useJob
only if workflow jobs have not been added to the statement (andUNION
has not been applied). Otherwise use the subquery produced by the union.I've restructured the method - I think it's easier to follow its query-building logic this way. But if that's not the case, I'll drop the last commit.
How to test the changes?
(Select all options that apply)
License