From a6b5c0b4df952cc5465d3aefc8b8c5c85325adee Mon Sep 17 00:00:00 2001 From: py Date: Tue, 12 Nov 2024 13:30:35 +0530 Subject: [PATCH] add type representation for scalar types --- crates/configuration/src/version1.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/configuration/src/version1.rs b/crates/configuration/src/version1.rs index 0e016da..fb8286f 100644 --- a/crates/configuration/src/version1.rs +++ b/crates/configuration/src/version1.rs @@ -409,6 +409,27 @@ fn get_scalar_types(type_names: &Vec, schema_name: String) -> database _ => "any", }; let type_name_scalar = ScalarTypeName::new(type_name.into()); + let type_rep = match type_item.name.as_str().to_lowercase().as_str() { + "bool" | "boolean" => Some(database::TypeRepresentation::Boolean), + "int16" | "smallint" => Some(database::TypeRepresentation::Int16), + "int" | "int32" | "integer" => Some(database::TypeRepresentation::Int32), + "int64" | "bigint" => Some(database::TypeRepresentation::Int64), + "numeric" => Some(database::TypeRepresentation::BigDecimal), + "float64" | "float" |"float8" => Some(database::TypeRepresentation::Float64), + "real" | "float4" => Some(database::TypeRepresentation::Float32), + "double precision" => Some(database::TypeRepresentation::Float64), + "text" => Some(database::TypeRepresentation::String), + "string" => Some(database::TypeRepresentation::String), + "character" => Some(database::TypeRepresentation::String), + "json" | "jsonb" => Some(database::TypeRepresentation::Json), + "date" => Some(database::TypeRepresentation::Date), + "timetz" | "time with time zone" => Some(database::TypeRepresentation::Timetz), + "time" | "time without time zone" => Some(database::TypeRepresentation::Time), + "timestamptz" | "timestamp with time zone" => Some(database::TypeRepresentation::Timestamptz), + "timestamp" | "timestamp without time zone" => Some(database::TypeRepresentation::Timestamp), + "uuid" => Some(database::TypeRepresentation::UUID), + _ => None, + }; scalar_types.insert( type_name_scalar.clone(), database::ScalarType { @@ -417,7 +438,7 @@ fn get_scalar_types(type_names: &Vec, schema_name: String) -> database comparison_operators: get_comparison_operators_for_type(&type_name_scalar), aggregate_functions: get_aggregate_functions_for_type(&type_name_scalar), description: None, - type_representation: None, + type_representation: (type_rep), }, // get_comparison_operators_for_type(&type_name.name), );