Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoTypeMapperFound is returned when no type mapper found. ErrNoTypeMapperFound = errors.New("no type mapper found for database type") // ErrUnsupportedType is returned when unsupported type. ErrUnsupportedType = errors.New("unsupported database type") )
Functions ¶
func FormatCamelCase ¶
FormatCamelCase formats camel case.
func FormatDisplayName ¶
FormatDisplayName formats display name.
func FormatFieldName ¶
FormatFieldName formats field name.
Types ¶
type TypeMapper ¶
type TypeMapper struct {
DatabaseType string
NullType string // "pointer", "sql.Null", or "bun.Null"
Overrides []TypeOverride
}
TypeMapper represents type mapper.
func NewTypeMapper ¶
func NewTypeMapper(databaseType string) *TypeMapper
NewTypeMapper creates a new type mapper.
func (*TypeMapper) BuildBunTag ¶ added in v1.0.0
func (tm *TypeMapper) BuildBunTag(col *catalog.Column) string
BuildBunTag returns the value of the `bun:"..."` struct tag for a column. Only emits attributes that affect query/marshaling behavior — column name, primary-key marker, and a `type:` hint where bun's default mapping would otherwise be wrong (notably uuid columns). DDL-only attributes (notnull/nullzero/default/unique/autoincrement) are intentionally omitted because andurel does not use bun for schema management.
func (*TypeMapper) GetDatabaseType ¶
func (tm *TypeMapper) GetDatabaseType() string
GetDatabaseType returns database type.
func (*TypeMapper) MapSQLTypeToGo ¶
func (tm *TypeMapper) MapSQLTypeToGo( sqlType string, nullable bool, ) (goType, packageName string, err error)
MapSQLTypeToGo returns the Go type for a SQL column. Nullable columns are wrapped according to tm.NullType ("pointer" → *string, "sql.Null" → sql.NullString, "bun.Null" → bun.NullString). The second return value is the import path required for the type, or "" if it is a builtin.
type TypeOverride ¶
TypeOverride lets users map a SQL database type to a custom Go type. When the column is nullable, the resulting Go type will be wrapped according to the TypeMapper's NullType setting.