mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-25 12:04:21 +01:00
sqlite3-parser: box the InsertBody
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -217,7 +217,7 @@ pub enum Stmt {
|
||||
/// `COLUMNS`
|
||||
columns: Option<DistinctNames>,
|
||||
/// `VALUES` or `SELECT`
|
||||
body: InsertBody,
|
||||
body: Box<InsertBody>,
|
||||
/// `RETURNING`
|
||||
returning: Option<Vec<ResultColumn>>,
|
||||
},
|
||||
|
||||
@@ -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>>)}
|
||||
|
||||
Reference in New Issue
Block a user