diff --git a/sbroad-cartridge/src/cartridge/config/tests.rs b/sbroad-cartridge/src/cartridge/config/tests.rs index 661ae9ed461a5e487fa56ff2fa093f1f2ffdc849..dbd844010e362d87468c7bb3504ac6da0ba7071c 100644 --- a/sbroad-cartridge/src/cartridge/config/tests.rs +++ b/sbroad-cartridge/src/cartridge/config/tests.rs @@ -216,6 +216,9 @@ fn test_invalid_schema() { assert_eq!( s.load_schema(test_schema).unwrap_err(), - SbroadError::NotImplemented(Entity::Type, "invalid_type".into()) + SbroadError::Invalid( + Entity::Type, + Some("Unable to transform invalid_type to Type.".into()) + ) ); } diff --git a/sbroad-core/src/ir/relation.rs b/sbroad-core/src/ir/relation.rs index 6cac0316d187b1667150d210e486f597d761f3ad..88573b81c7e7a3301dd06cd25df33b5d5c80a1fd 100644 --- a/sbroad-core/src/ir/relation.rs +++ b/sbroad-core/src/ir/relation.rs @@ -148,7 +148,7 @@ impl Type { "decimal" => Ok(Type::Decimal), "double" => Ok(Type::Double), "integer" => Ok(Type::Integer), - "number" => Ok(Type::Number), + "number" | "numeric" => Ok(Type::Number), "scalar" => Ok(Type::Scalar), "string" | "text" => Ok(Type::String), "uuid" => Ok(Type::Uuid), @@ -156,26 +156,9 @@ impl Type { "array" => Ok(Type::Array), "any" => Ok(Type::Any), "map" => Ok(Type::Map), - v => Err(SbroadError::NotImplemented(Entity::Type, v.to_smolstr())), - } - } - - /// Type constructor (in a case of the possibly incorrect input - - /// VALUES with the first NULL row can return incorrect type in the metadata). - /// - /// # Errors - /// - Invalid type name. - pub fn new_from_possibly_incorrect(s: &str) -> Result<Self, SbroadError> { - match s.to_string().to_lowercase().as_str() { - "boolean" | "decimal" | "double" | "integer" | "number" | "numeric" | "scalar" - | "string" | "uuid" | "text" | "unsigned" => Ok(Type::Scalar), - "array" => Ok(Type::Array), - "map" => Ok(Type::Map), - "datetime" => Ok(Type::Datetime), - "any" => Ok(Type::Any), v => Err(SbroadError::Invalid( Entity::Type, - Some(format_smolstr!("Unexpected type {v} met during ")), + Some(format_smolstr!("Unable to transform {v} to Type.")), )), } }