Skip to content

Commit bae8651

Browse files
committedJan 19, 2016
[bugfix][DbManager] 14110 - Error fetching layer indexes with recent sqlite version
Fixes #14110 The method `getTableIndexes`, situated in line 371 of the file `db_manager/db_plugins/spatialite/connector.py`, expected to get 3 fields from the sqlite method `PRAGMA index_list` . In recent versions of SQLite, since 3.8.9, though, this method now returns 5 fields. This commit fixes this issue by checking the length of columns returned by the method.
1 parent 26ae323 commit bae8651

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎python/plugins/db_manager/db_plugins/spatialite/connector.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,14 @@ def getTableIndexes(self, table):
368368
indexes = c.fetchall()
369369

370370
for i, idx in enumerate(indexes):
371-
num, name, unique = idx
371+
# sqlite has changed the number of columns returned by index_list since 3.8.9
372+
# I am not using self.getInfo() here because this behaviour
373+
# can be changed back without notice as done for index_info, see:
374+
# http://repo.or.cz/sqlite.git/commit/53555d6da78e52a430b1884b5971fef33e9ccca4
375+
if len(idx) == 3:
376+
num, name, unique = idx
377+
if len(idx) == 5:
378+
num, name, unique, createdby, partial = idx
372379
sql = u"PRAGMA index_info(%s)" % (self.quoteId(name))
373380
self._execute(c, sql)
374381

0 commit comments

Comments
 (0)
Please sign in to comment.