-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit principally fixes issues with distinct queries. Since refactoring for sqlalchemy 1.4, the query has been initialised with a starting "dummy" projection from which to join. ```python query = session.query(starting_table.id) ``` The returned projection was then removed. This is problematic, though, when requesting distinct result rows, because the dummy projection is also used to calculate uniqueness. This has now been changed to use the `select_from` method: https://docs.sqlalchemy.org/en/14/orm/query.html#sqlalchemy.orm.Query.select_from, such that now we can initialise without any projection. ```python query = session.query().select_from(starting_table) ``` The backend QueryBuilder code is also refactored, principally to make the `SqlaQueryBuilder._build` logic more understandable. Cherry-pick: 9fa2d88
- Loading branch information
1 parent
8b55a2a
commit 7a4532e
Showing
8 changed files
with
614 additions
and
531 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
'SELECT db_dbnode_1.id, db_dbnode_1.uuid \nFROM db_dbnode AS db_dbnode_1 \nWHERE CAST(db_dbnode_1.node_type AS VARCHAR) LIKE %(param_1)s AND CASE WHEN (jsonb_typeof((db_dbnode_1.extras #> %(extras_1)s)) = %(jsonb_typeof_1)s) THEN (db_dbnode_1.extras #>> %(extras_1)s) = %(param_2)s ELSE %(param_3)s END' % {'param_1': '%', 'extras_1': ('tag4',), 'jsonb_typeof_1': 'string', 'param_2': 'appl_pecoal', 'param_3': False} | ||
'SELECT db_dbnode_1.uuid \nFROM db_dbnode AS db_dbnode_1 \nWHERE CAST(db_dbnode_1.node_type AS VARCHAR) LIKE %(param_1)s AND CASE WHEN (jsonb_typeof((db_dbnode_1.extras #> %(extras_1)s)) = %(jsonb_typeof_1)s) THEN (db_dbnode_1.extras #>> %(extras_1)s) = %(param_2)s ELSE %(param_3)s END' % {'param_1': '%', 'extras_1': ('tag4',), 'jsonb_typeof_1': 'string', 'param_2': 'appl_pecoal', 'param_3': False} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
SELECT db_dbnode_1.id, db_dbnode_1.uuid | ||
SELECT db_dbnode_1.uuid | ||
FROM db_dbnode AS db_dbnode_1 | ||
WHERE CAST(db_dbnode_1.node_type AS VARCHAR) LIKE '%%' AND CASE WHEN (jsonb_typeof((db_dbnode_1.extras #> '{tag4}')) = 'string') THEN (db_dbnode_1.extras #>> '{tag4}') = 'appl_pecoal' ELSE false END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
SELECT db_dbnode_1.id, db_dbnode_1.uuid | ||
SELECT db_dbnode_1.uuid | ||
FROM db_dbnode AS db_dbnode_1 | ||
WHERE CAST(db_dbnode_1.node_type AS VARCHAR) LIKE 'data.core.structure.%%' AND CAST((db_dbnode_1.extras #> '{elements}') AS JSONB) @> '["Si"]' |