diff --git a/core/translate/insert.rs b/core/translate/insert.rs index 48dedf80d..7942ab7a1 100644 --- a/core/translate/insert.rs +++ b/core/translate/insert.rs @@ -27,12 +27,12 @@ use super::optimizer::rewrite_expr; pub fn translate_insert( query_mode: QueryMode, schema: &Schema, - with: &Option, - on_conflict: &Option, - tbl_name: &QualifiedName, - columns: &Option, - body: &mut InsertBody, - _returning: &Option>, + with: Option, + on_conflict: Option, + tbl_name: QualifiedName, + columns: Option, + body: InsertBody, + _returning: Option>, syms: &SymbolTable, mut program: ProgramBuilder, ) -> Result { @@ -451,16 +451,11 @@ struct ColumnMapping<'a> { fn resolve_columns_for_insert<'a>( table: &'a Table, columns: &Option, - values: &[Vec], + num_values: usize, ) -> Result>> { - if values.is_empty() { - crate::bail_parse_error!("no values to insert"); - } - let table_columns = &table.columns(); // Case 1: No columns specified - map values to columns in order if columns.is_none() { - let num_values = values[0].len(); if num_values > table_columns.len() { crate::bail_parse_error!( "table {} has {} columns but {} values were supplied", @@ -470,13 +465,6 @@ fn resolve_columns_for_insert<'a>( ); } - // Verify all value tuples have same length - for value in values.iter().skip(1) { - if value.len() != num_values { - crate::bail_parse_error!("all VALUES must have the same number of terms"); - } - } - // Map each column to either its corresponding value index or None return Ok(table_columns .iter() diff --git a/core/translate/mod.rs b/core/translate/mod.rs index e0070305c..debc8b2bb 100644 --- a/core/translate/mod.rs +++ b/core/translate/mod.rs @@ -250,18 +250,18 @@ pub fn translate_inner( or_conflict, tbl_name, columns, - mut body, + body, returning, } = *insert; translate_insert( query_mode, schema, - &with, - &or_conflict, - &tbl_name, - &columns, - &mut body, - &returning, + with, + or_conflict, + tbl_name, + columns, + body, + returning, syms, program, )?