Inconsistent casing in custom PostgreSQL types #4615
Replies: 2 comments
-
Can you indicate how the As for your "solutions": Neither one is a solution as the type name can totally be upper-case there. So it's not helpful to reject these values or change the query. See for example this test |
Beta Was this translation helpful? Give feedback.
-
Turns out the issue was all regarding the use of quotes around the name of the custom type: This will be inserted in CREATE TYPE "My_Type" AS ENUM ('foo', 'bar'); while this will be inserted as CREATE TYPE My_Type AS ENUM ('foo', 'bar'); I will make a PR to pgrx to add the quotes to avoid such issues in the future. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
At this time, when I define a custom type like:
with its
SqlType
being:and the postgres
SQL
binding being:When running queries including the aforementioned type I get:
"type \"NameplateCategory\" does not exist"
as the type being checked for from the
pg_type
table is lowercased, and equal tonameplatecategory
, and therefore it requires me to change thepostgres_type
name
to:Should we:
pg_type
table to lowercase the value before executing the check? I am not sure where this happens in diesel btw, but I am certain it happens as I see the message being sent via wireshark.postgres_type
name
to solely accept lowercased values and raise a compile time error when the provided value is not lowercased?Happy to do a PR to fix either things. I would be partial to the option 1 as I like the casing consistency, but also option 2 is absolutely viable for me as I primarily want compile time checks that let me know about this issues before I try to run the code.
Luca
Beta Was this translation helpful? Give feedback.
All reactions