Skip to content
Permalink
Browse files

db manager: also add newline when adding a unique id field (fixes #19343

)

(cherry picked from commit 870d078)
  • Loading branch information
jef-n committed Jul 5, 2018
1 parent 86c3e8b commit ef6ce4ec3f1ad5be61bcd2ff7e860f3167a77303
@@ -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()
@@ -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))
@@ -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()

0 comments on commit ef6ce4e

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