Skip to content

Commit

Permalink
db manager: also add newline when adding a unique id field (fixes #19343
Browse files Browse the repository at this point in the history
)

(cherry picked from commit 870d078)
  • Loading branch information
jef-n committed Jul 5, 2018
1 parent 7949e9b commit ca2abb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/oracle/plugin.py
Expand Up @@ -202,7 +202,7 @@ def toSqlLayer(self, sql, geomCol, uniqueCol,
uri = self.uri()
con = self.database().connector

uri.setDataSource(u"", u"({})".format(sql), geomCol, filter, uniqueCol.strip(u'"'))
uri.setDataSource(u"", u"({}\n)".format(sql), geomCol, filter, uniqueCol.strip(u'"'))
if avoidSelectById:
uri.disableSelectAtId(True)
provider = self.dbplugin().providerName()
Expand All @@ -212,7 +212,7 @@ def toSqlLayer(self, sql, geomCol, uniqueCol,
if not vlayer.isValid():

wkbType, srid = con.getTableMainGeomType(
u"({})".format(sql), geomCol)
u"({}\n)".format(sql), geomCol)
uri.setWkbType(wkbType)
if srid:
uri.setSrid(str(srid))
Expand Down
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_plugins/plugin.py
Expand Up @@ -285,7 +285,7 @@ def toSqlLayer(self, sql, geomCol, uniqueCol, layerName="QueryLayer", layerType=
q = 1
while "_subq_%d_" % q in sql:
q += 1
sql = "SELECT %s AS _uid_,* FROM (%s) AS _subq_%d_" % (uniqueFct, sql, q)
sql = u"SELECT %s AS _uid_,* FROM (%s\n) AS _subq_%d_" % (uniqueFct, sql, q)
uniqueCol = "_uid_"

uri = self.uri()
Expand Down

0 comments on commit ca2abb5

Please sign in to comment.