types

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Info

type Info struct {
	// The Name of the type
	Name string
	// The package that the type with Name is in
	Pkg string
	// The name of a nullable version of the type
	NullName string
	// The package that the type with NullName is in (may be blank if
	// the same as Pkg)
	NullPkg string
	// The name of a nullable version of the type that should be used
	// for interfacing with the database. This type will get converted
	// into `NullName` before it reaches any public-facing part of the
	// generated code.
	ScanNullName string
	// The package that the type with ScanNullName type is in. May be
	// blank if same as either one of the other two packages.
	ScanNullPkg string
	// A function for transforming a variable with the given name of type
	// ScanNullName into a block of code which evaluates to a value of type
	// NullName
	NullConvertFunc func(string) string
	// Given a variable name, SqlReceiver must return an appropriate wrapper
	// around that variable which can be passed as a parameter to Rows.Scan.
	// For many simple types, SqlReceiver will just wrap the variable in a
	// reference.
	SqlReceiver func(string) string
	// Given a variable name, SqlReceiver must return an appropriate wrapper
	// around that variable which can be passed as a parameter to Rows.Scan.
	// Must work for the nullable receiver wrapper.
	NullSqlReceiver func(string) string
	// Given a variable name, SqlArgument must return an appropriate wrapper
	// around that variable which can be passed as a parameter to `sql.Query`
	SqlArgument func(string) string
	// Given a variable name of type pointer-to-type, NullSqlArgument must return
	// an appropriate value to pas as a parameter to `sql.Query`
	NullSqlArgument func(string) string
	// If this is a timestamp type, it has a time zone, otherwise this field
	// is meaningless.
	IsTimestampWithZone bool
	// contains filtered or unexported fields
}

type Resolver

type Resolver struct {
	// contains filtered or unexported fields
}

func NewResolver

func NewResolver(db *sql.DB, registerImport func(string)) *Resolver

func (*Resolver) EmitStructType

func (r *Resolver) EmitStructType(typeName string, genCtx interface{}) error

genCtx should be a meta.TableGenCtx. We ask for an interface{} param to avoid a cyclic dependency. Using an interface{} is fine because we are just going to pass it into the template evaluator anyway.

func (*Resolver) EmitType

func (r *Resolver) EmitType(name string, sig string, body string) error

func (*Resolver) Gen

func (r *Resolver) Gen(into io.Writer) error

emit all the types we have build up into the given Writer

func (*Resolver) Probe

func (r *Resolver) Probe(name string) bool

func (*Resolver) Resolve

func (r *Resolver) Resolve(conf *config.DbConfig) error

Resolve performs any ahead-of-time computations needed to service subsequent type resolution requests.

This method _must_ be called before any other methods are called.

func (*Resolver) TypeInfoOf

func (r *Resolver) TypeInfoOf(pgTypeName string) (*Info, error)

Jump to

Keyboard shortcuts

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