What problem does it solve?
Many Go types cannot be directly mapped to database column representations, making it difficult to store structured, encrypted, or dialect-specific values reliably; this Skill provides patterns and interfaces to convert complex Go values into database-compatible formats for GORM models.
Core Features & Use Cases
- Scanner and Valuer Integration: Implement sql.Scanner and driver.Valuer to control how values are read from and written to the database.
- Dialect-Specific Types: Define GormDBDataType to return database-specific column types for migrations across MySQL, Postgres, SQLite, and others.
- SQL Expression Support: Provide GormValue/GormValuer implementations to persist values using SQL expressions or database functions, useful for spatial types or context-aware encryption.
- Use Case: Store JSON objects as JSONB on Postgres, JSON on MySQL, or TEXT on SQLite while preserving queryability and migration correctness.
Quick Start
Create a GORM model field that implements Scanner and Valuer, implement GormDBDataType for your target dialect, and run AutoMigrate to verify the generated column type.