mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
fix generation for string literal in a different place + simplify test assertion
This commit is contained in:
parent
470093ca03
commit
62e7b1f64c
4 changed files with 10 additions and 16 deletions
BIN
limbo_sim
BIN
limbo_sim
Binary file not shown.
|
@ -236,7 +236,7 @@ fn produce_true_predicate<R: Rng>(rng: &mut R, (t, row): (&Table, &Vec<Value>))
|
|||
let column_index = rng.gen_range(0..t.columns.len());
|
||||
let column = &t.columns[column_index];
|
||||
let value = &row[column_index];
|
||||
backtrack(
|
||||
let predicate = backtrack(
|
||||
vec![
|
||||
(
|
||||
1,
|
||||
|
@ -316,7 +316,8 @@ fn produce_true_predicate<R: Rng>(rng: &mut R, (t, row): (&Table, &Vec<Value>))
|
|||
),
|
||||
],
|
||||
rng,
|
||||
)
|
||||
);
|
||||
predicate
|
||||
}
|
||||
|
||||
/// Produces a predicate that is false for the provided row in the given table
|
||||
|
@ -538,7 +539,6 @@ impl ArbitraryFrom<(&Table, &Vec<Value>)> for Predicate {
|
|||
rng,
|
||||
);
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,12 +43,9 @@ fn expr_to_value(expr: &ast::Expr, row: &[Value], table: &Table) -> Option<Value
|
|||
.cloned(),
|
||||
ast::Expr::Literal(literal) => Some(literal.into()),
|
||||
ast::Expr::Binary(lhs, op, rhs) => {
|
||||
let lhs = expr_to_value(lhs, row, table);
|
||||
let rhs = expr_to_value(rhs, row, table);
|
||||
match (lhs, rhs) {
|
||||
(Some(lhs), Some(rhs)) => Some(lhs.binary_compare(&rhs, *op)),
|
||||
_ => None,
|
||||
}
|
||||
let lhs = expr_to_value(lhs, row, table)?;
|
||||
let rhs = expr_to_value(rhs, row, table)?;
|
||||
Some(lhs.binary_compare(&rhs, *op))
|
||||
}
|
||||
ast::Expr::Like {
|
||||
lhs,
|
||||
|
@ -57,12 +54,9 @@ fn expr_to_value(expr: &ast::Expr, row: &[Value], table: &Table) -> Option<Value
|
|||
rhs,
|
||||
escape: _, // TODO: support escape
|
||||
} => {
|
||||
let lhs = expr_to_value(lhs, row, table);
|
||||
let rhs = expr_to_value(rhs, row, table);
|
||||
let res = match (lhs, rhs) {
|
||||
(Some(lhs), Some(rhs)) => lhs.like_compare(&rhs, *op),
|
||||
_ => return None,
|
||||
};
|
||||
let lhs = expr_to_value(lhs, row, table)?;
|
||||
let rhs = expr_to_value(rhs, row, table)?;
|
||||
let res = lhs.like_compare(&rhs, *op);
|
||||
let value: Value = if *not { !res } else { res }.into();
|
||||
Some(value)
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ impl From<&Value> for ast::Literal {
|
|||
Value::Null => Self::Null,
|
||||
Value::Integer(i) => Self::Numeric(i.to_string()),
|
||||
Value::Float(f) => Self::Numeric(f.to_string()),
|
||||
Value::Text(string) => Self::String(string.clone()),
|
||||
Value::Text(string) => Self::String(format!("'{}'", string)),
|
||||
Value::Blob(blob) => Self::Blob(hex::encode(blob)),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue