From 0aa28293adedc488eb9107dc52b5e9a124887fbd Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Wed, 1 Aug 2018 08:29:53 -0700 Subject: [PATCH] Fix compatibility with SQLite prior to 3.16.0 pragma_index_info() and pragma_index_list() were introduced in 3.16.0 but the version of SQLite running in Travis CI is earlier than that, hence the test failures: https://travis-ci.com/simonw/sqlite-utils/jobs/137617744 --- sqlite_utils/db.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sqlite_utils/db.py b/sqlite_utils/db.py index 82f1f93..0a05296 100644 --- a/sqlite_utils/db.py +++ b/sqlite_utils/db.py @@ -125,13 +125,13 @@ class Table: @property def indexes(self): - sql = "select * from pragma_index_list(?)" + sql = 'PRAGMA index_list("{}")'.format(self.name) indexes = [] - for row in list(self.db.conn.execute(sql, (self.name,)).fetchall()): - column_sql = "select name from pragma_index_info(?) order by seqno" - columns = [ - r[0] for r in self.db.conn.execute(column_sql, (row[1],)).fetchall() - ] + for row in list(self.db.conn.execute(sql).fetchall()): + column_sql = 'PRAGMA index_info("{}")'.format(row[1]) + columns = [] + for seqno, cid, name in self.db.conn.execute(column_sql).fetchall(): + columns.append(name) indexes.append(Index(*(row + (columns,)))) return indexes