Merge pull request #7966 from elpaso/bugfix-19843-dbmanager-quoted-sql

[dbmanager] Fix Update SQL Layer converts query to table name
This commit is contained in:
Alessandro Pasotti 2018-09-21 09:56:35 +02:00 committed by GitHub
commit 1b2d885a03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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