types

package
v1.0.0-beta.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoTypeMapperFound = errors.New("no type mapper found for database type")
	ErrUnsupportedType   = errors.New("unsupported database type")
)

Functions

func FormatCamelCase

func FormatCamelCase(dbColumnName string) string

func FormatDisplayName

func FormatDisplayName(dbColumnName string) string

func FormatFieldName

func FormatFieldName(dbColumnName string) string

Types

type TypeMapper

type TypeMapper struct {
	DatabaseType string
	NullType     string // "pointer", "sql.Null", or "bun.Null"
	Overrides    []TypeOverride
}

func NewTypeMapper

func NewTypeMapper(databaseType string) *TypeMapper

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

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

type TypeOverride struct {
	DatabaseType string
	GoType       string
	Package      string
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL