Documentation ¶
Overview ¶
Package loader contains database schema, type and query loaders.
Index ¶
- func EnableOids(ctx context.Context) bool
- func MysqlEnumValues(ctx context.Context, db models.DB, schema string, enum string) ([]*models.EnumValue, error)
- func MysqlGoType(ctx context.Context, typ string, nullable bool) (string, string, int, error)
- func MysqlQueryColumns(ctx context.Context, db models.DB, schema string, inspect []string) ([]*models.Column, error)
- func MysqlTables(ctx context.Context, db models.DB, schema string, kind string) ([]*models.Table, error)
- func OracleGoType(ctx context.Context, typ string, nullable bool) (string, string, int, error)
- func OracleQueryColumns(ctx context.Context, db models.DB, schema string, inspect []string) ([]*models.Column, error)
- func PostgresGoType(ctx context.Context, typ string, nullable bool) (string, string, int, error)
- func PostgresIndexColumns(ctx context.Context, db models.DB, schema string, table string, index string) ([]*models.IndexColumn, error)
- func PostgresQueryColumns(ctx context.Context, db models.DB, _ string, inspect []string) ([]*models.Column, error)
- func PostgresQueryStrip(query []string, queryComments []string)
- func PostgresTableColumns(ctx context.Context, db models.DB, schema string, table string) ([]*models.Column, error)
- func PostgresTables(ctx context.Context, db models.DB, schema string, relkind string) ([]*models.Table, error)
- func Register(loader *Loader)
- func Sqlite3ForeignKeys(ctx context.Context, db models.DB, schema string, table string) ([]*models.ForeignKey, error)
- func Sqlite3GoType(ctx context.Context, typ string, nullable bool) (string, string, int, error)
- func Sqlite3IndexColumns(ctx context.Context, db models.DB, schema string, table string, index string) ([]*models.IndexColumn, error)
- func Sqlite3Indexes(ctx context.Context, db models.DB, schema string, table string) ([]*models.Index, error)
- func Sqlite3QueryColumns(ctx context.Context, db models.DB, _ string, inspect []string) ([]*models.Column, error)
- func Sqlite3TableColumns(ctx context.Context, db models.DB, schema string, table string) ([]*models.Column, error)
- func Sqlite3Tables(ctx context.Context, db models.DB, schema string, kind string) ([]*models.Table, error)
- func SqlserverGoType(ctx context.Context, typ string, nullable bool) (string, string, int, error)
- func SqlserverQueryColumns(ctx context.Context, db models.DB, schema string, inspect []string) ([]*models.Column, error)
- func SqlserverTables(ctx context.Context, db models.DB, schema string, relkind string) ([]*models.Table, error)
- type ContextKey
- type Flag
- type FlagSet
- type Kind
- type Loader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnableOids ¶
EnableOids returns the EnableOids value from the context.
func MysqlEnumValues ¶
func MysqlEnumValues(ctx context.Context, db models.DB, schema string, enum string) ([]*models.EnumValue, error)
MysqlEnumValues loads the enum values.
func MysqlGoType ¶
MysqlGoType parse a mysql type into a Go type based on the column definition.
func MysqlQueryColumns ¶
func MysqlQueryColumns(ctx context.Context, db models.DB, schema string, inspect []string) ([]*models.Column, error)
MysqlQueryColumns parses the query and generates a type for it.
func MysqlTables ¶
func MysqlTables(ctx context.Context, db models.DB, schema string, kind string) ([]*models.Table, error)
MysqlTables returns the mysql tables.
func OracleGoType ¶
OracleGoType parse a oracle type into a Go type based on the column definition.
func OracleQueryColumns ¶
func OracleQueryColumns(ctx context.Context, db models.DB, schema string, inspect []string) ([]*models.Column, error)
OracleQueryColumns parses the query and generates a type for it.
func PostgresGoType ¶
PostgresGoType parse a type into a Go type based on the database type definition.
func PostgresIndexColumns ¶
func PostgresIndexColumns(ctx context.Context, db models.DB, schema string, table string, index string) ([]*models.IndexColumn, error)
PostgresIndexColumns returns the column list for an index.
FIXME: rewrite this using SQL exclusively using OVER
func PostgresQueryColumns ¶
func PostgresQueryColumns(ctx context.Context, db models.DB, _ string, inspect []string) ([]*models.Column, error)
PostgresQueryColumns parses the query and generates a type for it.
func PostgresQueryStrip ¶
PostgresQueryStrip strips '::type AS name' in queries.
func PostgresTableColumns ¶
func PostgresTableColumns(ctx context.Context, db models.DB, schema string, table string) ([]*models.Column, error)
PostgresTableColumns returns the columns for a table.
func PostgresTables ¶
func PostgresTables(ctx context.Context, db models.DB, schema string, relkind string) ([]*models.Table, error)
PostgresTables returns the Postgres tables with the manual PK information added. ManualPk is true when the table does not have a sequence defined.
func Sqlite3ForeignKeys ¶
func Sqlite3ForeignKeys(ctx context.Context, db models.DB, schema string, table string) ([]*models.ForeignKey, error)
Sqlite3ForeignKeys returns the sqlite3 foreign key info.
func Sqlite3GoType ¶
Sqlite3GoType parse a sqlite3 type into a Go type based on the column definition.
func Sqlite3IndexColumns ¶
func Sqlite3IndexColumns(ctx context.Context, db models.DB, schema string, table string, index string) ([]*models.IndexColumn, error)
Sqlite3IndexColumns returns the sqlite3 index column info.
func Sqlite3Indexes ¶
func Sqlite3Indexes(ctx context.Context, db models.DB, schema string, table string) ([]*models.Index, error)
Sqlite3Indexes returns the sqlite3 indexes info.
func Sqlite3QueryColumns ¶
func Sqlite3QueryColumns(ctx context.Context, db models.DB, _ string, inspect []string) ([]*models.Column, error)
Sqlite3QueryColumns parses a sqlite3 query and generates a type for it.
func Sqlite3TableColumns ¶
func Sqlite3TableColumns(ctx context.Context, db models.DB, schema string, table string) ([]*models.Column, error)
Sqlite3TableColumns returns the sqlite3 table column info.
func Sqlite3Tables ¶
func Sqlite3Tables(ctx context.Context, db models.DB, schema string, kind string) ([]*models.Table, error)
Sqlite3Tables returns the sqlite3 tables.
func SqlserverGoType ¶
SqlserverGoType parse a mssql type into a Go type based on the column definition.
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is a context key.
const OidsKey ContextKey = "oids"
OidsKey is the oids context key.
type Flag ¶
type Flag struct { ContextKey ContextKey Desc string PlaceHolder string Default string Short rune Value interface{} Enums []string }
Flag is a option flag.
type Loader ¶
type Loader struct { Driver string Flags []Flag ParamN func(int) string MaskFunc func() string Kind map[Kind]string GoType func(context.Context, string, bool) (string, string, int, error) QueryStrip func([]string, []string) Schema func(context.Context, models.DB) (string, error) Enums func(context.Context, models.DB, string) ([]*models.Enum, error) EnumValues func(context.Context, models.DB, string, string) ([]*models.EnumValue, error) Procs func(context.Context, models.DB, string) ([]*models.Proc, error) ProcParams func(context.Context, models.DB, string, string) ([]*models.ProcParam, error) Tables func(context.Context, models.DB, string, string) ([]*models.Table, error) TableColumns func(context.Context, models.DB, string, string) ([]*models.Column, error) TableForeignKeys func(context.Context, models.DB, string, string) ([]*models.ForeignKey, error) TableIndexes func(context.Context, models.DB, string, string) ([]*models.Index, error) IndexColumns func(context.Context, models.DB, string, string, string) ([]*models.IndexColumn, error) QueryColumns func(context.Context, models.DB, string, []string) ([]*models.Column, error) }
Loader loads type information from a database.