Skip to content

Commit

Permalink
fix(binder): insert column count validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Joeyscat committed Dec 18, 2023
1 parent 33a310c commit f62d3e2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/binder/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ impl<'a, T: Transaction> Binder<'a, T> {
}
let mut rows = Vec::with_capacity(expr_rows.len());
for expr_row in expr_rows {
if expr_row.len() != columns.len() {
return Err(BindError::ColumnCountMismatch(
columns.len(),
expr_row.len(),
));
}
let mut row = Vec::with_capacity(expr_row.len());

for (i, expr) in expr_row.iter().enumerate() {
Expand Down
2 changes: 2 additions & 0 deletions src/binder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ pub enum BindError {
InvalidColumn(String),
#[error("ambiguous column {0}")]
AmbiguousColumn(String),
#[error("column count not match, expect {0}, got {1}")]
ColumnCountMismatch(usize, usize),
#[error("binary operator types mismatch: {0} != {1}")]
BinaryOpTypeMismatch(String, String),
#[error("subquery error: {0}")]
Expand Down

0 comments on commit f62d3e2

Please sign in to comment.