Skip to content

Commit

Permalink
fix: special mapping of row ids
Browse files Browse the repository at this point in the history
  • Loading branch information
KKould committed Jan 2, 2025
1 parent 4e72540 commit 8aaa278
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 6 additions & 3 deletions core/translate/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -977,9 +977,12 @@ fn try_index_cover(
let (pos, _) = table.get_column(&index_column.name).unwrap();
index_column_map.insert(pos, i);
}
for pk_name in table.primary_key_column_names.iter() {
// SAFETY: the primary key column must exist in the table
let (pos, _) = table.get_column(pk_name).unwrap();
if table.has_rowid {
let pos = table
.columns
.iter()
.position(|column| column.is_rowid_alias)
.unwrap();
index_column_map.insert(pos, index_column_map.len());
}

Expand Down
4 changes: 4 additions & 0 deletions testing/where.test
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ do_execsql_test where-age-index-seek-regression-test-2 {
select count(1) from users where age > 0;
} {10000}

do_execsql_test where-age-index-cover-seek {
select id, age from users where age > 90;
} {120|90}

do_execsql_test where-simple-between {
SELECT * FROM products WHERE price BETWEEN 70 AND 100;
} {1|hat|79.0
Expand Down

0 comments on commit 8aaa278

Please sign in to comment.