fix: resolve NotSupportedException for schema-qualified PostgreSQL enum types#421
Merged
Conversation
…um types When a PostgreSQL column references an enum type with schema qualification (e.g., `block_type public.post_block_type`), sqlc sets `column.Type.Schema` to `public`. However, `ConstructEnumsLookup` normalizes default schema enums under key `` (empty string), causing `GetEnumType` to fail the lookup and throw `NotSupportedException`. Fixed by normalizing the schema name in `GetEnumSchemaAndName` to empty string when it matches the driver's DefaultSchema. Changes: - Drivers/NpgsqlDriver.cs: normalize default schema in GetEnumSchemaAndName - unit-tests/CodegenTests/CodegenSchemaTests.cs: add failing-then-passing test - examples/config/postgresql/types/: add schema-qualified enum table + queries - examples/Npgsql*Example/: regenerated code with new model/queries - end2end/: add truncation for new table in e2e TearDown
8.4.6 was removed from the MySQL CDN (404), causing Chocolatey install to fail. 8.4.9 is the latest 8.4.x patch available.
The pinned versions 8.4.6 and 8.4.9 both fail — 8.4.6 downloads from a dead CDN URL, and 8.4.9 doesn't exist on Chocolatey. Removing the pin lets Chocolatey resolve the latest approved version with a valid URL.
…types table Move c_qualified_enum (public.c_enum) into the existing postgres_special_types table instead of a separate postgres_qualified_enum_types table, per PR feedback. The schema-qualified enum type is tested alongside the existing unqualified c_enum column in the same table and its queries. This avoids adding a new table to the schema.
SockworkOrange
approved these changes
Jul 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #399
When a PostgreSQL column references an enum type with schema qualification (e.g.,
block_type public.post_block_type), sqlc setscolumn.Type.Schemato"public". However,ConstructEnumsLookupnormalizes default schema enums under key""(empty string), causingGetEnumTypeto fail the lookup and throwNotSupportedException.Changes
Drivers/NpgsqlDriver.cs— Normalize the schema name inGetEnumSchemaAndNameto empty string when it matchesDefaultSchema, making it consistent withConstructEnumsLookup.unit-tests/CodegenTests/CodegenSchemaTests.cs— AddedTestDefaultSchemaEnumWithSchemaQualifiedTypethat constructs aGenerateRequestwithcolumn.Type.Schema = "public"and asserts successful generation (was throwing before the fix).examples/config/postgresql/types/— Addedpostgres_qualified_enum_typestable with a column referencingpublic.c_enum(schema-qualified), plus INSERT/SELECT/TRUNCATE queries. This exercises the fixed code path in e2e tests.examples/Npgsql*— Regenerated all Npgsql example code to include the new model/queries.end2end/— AddedTruncatePostgresQualifiedEnumTypesAsyncto both Npgsql and NpgsqlDapper tester TearDown methods.Testing
postgres_qualified_enum_typeswithpublic.c_enumcolumn verifies the fix end-to-end