types

package
v1.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2026 License: MIT Imports: 7 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

func ValidateSQLCConfig

func ValidateSQLCConfig(projectPath string) error

Types

type SQLCConfig

type SQLCConfig struct {
	Version string `yaml:"version"`
	SQL     []struct {
		Schema  string `yaml:"schema"`
		Queries string `yaml:"queries"`
		Engine  string `yaml:"engine"`
		Gen     struct {
			Go struct {
				Package                   string `yaml:"package"`
				Out                       string `yaml:"out"`
				OutputDBFileName          string `yaml:"output_db_file_name"`
				OutputModelsFileName      string `yaml:"output_models_file_name"`
				EmitMethodsWithDBArgument bool   `yaml:"emit_methods_with_db_argument"`
				SQLPackage                string `yaml:"sql_package"`
				Overrides                 []struct {
					DBType string `yaml:"db_type"`
					GoType string `yaml:"go_type"`
				} `yaml:"overrides"`
			} `yaml:"go"`
		} `yaml:"gen"`
	} `yaml:"sql"`
}

type TypeMapper

type TypeMapper struct {
	DatabaseType string
	TypeMap      map[string]string
	Overrides    []TypeOverride
}

func NewTypeMapper

func NewTypeMapper(databaseType string) *TypeMapper

func (*TypeMapper) GenerateConversionFromDB

func (tm *TypeMapper) GenerateConversionFromDB(fieldName, sqlcType, goType string) string

func (*TypeMapper) GenerateConversionToDB

func (tm *TypeMapper) GenerateConversionToDB(
	sqlcType string,
	goType string,
	valueExpr string,
) string

func (*TypeMapper) GenerateZeroCheck

func (tm *TypeMapper) GenerateZeroCheck(
	goType string,
	valueExpr string,
) string

func (*TypeMapper) GetDatabaseType

func (tm *TypeMapper) GetDatabaseType() string

func (*TypeMapper) MapSQLTypeToGo

func (tm *TypeMapper) MapSQLTypeToGo(
	sqlType string,
	nullable bool,
) (goType, sqlcType, packageName string, err error)

type TypeOverride

type TypeOverride struct {
	DatabaseType string
	GoType       string
	Package      string
	Nullable     bool
}

Jump to

Keyboard shortcuts

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