From a8bf1b8f05ac2d569fd58bdf9951e8a756344a5e Mon Sep 17 00:00:00 2001 From: Alessandro Pasotti Date: Thu, 20 Sep 2018 12:43:59 +0200 Subject: [PATCH] [dbmanager] Fix Update SQL Layer converts query to table name Fixes #19843 --- python/plugins/db_manager/dlg_sql_layer_window.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/plugins/db_manager/dlg_sql_layer_window.py b/python/plugins/db_manager/dlg_sql_layer_window.py index f2a732eb187..3c768d283d5 100644 --- a/python/plugins/db_manager/dlg_sql_layer_window.py +++ b/python/plugins/db_manager/dlg_sql_layer_window.py @@ -152,7 +152,8 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog): match = re.search('^\((SELECT .+ FROM .+)\)$', sql, re.S) if match: sql = match.group(1) - if not sql.startswith('(') and not sql.endswith(')'): + # Need to check on table() since the parentheses were removed by the regexp + if not uri.table().startswith('(') and not uri.table().endswith(')'): schema = uri.schema() if schema and schema.upper() != 'PUBLIC': sql = 'SELECT * FROM {0}.{1}'.format(self.db.connector.quoteId(schema), self.db.connector.quoteId(sql))