Skip to content

Commit 19543f2

Browse files
committed
fix: Address CodeRabbit nitpicks
- Add value assertion in test_parse_update_single_column for completeness - Add duplicate column assignment validation in UPDATE executor - Prevent same column from being assigned multiple times in single UPDATE
1 parent ead1cf0 commit 19543f2

2 files changed

Lines changed: 13 additions & 0 deletions

File tree

nexum_core/src/executor/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@ impl Executor {
249249
let column_names: Vec<String> =
250250
schema.columns.iter().map(|c| c.name.clone()).collect();
251251

252+
// Check for duplicate column assignments
253+
let mut seen_columns: std::collections::HashSet<&str> =
254+
std::collections::HashSet::new();
255+
for (col_name, _) in &assignments {
256+
if !seen_columns.insert(col_name.as_str()) {
257+
return Err(StorageError::ReadError(format!(
258+
"Duplicate column assignment for '{}'",
259+
col_name
260+
)));
261+
}
262+
}
263+
252264
// Build column index map for assignments
253265
let mut assignment_indices: Vec<(usize, Value)> = Vec::new();
254266
for (col_name, new_value) in &assignments {

nexum_core/src/sql/parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ mod tests {
278278
assert_eq!(table, "users");
279279
assert_eq!(assignments.len(), 1);
280280
assert_eq!(assignments[0].0, "name");
281+
assert_eq!(assignments[0].1, Value::Text("Bob".to_string()));
281282
assert!(where_clause.is_some());
282283
}
283284
_ => panic!("Expected Update statement"),

0 commit comments

Comments
 (0)