[db-manager] Allow multiline filters in sql window

Fixes #19956 - Update SQL layer results in invalid SQL expression
This commit is contained in:
Alessandro Pasotti 2018-09-27 08:01:40 +02:00
parent a1d130ac97
commit 94ded32f4e

View File

@ -145,11 +145,11 @@ class DlgSqlLayerWindow(QWidget, Ui_Dialog):
# First the SQL from QgsDataSourceUri table
sql = uri.table()
if uri.keyColumn() == '_uid_':
match = re.search('^\(SELECT .+ AS _uid_,\* FROM \((.*)\) AS _subq_.+_\s*\)$', sql, re.S)
match = re.search(r'^\(SELECT .+ AS _uid_,\* FROM \((.*)\) AS _subq_.+_\s*\)$', sql, re.S | re.X)
if match:
sql = match.group(1)
else:
match = re.search('^\((SELECT .+ FROM .+)\)$', sql, re.S)
match = re.search(r'^\((SELECT .+ FROM .+)\)$', sql, re.S | re.X)
if match:
sql = match.group(1)
# Need to check on table() since the parentheses were removed by the regexp