mirror of
https://github.com/aljazceru/turso.git
synced 2026-02-09 10:14:21 +01:00
wip: add delete support to the simulator
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1735,6 +1735,8 @@ dependencies = [
|
||||
"notify",
|
||||
"rand 0.8.5",
|
||||
"rand_chacha 0.3.1",
|
||||
"regex",
|
||||
"regex-syntax",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tempfile",
|
||||
|
||||
@@ -14,7 +14,10 @@ use crate::{
|
||||
|
||||
use crate::generation::{frequency, Arbitrary, ArbitraryFrom};
|
||||
|
||||
use super::property::{remaining, Property};
|
||||
use super::{
|
||||
property::{remaining, Property},
|
||||
table,
|
||||
};
|
||||
|
||||
pub(crate) type ResultSet = Result<Vec<Vec<Value>>>;
|
||||
|
||||
@@ -303,7 +306,15 @@ impl Interactions {
|
||||
.unwrap();
|
||||
table.rows.extend(values);
|
||||
}
|
||||
Query::Delete(_) => todo!(),
|
||||
Query::Delete(delete) => {
|
||||
let table = env
|
||||
.tables
|
||||
.iter_mut()
|
||||
.find(|t| t.name == delete.table)
|
||||
.unwrap();
|
||||
let t2 = &table.clone();
|
||||
table.rows.retain_mut(|r| delete.predicate.test(r, t2));
|
||||
}
|
||||
Query::Select(_) => {}
|
||||
},
|
||||
Interaction::Assertion(_) => {}
|
||||
|
||||
@@ -113,7 +113,7 @@ impl ArbitraryFrom<(&SimulatorEnv, &Remaining)> for Query {
|
||||
Box::new(|rng| Self::Insert(Insert::arbitrary_from(rng, env))),
|
||||
),
|
||||
(
|
||||
0.0,
|
||||
remaining.write,
|
||||
Box::new(|rng| Self::Delete(Delete::arbitrary_from(rng, env))),
|
||||
),
|
||||
],
|
||||
|
||||
@@ -288,7 +288,7 @@ pub(crate) struct Delete {
|
||||
|
||||
impl Delete {
|
||||
pub(crate) fn shadow(&self, _env: &mut SimulatorEnv) -> Vec<Vec<Value>> {
|
||||
todo!()
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user