Skip to main content

find_duplicate_sql_value

Function find_duplicate_sql_value 

Source
pub fn find_duplicate_sql_value(values: &[SqlValue]) -> Option<(usize, usize)>
Expand description

Detect the first duplicate value in a list of SqlValues, used for batch_upsert input deduplication. Linear-scan with PartialEq rather than the hashed variant in cratestack-core because SqlValue::Float and SqlValue::Decimal don’t admit a sound Hash impl.

At the documented batch cap (≤ 1000 items) the O(N²) cost is on the order of a million PartialEq comparisons, which dominates nothing next to a single round-trip to Postgres. Returns (first_index, duplicate_index) on collision, matching cratestack_core::find_duplicate_position.