Skip to content
Permalink
Browse files

db_manager: only try isgpkg on spatialite plugin and sqlite version p…

…arsing
  • Loading branch information
jef-n committed Jul 11, 2015
1 parent baf60a2 commit 5b86e38676f01e147035b3b2cfa52bf2f1945633
@@ -637,7 +637,7 @@ def uri(self):

def mimeUri(self):
layerType = "raster" if self.type == Table.RasterType else "vector"
if self.database().connector.isgpkg():
if self.database().dbplugin().typeName() == "spatialite" and self.database().connector.isgpkg():
url = str(self.database().connector._connectionInfo() + "|layername=" + self.name)
return u"%s:%s:%s:%s" % (layerType, "ogr", self.name, url)
return u"%s:%s:%s:%s" % (layerType, self.database().dbplugin().providerName(), self.name, self.uri().uri())
@@ -126,7 +126,7 @@ def hasCreateSpatialViewSupport(self):
return True

def isgpkg(self):
info = float(self.getInfo()[0][:-2])
info = float( ".".join( self.getInfo()[0].split('.')[0:2] ) )
if info < 4.2:
result = self.uri().database()[-5:] == ".gpkg"
else:
@@ -501,7 +501,7 @@ def createSpatialView(self, view, query):
sql = u"PRAGMA table_info(%s)" % self.quoteString(view)
c = self._execute( None, sql )
geom_col = None
for r in c.fetchall():
for r in c.fetchall():
if r[2].upper() in ('POINT', 'LINESTRING', 'POLYGON',
'MULTIPOINT', 'MULTILINESTRING', 'MULTIPOLYGON'):
geom_col = r[1]
@@ -530,7 +530,7 @@ def createSpatialView(self, view, query):
wkbType += 1000
if 'M' in gdim:
wkbType += 2000

sql = u"""INSERT INTO geometry_columns (f_table_name, f_geometry_column, geometry_type, coord_dimension, srid, spatial_index_enabled)
VALUES (%s, %s, %s, %s, %s, 0)""" % (self.quoteId(view), self.quoteId(geom_col), wkbType, len(gdim), gsrid)
self._execute_and_commit(sql)

0 comments on commit 5b86e38

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