Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
themaxgoldman opened this issue Apr 28, 2025 · 0 comments

Comments

@themaxgoldman
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant