Documentation ¶
Overview ¶
Package loader loads query and schema information from mysql, oracle, postgres, sqlite3 and sqlserver databases.
Index ¶
- func EnumValues(ctx context.Context, enum string) ([]*models.EnumValue, error)
- func Enums(ctx context.Context) ([]*models.Enum, error)
- func Flags() []xo.FlagSet
- func IndexColumns(ctx context.Context, table, index string) ([]*models.IndexColumn, error)
- func MysqlEnumValues(ctx context.Context, db models.DB, schema string, enum string) ([]*models.EnumValue, error)
- func MysqlGoType(d xo.Type, schema, itype, utype string) (string, string, error)
- func NthParam(ctx context.Context) (func(int) string, error)
- func OracleGoType(d xo.Type, schema, itype, utype string) (string, string, error)
- func PostgresFlags() []xo.Flag
- func PostgresGoType(d xo.Type, schema, itype, utype string) (string, string, error)
- func PostgresIndexColumns(ctx context.Context, db models.DB, schema string, table string, index string) ([]*models.IndexColumn, error)
- func PostgresTableColumns(ctx context.Context, db models.DB, schema string, table string) ([]*models.Column, error)
- func PostgresViewStrip(query, inspect []string) ([]string, []string, []string, error)
- func ProcParams(ctx context.Context, id string) ([]*models.ProcParam, error)
- func Procs(ctx context.Context) ([]*models.Proc, error)
- func Register(typ string, loader Loader)
- func Schema(ctx context.Context) (string, error)
- func Sqlite3GoType(d xo.Type, schema, itype, utype string) (string, string, error)
- func SqlserverGoType(d xo.Type, schema, itype, utype string) (string, string, error)
- func SqlserverViewStrip(query, inspect []string) ([]string, []string, []string, error)
- func TableColumns(ctx context.Context, table string) ([]*models.Column, error)
- func TableForeignKeys(ctx context.Context, table string) ([]*models.ForeignKey, error)
- func TableIndexes(ctx context.Context, table string) ([]*models.Index, error)
- func TableSequences(ctx context.Context, table string) ([]*models.Sequence, error)
- func Tables(ctx context.Context, typ string) ([]*models.Table, error)
- func ViewCreate(ctx context.Context, id string, query []string) (sql.Result, error)
- func ViewDrop(ctx context.Context, id string) (sql.Result, error)
- func ViewSchema(ctx context.Context, id string) (string, error)
- func ViewStrip(ctx context.Context, query, inspect []string) ([]string, []string, []string, error)
- func ViewTruncate(ctx context.Context, id string) (sql.Result, error)
- type Loader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnumValues ¶
EnumValues returns the database enum values.
func Flags ¶
Flags returns the additional flags for the loaders.
These should be added to the invocation context for any call to a loader func.
func IndexColumns ¶
IndexColumns returns the database index columns.
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 NthParam ¶
NthParam returns a 0-based func to generate the nth param placeholder for database queries.
func OracleGoType ¶
OracleGoType parse a oracle type into a Go type based on the column definition.
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 PostgresTableColumns ¶
func PostgresTableColumns(ctx context.Context, db models.DB, schema string, table string) ([]*models.Column, error)
PostgresTableColumns returns the columns for a table.
func PostgresViewStrip ¶
PostgresViewStrip strips '::type AS name' in queries.
func ProcParams ¶
ProcParams returns the database proc params.
func Sqlite3GoType ¶
Sqlite3GoType parse a sqlite3 type into a Go type based on the column definition.
func SqlserverGoType ¶
SqlserverGoType parse a mssql type into a Go type based on the column definition.
func SqlserverViewStrip ¶
SqlserverViewStrip strips ORDER BY clauses from the passed query.
func TableColumns ¶
TableColumns returns the database table columns.
func TableForeignKeys ¶
TableForeignKeys returns the database table foreign keys.
func TableIndexes ¶
TableIndexes returns the database table indexes.
func TableSequences ¶
TableSequences returns the database table sequences.
func ViewCreate ¶
ViewCreate creates a introspection view of a query.
func ViewSchema ¶
ViewSchema returns the schema that the introspection view was created in.
Types ¶
type Loader ¶
type Loader struct { Type string Mask string Flags func() []xo.Flag 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) TableSequences func(context.Context, models.DB, string, string) ([]*models.Sequence, 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) ViewCreate func(context.Context, models.DB, string, string, []string) (sql.Result, error) ViewSchema func(context.Context, models.DB, string) (string, error) ViewTruncate func(context.Context, models.DB, string, string) (sql.Result, error) ViewDrop func(context.Context, models.DB, string, string) (sql.Result, error) ViewStrip func([]string, []string) ([]string, []string, []string, error) }
Loader loads type information from a database.