Skip to content

PostgreSQL enum types become interface{} with managed: true - best practices? #3948

Open
@themaxgoldman

Description

@themaxgoldman

We've encountered an issue when using managed: true in our SQLC configuration with PostgreSQL databases.
Problem:
When using local schema parsing (managed: false), SQLC correctly interprets PostgreSQL enum types and generates proper type-safe Go types. However, when we enable managed: true to connect to a real database, the same enum fields are generated as interface{} instead of their strongly-typed equivalents.
For example, with managed: false:

type CreateDocumentParams struct {
    ID uuid.UUID
    Type DocumentType  // Properly typed enum
    // ...other fields
}

But with managed: true:

type CreateDocumentParams struct {
    ID uuid.UUID
    Type interface{}  // No longer properly typed
    // ...other fields
}

This happens despite the enum type definitions being present in our migration files that SQLC is using for schema information.
What's the best practice for handling PostgreSQL enum types when using managed mode? It seems unnecessary to manually override types that SQLC could/should detect from the schema. Is there a configuration option we're missing?
We want to use managed: true for its benefits, especially with sqlc vet, but the loss of type safety for enums is problematic.
Any guidance would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions