From b20054c1e505a8559da7579e540aa9dfa68b0daf Mon Sep 17 00:00:00 2001 From: k1LoW Date: Fri, 3 May 2024 08:20:34 +0900 Subject: [PATCH] Support the case where name in index_info is NULL. Fix https://github.com/k1LoW/tbls/issues/578 ref: https://www.sqlite.org/pragma.html#pragma_index_info > 3. The name of the column being indexed. This columns is NULL if the column is the rowid or an expression. --- drivers/sqlite/sqlite.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/sqlite/sqlite.go b/drivers/sqlite/sqlite.go index 9387afaa9..a32b0e46f 100644 --- a/drivers/sqlite/sqlite.go +++ b/drivers/sqlite/sqlite.go @@ -248,7 +248,7 @@ WHERE name != 'sqlite_sequence' AND (type = 'table' OR type = 'view');`) var ( colRank string colRankWithinTable string - col string + col sql.NullString cols []string ) row, err := l.db.Query(fmt.Sprintf("PRAGMA index_info(`%s`)", indexName)) @@ -264,7 +264,9 @@ WHERE name != 'sqlite_sequence' AND (type = 'table' OR type = 'view');`) if err != nil { return errors.WithStack(err) } - cols = append(cols, col) + if col.Valid { + cols = append(cols, col.String) + } } switch indexCreatedBy {