Skip to content

Commit

Permalink
fix all Postgres tests!
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Apr 18, 2023
1 parent b112f89 commit 2369ff2
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,25 +162,25 @@ type Postgres_Dialect
this situations and overrides the type to make it correct.
adapt_unified_column : Internal_Column -> Value_Type -> (SQL_Expression -> SQL_Type_Reference) -> Internal_Column
adapt_unified_column self column approximate_result_type infer_result_type_from_database_callback =
case approximate_result_type of
## We apply the override only if the result type is computed to be
variable-length, but the Database wrongly reports fixed-length.
Value_Type.Char _ True ->
needs_char_length_override_check = case approximate_result_type of
Value_Type.Char _ _ -> True
_ -> False
case needs_char_length_override_check of
True ->
type_mapping = self.get_type_mapping
db_type = type_mapping.sql_type_to_value_type column.sql_type_reference.get
case db_type of
Value_Type.Char _ False ->
type_override = type_mapping.value_type_to_sql approximate_result_type Problem_Behavior.Report_Error
type_override.catch Inexact_Type_Coercion _->
Panic.throw <|
Illegal_State.Error "The target type ("+db_type.to_display_text+") that we need to cast to seems to not be supported by the Dialect. This is not expected. It is a bug in the Database library."
self.make_cast column type_override infer_result_type_from_database_callback
Value_Type.Char _ True ->
## The Database correctly reports the type as variable-length.
column
Value_Type.Char _ _ -> case db_type == approximate_result_type of
True -> column
False ->
type_override = type_mapping.value_type_to_sql approximate_result_type Problem_Behavior.Report_Error
type_override.catch Inexact_Type_Coercion _->
Panic.throw <|
Illegal_State.Error "The target type ("+db_type.to_display_text+") that we need to cast to seems to not be supported by the Dialect. This is not expected. It is a bug in the Database library."
self.make_cast column type_override infer_result_type_from_database_callback
_ -> Panic.throw <|
Illegal_State.Error "The type computed by our logic is Char, but the Database computed a non-text type ("+db_type.to_display_text+"). This should never happen and should be reported as a bug in the Database library."
_ -> column
False -> column

## PRIVATE
prepare_fetch_types_query : SQL_Expression -> Context -> SQL_Statement
Expand Down

0 comments on commit 2369ff2

Please sign in to comment.