mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-23 17:05:36 +01:00
core: Move result row to ProgramState
Move result row to `ProgramState` to mimic what SQLite does where `Vdbe` struct has a `pResultRow` member. This makes it easier to deal with result lifetime, but more importantly, eventually lazily parse values at the edges of the API.
This commit is contained in:
@@ -13,8 +13,9 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
|
||||
|
||||
loop {
|
||||
match stmt.step()? {
|
||||
StepResult::Row(row) => {
|
||||
assert_eq!(row.values[0], Value::Integer(1));
|
||||
StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
assert_eq!(row.values[0].to_value(), Value::Integer(1));
|
||||
}
|
||||
StepResult::IO => tmp_db.io.run_once()?,
|
||||
_ => break,
|
||||
@@ -27,8 +28,9 @@ fn test_statement_reset_bind() -> anyhow::Result<()> {
|
||||
|
||||
loop {
|
||||
match stmt.step()? {
|
||||
StepResult::Row(row) => {
|
||||
assert_eq!(row.values[0], Value::Integer(2));
|
||||
StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
assert_eq!(row.values[0].to_value(), Value::Integer(2));
|
||||
}
|
||||
StepResult::IO => tmp_db.io.run_once()?,
|
||||
_ => break,
|
||||
@@ -59,24 +61,25 @@ fn test_statement_bind() -> anyhow::Result<()> {
|
||||
|
||||
loop {
|
||||
match stmt.step()? {
|
||||
StepResult::Row(row) => {
|
||||
if let Value::Text(s) = row.values[0] {
|
||||
StepResult::Row => {
|
||||
let row = stmt.row().unwrap();
|
||||
if let Value::Text(s) = row.values[0].to_value() {
|
||||
assert_eq!(s, "hello")
|
||||
}
|
||||
|
||||
if let Value::Text(s) = row.values[1] {
|
||||
if let Value::Text(s) = row.values[1].to_value() {
|
||||
assert_eq!(s, "hello")
|
||||
}
|
||||
|
||||
if let Value::Integer(i) = row.values[2] {
|
||||
if let Value::Integer(i) = row.values[2].to_value() {
|
||||
assert_eq!(i, 42)
|
||||
}
|
||||
|
||||
if let Value::Blob(v) = row.values[3] {
|
||||
if let Value::Blob(v) = row.values[3].to_value() {
|
||||
assert_eq!(v, &vec![0x1 as u8, 0x2, 0x3])
|
||||
}
|
||||
|
||||
if let Value::Float(f) = row.values[4] {
|
||||
if let Value::Float(f) = row.values[4].to_value() {
|
||||
assert_eq!(f, 0.5)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user