Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 5b86e38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion python/plugins/db_manager/db_plugins/plugin.py
Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions python/plugins/db_manager/db_plugins/spatialite/connector.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 5b86e38

Please sign in to comment.