-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
♻️ REFACTOR: Move to sqlachemy 1.4 (and v2 API) #5069
Conversation
In 95985f0, I have added an initial trial migration for the querybuilder. def do_execute(self, cursor, statement, parameters, context=None):
> cursor.execute(statement, parameters)
E sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedTable) invalid reference to FROM-clause entry for table "db_dbnode_2"
E LINE 3: ...b_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_...
E ^
E HINT: There is an entry for table "db_dbnode_2", but it cannot be referenced from this part of the query.
E
E [SQL: SELECT count(*) AS count_1
E FROM (SELECT db_dbnode_1.id AS db_dbnode_1_id, db_dbnode_1.uuid AS db_dbnode_1_uuid, db_dbnode_1.node_type AS db_dbnode_1_node_type, db_dbnode_1.process_type AS db_dbnode_1_process_type, db_dbnode_1.label AS db_dbnode_1_label, db_dbnode_1.description AS db_dbnode_1_description, db_dbnode_1.ctime AS db_dbnode_1_ctime, db_dbnode_1.mtime AS db_dbnode_1_mtime, db_dbnode_1.attributes AS db_dbnode_1_attributes, db_dbnode_1.extras AS db_dbnode_1_extras, db_dbnode_1.repository_metadata AS db_dbnode_1_repository_metadata, db_dbnode_1.user_id AS db_dbnode_1_user_id, db_dbnode_1.dbcomputer_id AS db_dbnode_1_dbcomputer_id
E FROM db_dbnode AS db_dbnode_2, db_dbnode AS db_dbnode_1 JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_2.id JOIN db_dbnode AS db_dbnode_1 ON db_dblink_1.output_id = db_dbnode_1.id
E WHERE CAST(db_dbnode_2.node_type AS VARCHAR) LIKE %(param_1)s AND CAST(db_dbnode_1.node_type AS VARCHAR) LIKE %(param_2)s) AS anon_1]
E [parameters: {'param_1': 'data.%', 'param_2': 'data.%'}]
E (Background on this error at: https://sqlalche.me/e/14/f405)
.tox/py38-django/lib/python3.8/site-packages/sqlalchemy/engine/default.py:717: ProgrammingError when comparing the query statement to that output from diff --git a/x_old.txt b/x_new.txt
index 920060325..ba8541f94 100644
--- a/x_old.txt
+++ b/x_new.txt
@@ -1,3 +1,3 @@
SELECT db_dbnode_1.id AS db_dbnode_1_id, db_dbnode_1.uuid AS db_dbnode_1_uuid, db_dbnode_1.node_type AS db_dbnode_1_node_type, db_dbnode_1.process_type AS db_dbnode_1_process_type, db_dbnode_1.label AS db_dbnode_1_label, db_dbnode_1.description AS db_dbnode_1_description, db_dbnode_1.ctime AS db_dbnode_1_ctime, db_dbnode_1.mtime AS db_dbnode_1_mtime, db_dbnode_1.attributes AS db_dbnode_1_attributes, db_dbnode_1.extras AS db_dbnode_1_extras, db_dbnode_1.repository_metadata AS db_dbnode_1_repository_metadata, db_dbnode_1.user_id AS db_dbnode_1_user_id, db_dbnode_1.dbcomputer_id AS db_dbnode_1_dbcomputer_id
-FROM db_dbnode AS db_dbnode_2 JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_2.id JOIN db_dbnode AS db_dbnode_1 ON db_dblink_1.output_id = db_dbnode_1.id
+FROM db_dbnode AS db_dbnode_2, db_dbnode AS db_dbnode_1 JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_2.id JOIN db_dbnode AS db_dbnode_1 ON db_dblink_1.output_id = db_dbnode_1.id
WHERE CAST(db_dbnode_2.node_type AS VARCHAR) LIKE %(param_1)s AND CAST(db_dbnode_1.node_type AS VARCHAR) LIKE %(param_2)s You can see that it has added an additional alias So my first guess, that even though I do Note there is also a lot of these warnings:
|
this is the query before/after SELECT db_dbnode_1.id, db_dbnode_1.uuid, db_dbnode_1.node_type, db_dbnode_1.process_type, db_dbnode_1.label, db_dbnode_1.description, db_dbnode_1.ctime, db_dbnode_1.mtime, db_dbnode_1.attributes, db_dbnode_1.extras, db_dbnode_1.repository_metadata, db_dbnode_1.user_id, db_dbnode_1.dbcomputer_id, db_dbnode_2.id AS id_1, db_dbnode_2.uuid AS uuid_1, db_dbnode_2.node_type AS node_type_1, db_dbnode_2.process_type AS process_type_1, db_dbnode_2.label AS label_1, db_dbnode_2.description AS description_1, db_dbnode_2.ctime AS ctime_1, db_dbnode_2.mtime AS mtime_1, db_dbnode_2.attributes AS attributes_1, db_dbnode_2.extras AS extras_1, db_dbnode_2.repository_metadata AS repository_metadata_1, db_dbnode_2.user_id AS user_id_1, db_dbnode_2.dbcomputer_id AS dbcomputer_id_1
FROM db_dbnode AS db_dbnode_1 JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_1.id JOIN db_dbnode AS db_dbnode_2 ON db_dblink_1.output_id = db_dbnode_2.id
WHERE CAST(db_dbnode_1.node_type AS VARCHAR) LIKE 'data.%%' AND CAST(db_dbnode_2.node_type AS VARCHAR) LIKE 'data.%%' SELECT db_dbnode_1.id, db_dbnode_1.uuid, db_dbnode_1.node_type, db_dbnode_1.process_type, db_dbnode_1.label, db_dbnode_1.description, db_dbnode_1.ctime, db_dbnode_1.mtime, db_dbnode_1.attributes, db_dbnode_1.extras, db_dbnode_1.repository_metadata, db_dbnode_1.user_id, db_dbnode_1.dbcomputer_id
FROM db_dbnode AS db_dbnode_2, db_dbnode AS db_dbnode_1 JOIN db_dblink AS db_dblink_1 ON db_dblink_1.input_id = db_dbnode_2.id JOIN db_dbnode AS db_dbnode_1 ON db_dblink_1.output_id = db_dbnode_1.id
WHERE CAST(db_dbnode_2.node_type AS VARCHAR) LIKE 'data.%%' AND CAST(db_dbnode_1.node_type AS VARCHAR) LIKE 'data.%%' |
I remember looking at this, but mostly that the whole logic around the private |
Yeh the but, as per the issue above, I don't know if I can actually get it to work, and its obviously not great to be accessing private attributes anyway. |
Note:
|
For reference, re:
This was actually in response to an issue I had opened a lot of time ago: sqlalchemy/sqlalchemy#4395 |
superseded by #5103 |
This PR is intended to update our use of sqlalchemy to the 2.0 API, which is supported by v1.4: https://docs.sqlalchemy.org/en/14/glossary.html#term-1
(note this currently builds on #5063)