- 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:
alpaylan 2025-02-09 09:28:33 -05:00
parent e406a030e6
commit 47420db16f
11 changed files with 499 additions and 240 deletions

View 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)
}
}