You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the cast_as_quoted function to cast schema-qualified enums (e.g., schema_name.enum_name), the generated SQL incorrectly quotes the entire identifier as "schema_name.enum_name". Instead, each part of the schema and enum should be quoted separately, like "schema_name"."enum_name", to ensure correctness.
Steps to Reproduce
Define a schema-qualified enum:
CREATETYPEschema_name.enum_name AS ENUM ('value1', 'value2');
Use SeaQuery to cast a value using cast_as_quoted:
use sea_query::{tests_cfg::*,*};let query = Query::select().expr(Func::cast_as_quoted("some_value",Alias::new("schema_name.enum_name"),'"'.into(),)).to_owned();
Generate the SQL for PostgreSQL:
assert_eq!(
query.to_string(PostgresQueryBuilder),r#"SELECT CAST('some_value' AS "schema_name.enum_name")"#);
I find it counterintuitive that calling with Alias::new("schema_name.enum_name") results in "schema_name"."enum_name". The identifier should be fully determined at the alias definition stage and should not be modified.
To address this, we could modify cast_as_quoted to also accept Expr, allowing for cases like:
Description
When using the
cast_as_quoted
function to cast schema-qualified enums (e.g.,schema_name.enum_name
), the generated SQL incorrectly quotes the entire identifier as"schema_name.enum_name"
. Instead, each part of the schema and enum should be quoted separately, like"schema_name"."enum_name"
, to ensure correctness.Steps to Reproduce
cast_as_quoted
:Expected Behavior
The SQL should be generated as:
Actual Behavior
The SQL is incorrectly generated as:
Reproduces How Often
Always.
Versions
Additional Information
The text was updated successfully, but these errors were encountered: