bindings/rust: Fix Rows::next() I/O dispatcher handling

The `next()` function needs to be a loop to make sure we actually return rows.
This commit is contained in:
Pekka Enberg 2025-06-16 14:23:26 +03:00
parent 882c5ca168
commit 47e08d34bf
2 changed files with 49 additions and 12 deletions

View file

@ -0,0 +1,27 @@
use limbo::Builder;
#[tokio::test]
async fn test_rows_next() {
let builder = Builder::new_local(":memory:");
let db = builder.build().await.unwrap();
let conn = db.connect().unwrap();
conn.execute("CREATE TABLE test (x INTEGER)", ())
.await
.unwrap();
conn.execute("INSERT INTO test (x) VALUES (1)", ())
.await
.unwrap();
conn.execute("INSERT INTO test (x) VALUES (2)", ())
.await
.unwrap();
let mut res = conn.query("SELECT * FROM test", ()).await.unwrap();
assert_eq!(
res.next().await.unwrap().unwrap().get_value(0).unwrap(),
1.into()
);
assert_eq!(
res.next().await.unwrap().unwrap().get_value(0).unwrap(),
2.into()
);
assert!(res.next().await.unwrap().is_none());
}