Skip to content

Commit be0ef72

Browse files
committed
planner: write the vector-primary key guard as is_none_or
`cargo clippy --profile ci -p nodedb --all-targets --all-features -- -D warnings` aborts on this expression at `vector_primary.rs:161`: error: this boolean expression can be simplified = help: ... #nonminimal_bool so the lint job is red on `main` for every branch, and the first thing it reports is a file no branch has touched. Clippy's own suggested rewrite is this one, and it is the negation identity `is_none_or(f) == !is_some_and(!f)`: `!get(k).is_some_and(|v| !matches!(v, SqlValue::Null))` becomes `get(k).is_none_or(|v| matches!(v, SqlValue::Null))`. All three cases agree, including the one a reader might expect to differ — an absent key inserts the key-column value under both spellings: present non-null -> false / false present Null -> true / true absent -> true / true Verified: `main` exits 101 on this file, this branch exits 0.
1 parent f18b31e commit be0ef72

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎nodedb/src/control/planner/sql_plan_convert/dml/vector_primary.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ pub(in super::super) fn convert_vector_primary_insert(
161161
let key_column = declared.as_deref().unwrap_or(primary_key);
162162
let mut fields = row.payload_fields.clone();
163163
if !is_auto_rowid_pk(primary_key)
164-
&& !fields
164+
&& fields
165165
.get(key_column)
166-
.is_some_and(|v| !matches!(v, SqlValue::Null))
166+
.is_none_or(|v| matches!(v, SqlValue::Null))
167167
{
168168
fields.insert(key_column.to_string(), SqlValue::String(doc_id.clone()));
169169
}

0 commit comments

Comments
 (0)