[dbmanager] Fix Update SQL Layer converts query to table name

Fixes #19843
This commit is contained in:
Alessandro Pasotti 2018-09-20 12:43:59 +02:00
parent f208191824
commit a8bf1b8f05

View File

@ -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))