sqlite3-parser: box the InsertBody

This commit is contained in:
Jussi Saurio
2025-02-08 18:09:58 +02:00
parent 781aa3b5d6
commit 4faadd86b0
3 changed files with 13 additions and 13 deletions

View File

@@ -160,19 +160,19 @@ impl Stmt {
} => Err(custom_err!("ORDER BY without LIMIT on DELETE")),
Self::Insert {
columns: Some(columns),
body: InsertBody::Select(select, ..),
body,
..
} => match select.body.select.column_count() {
ColumnCount::Fixed(n) if n != columns.len() => {
Err(custom_err!("{} values for {} columns", n, columns.len()))
} => match &**body {
InsertBody::Select(select, ..) => match select.body.select.column_count() {
ColumnCount::Fixed(n) if n != columns.len() => {
Err(custom_err!("{} values for {} columns", n, columns.len()))
}
_ => Ok(()),
},
InsertBody::DefaultValues => {
Err(custom_err!("0 values for {} columns", columns.len()))
}
_ => Ok(()),
},
Self::Insert {
columns: Some(columns),
body: InsertBody::DefaultValues,
..
} => Err(custom_err!("0 values for {} columns", columns.len())),
Self::Update {
order_by: Some(_),
limit: None,

View File

@@ -217,7 +217,7 @@ pub enum Stmt {
/// `COLUMNS`
columns: Option<DistinctNames>,
/// `VALUES` or `SELECT`
body: InsertBody,
body: Box<InsertBody>,
/// `RETURNING`
returning: Option<Vec<ResultColumn>>,
},

View File

@@ -828,13 +828,13 @@ cmd ::= with(W) insert_cmd(R) INTO xfullname(X) idlist_opt(F) select(S)
let (upsert, returning) = U;
let body = InsertBody::Select(Box::new(S), upsert);
self.ctx.stmt = Some(Stmt::Insert{ with: W, or_conflict: R, tbl_name: X, columns: F,
body, returning });
body: Box::new(body), returning });
}
cmd ::= with(W) insert_cmd(R) INTO xfullname(X) idlist_opt(F) DEFAULT VALUES returning(Y).
{
let body = InsertBody::DefaultValues;
self.ctx.stmt = Some(Stmt::Insert{ with: W, or_conflict: R, tbl_name: X, columns: F,
body, returning: Y });
body: Box::new(body), returning: Y });
}
%type upsert {(Option<Upsert>, Option<Vec<ResultColumn>>)}