number can be converted to the string as a backup for server to validate it
This commit is contained in:
@@ -112,16 +112,10 @@ pub(crate) fn csv_value(locale: Locale, raw: &str, data_type: &str) -> Result<Va
|
||||
normalized.as_str(),
|
||||
"INTEGER" | "INT" | "INT4" | "INT2" | "BIGINT" | "INT8"
|
||||
) {
|
||||
let integer = raw
|
||||
.parse::<i64>()
|
||||
.map_err(|_| {
|
||||
tr!(
|
||||
locale,
|
||||
"import-err-bad-integer",
|
||||
"value" => raw.to_string(),
|
||||
)
|
||||
})?;
|
||||
Kind::NumberValue(integer as f64)
|
||||
match raw.parse::<i64>() {
|
||||
Ok(integer) => Kind::NumberValue(integer as f64),
|
||||
Err(_) => Kind::StringValue(raw.to_string()),
|
||||
}
|
||||
} else {
|
||||
Kind::StringValue(raw.to_string())
|
||||
};
|
||||
@@ -188,5 +182,9 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn integer_columns_pass_non_numeric_text_to_the_backend() {
|
||||
let value = csv_value(Locale::English, "KUPE SRO", "BIGINT").unwrap();
|
||||
assert_eq!(value.kind, Some(Kind::StringValue("KUPE SRO".to_string())));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user