Skip to content

Commit

Permalink
Merge pull request #4100 from rldhont/bugfix_dbmanager_detect_query_l…
Browse files Browse the repository at this point in the history
…ayer

[BUGFIX][DB Manager] Detect query layer like providers do
  • Loading branch information
rldhont committed Feb 3, 2017
2 parents 74c65c8 + 2a77ba7 commit cb9314a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/plugins/db_manager/db_manager_plugin.py
Expand Up @@ -81,7 +81,8 @@ def unload(self):
def onLayerWasAdded(self, aMapLayer):
if hasattr(aMapLayer, 'dataProvider') and aMapLayer.dataProvider().name() in ['postgres', 'spatialite', 'oracle']:
uri = QgsDataSourceUri(aMapLayer.source())
if re.search('^\(SELECT .+ FROM .+\)$', uri.table(), re.S):
table = uri.table()
if table.startswith('(') and table.endswith(')'):
self.addCustomActionForLayer(self.layerAction, aMapLayer)
# virtual has QUrl source
# url = QUrl(QUrl.fromPercentEncoding(l.source()))
Expand All @@ -92,8 +93,8 @@ def onLayerWasAdded(self, aMapLayer):
def onUpdateSqlLayer(self):
l = self.iface.activeLayer()
if l.dataProvider().name() in ['postgres', 'spatialite', 'oracle']:
uri = QgsDataSourceUri(l.source())
if re.search('^\(SELECT .+ FROM .+\)$', uri.table(), re.S):
table = uri.table()
if table.startswith('(') and table.endswith(')'):
self.run()
self.dlg.runSqlLayerWindow(l)
# virtual has QUrl source
Expand Down

0 comments on commit cb9314a

Please sign in to comment.