removing decimal with precision and decimal count

This commit is contained in:
Filipriec
2026-08-24 21:31:06 +02:00
parent 16670f4375
commit 5e9b86c1fb
22 changed files with 50 additions and 467 deletions

View File

@@ -93,9 +93,7 @@ pub fn normalize_exact(input: &str) -> String {
/// names, so this deliberately matches the catalog vocabulary.
pub fn canonical_exact_search_value(input: &str, field_type: &str) -> Result<String, String> {
let normalized_type = field_type.trim().to_ascii_lowercase();
if matches!(normalized_type.as_str(), "numeric" | "money")
|| normalized_type.starts_with("decimal(")
{
if matches!(normalized_type.as_str(), "numeric" | "money") {
return input
.parse::<rust_decimal::Decimal>()
.map(|value| value.normalize().to_string())
@@ -288,10 +286,6 @@ mod tests {
assert_eq!(canonical_exact_search_value("001", "link(adresar)").unwrap(), "1");
assert_eq!(canonical_exact_search_value("10.50", "numeric").unwrap(), "10.5");
assert_eq!(canonical_exact_search_value("10.50", "money").unwrap(), "10.5");
assert_eq!(
canonical_exact_search_value("10.50", "decimal(12, 2)").unwrap(),
"10.5"
);
}
}