diff --git a/core/translate/emitter.rs b/core/translate/emitter.rs index 3713516a4..cc252112b 100644 --- a/core/translate/emitter.rs +++ b/core/translate/emitter.rs @@ -977,12 +977,11 @@ fn try_index_cover( let (pos, _) = table.get_column(&index_column.name).unwrap(); index_column_map.insert(pos, i); } - if table.has_rowid { - let pos = table - .columns - .iter() - .position(|column| column.is_rowid_alias) - .unwrap(); + if let Some(pos) = table + .columns + .iter() + .position(|column| column.is_rowid_alias) + { index_column_map.insert(pos, index_column_map.len()); } diff --git a/testing/where.test b/testing/where.test index 8e4081409..1722d8d35 100755 --- a/testing/where.test +++ b/testing/where.test @@ -319,7 +319,7 @@ do_execsql_test where-age-index-seek-regression-test-2 { } {10000} do_execsql_test where-age-index-cover-seek { - select id, age from users where age > 90; + select id, age from users where age > 90 limit 1; } {120|90} do_execsql_test where-simple-between {