Skip to content
Permalink
Browse files

Merge pull request #38940 from elpaso/bugfix-gh38092-executesql-feedb…

…ack-followup

Be smart when adding limit: followup #8092
  • Loading branch information
elpaso committed Sep 22, 2020
2 parents a15fff1 + ef02c54 commit 063b8daab378886037c6a7a265e7c0863abb4bcd
Showing with 2 additions and 1 deletion.
  1. +2 −1 python/plugins/db_manager/db_plugins/postgis/connector.py
@@ -121,7 +121,8 @@ def description(self):
uri = QgsDataSourceUri(self.connection.uri())

# TODO: make this part provider-agnostic
uri.setTable('(SELECT row_number() OVER () AS __rid__, * FROM (' + self.sql + ' LIMIT 1) as foo)')
sql = self.sql if self.sql.upper().find(' LIMIT ') >= 0 else self.sql + ' LIMIT 1 '
uri.setTable('(SELECT row_number() OVER () AS __rid__, * FROM (' + sql + ') as foo)')
uri.setKeyColumn('__rid__')
# TODO: fetch provider name from connection (QgsAbstractConnectionProvider)
# TODO: re-use the VectorLayer for fetching rows in batch mode

0 comments on commit 063b8da

Please sign in to comment.
You can’t perform that action at this time.