Repository: gluesql/gluesql (rust)

Issue:
INSERT with more values is accepted
```sql
CREATE TABLE Test (id INTEGER);
INSERT INTO Test VALUES (100, 200);
```

below insertion query should report an error but it is accepted.
* [src/data/row.rs](https://github.com/gluesql/gluesql/blob/main/src/data/row.rs)

Current `Row` struct cares lack of values or columns but not handling more values properly.

Pull request description:
Report an error for inserting more values than table columns
Closes #62 .

Fixes to report an error `TooManyValues` if inserting more values than target columns of the specified table.

Patch:
diff --git a/src/data/row.rs b/src/data/row.rs
index ad142414..1708eca6 100644
--- a/src/data/row.rs
+++ b/src/data/row.rs
@@ -17,6 +17,9 @@ pub enum RowError {
     #[error("literals does not fit to columns")]
     LackOfRequiredValue(String),
 
+    #[error("literals have more values than target columns")]
+    TooManyValues,
+
     #[error("unsupported ast value type")]
     UnsupportedAstValueType,
 
@@ -61,6 +64,10 @@ impl Row {
         values
             .iter()
             .map(|values| {
+                if values.len() > column_defs.len() {
+                    return Err(RowError::TooManyValues.into());
+                }
+
                 (&column_defs)
                     .iter()
                     .enumerate()


Test patch:
diff --git a/src/tests/error.rs b/src/tests/error.rs
index 2a2d3305..6e4db968 100644
--- a/src/tests/error.rs
+++ b/src/tests/error.rs
@@ -39,6 +39,10 @@ pub fn error(mut tester: impl tests::Tester) {
             RowError::LackOfRequiredValue("id".to_owned()).into(),
             "INSERT INTO TableA (id2, id) VALUES (100);",
         ),
+        (
+            RowError::TooManyValues.into(),
+            "INSERT INTO TableA VALUES (100), (100, 200);",
+        ),
     ];
 
     test_cases