Skip to content

Commit cb9314a

Browse files
authored
Merge pull request #4100 from rldhont/bugfix_dbmanager_detect_query_layer
[BUGFIX][DB Manager] Detect query layer like providers do
2 parents 74c65c8 + 2a77ba7 commit cb9314a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

python/plugins/db_manager/db_manager_plugin.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def unload(self):
8181
def onLayerWasAdded(self, aMapLayer):
8282
if hasattr(aMapLayer, 'dataProvider') and aMapLayer.dataProvider().name() in ['postgres', 'spatialite', 'oracle']:
8383
uri = QgsDataSourceUri(aMapLayer.source())
84-
if re.search('^\(SELECT .+ FROM .+\)$', uri.table(), re.S):
84+
table = uri.table()
85+
if table.startswith('(') and table.endswith(')'):
8586
self.addCustomActionForLayer(self.layerAction, aMapLayer)
8687
# virtual has QUrl source
8788
# url = QUrl(QUrl.fromPercentEncoding(l.source()))
@@ -92,8 +93,8 @@ def onLayerWasAdded(self, aMapLayer):
9293
def onUpdateSqlLayer(self):
9394
l = self.iface.activeLayer()
9495
if l.dataProvider().name() in ['postgres', 'spatialite', 'oracle']:
95-
uri = QgsDataSourceUri(l.source())
96-
if re.search('^\(SELECT .+ FROM .+\)$', uri.table(), re.S):
96+
table = uri.table()
97+
if table.startswith('(') and table.endswith(')'):
9798
self.run()
9899
self.dlg.runSqlLayerWindow(l)
99100
# virtual has QUrl source

0 commit comments

Comments
 (0)