mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
- implement DROP TABLE support, toggled off from generation for now
- clean up the query generation/printing by separating it into different files and removing duplications
This commit is contained in:
parent
e406a030e6
commit
47420db16f
11 changed files with 499 additions and 240 deletions
35
simulator/model/query/delete.rs
Normal file
35
simulator/model/query/delete.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
use std::fmt::Display;
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::{model::table::Value, SimulatorEnv};
|
||||
|
||||
use super::select::Predicate;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub(crate) struct Delete {
|
||||
pub(crate) table: String,
|
||||
pub(crate) predicate: Predicate,
|
||||
}
|
||||
|
||||
impl Delete {
|
||||
pub(crate) fn shadow(&self, env: &mut SimulatorEnv) -> Vec<Vec<Value>> {
|
||||
let table = env
|
||||
.tables
|
||||
.iter_mut()
|
||||
.find(|t| t.name == self.table)
|
||||
.unwrap();
|
||||
|
||||
let t2 = table.clone();
|
||||
|
||||
table.rows.retain_mut(|r| self.predicate.test(r, &t2));
|
||||
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for Delete {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "DELETE FROM {} WHERE {}", self.table, self.predicate)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue