loader

package
v0.0.0-...-e0d90fa Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package loader loads query and schema information from mysql, oracle, postgres, sqlite3 and sqlserver databases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnumValues

func EnumValues(ctx context.Context, enum string) ([]*models.EnumValue, error)

EnumValues returns the database enum values.

func Enums

func Enums(ctx context.Context) ([]*models.Enum, error)

Enums returns the database enums.

func Flags

func Flags() []xo.FlagSet

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

func IndexColumns(ctx context.Context, table, index string) ([]*models.IndexColumn, error)

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

func MysqlGoType(d xo.Type, schema, itype, utype string) (string, string, error)

MysqlGoType parse a mysql type into a Go type based on the column definition.

func NthParam

func NthParam(ctx context.Context) (func(int) string, error)

NthParam returns a 0-based func to generate the nth param placeholder for database queries.

func OracleGoType

func OracleGoType(d xo.Type, schema, itype, utype string) (string, string, error)

OracleGoType parse a oracle type into a Go type based on the column definition.

func PostgresFlags

func PostgresFlags() []xo.Flag

PostgresFlags returnss the postgres flags.

func PostgresGoType

func PostgresGoType(d xo.Type, schema, itype, utype string) (string, string, error)

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

func PostgresViewStrip(query, inspect []string) ([]string, []string, []string, error)

PostgresViewStrip strips '::type AS name' in queries.

func ProcParams

func ProcParams(ctx context.Context, id string) ([]*models.ProcParam, error)

ProcParams returns the database proc params.

func Procs

func Procs(ctx context.Context) ([]*models.Proc, error)

Procs returns the database procs.

func Register

func Register(typ string, loader Loader)

Register registers a database loader.

func Schema

func Schema(ctx context.Context) (string, error)

Schema loads the active schema name from the context.

func Sqlite3GoType

func Sqlite3GoType(d xo.Type, schema, itype, utype string) (string, string, error)

Sqlite3GoType parse a sqlite3 type into a Go type based on the column definition.

func SqlserverGoType

func SqlserverGoType(d xo.Type, schema, itype, utype string) (string, string, error)

SqlserverGoType parse a mssql type into a Go type based on the column definition.

func SqlserverViewStrip

func SqlserverViewStrip(query, inspect []string) ([]string, []string, []string, error)

SqlserverViewStrip strips ORDER BY clauses from the passed query.

func TableColumns

func TableColumns(ctx context.Context, table string) ([]*models.Column, error)

TableColumns returns the database table columns.

func TableForeignKeys

func TableForeignKeys(ctx context.Context, table string) ([]*models.ForeignKey, error)

TableForeignKeys returns the database table foreign keys.

func TableIndexes

func TableIndexes(ctx context.Context, table string) ([]*models.Index, error)

TableIndexes returns the database table indexes.

func TableSequences

func TableSequences(ctx context.Context, table string) ([]*models.Sequence, error)

TableSequences returns the database table sequences.

func Tables

func Tables(ctx context.Context, typ string) ([]*models.Table, error)

Tables returns the database tables.

func ViewCreate

func ViewCreate(ctx context.Context, id string, query []string) (sql.Result, error)

ViewCreate creates a introspection view of a query.

func ViewDrop

func ViewDrop(ctx context.Context, id string) (sql.Result, error)

ViewDrop drops the introspection view.

func ViewSchema

func ViewSchema(ctx context.Context, id string) (string, error)

ViewSchema returns the schema that the introspection view was created in.

func ViewStrip

func ViewStrip(ctx context.Context, query, inspect []string) ([]string, []string, []string, error)

ViewStrip post processes the query and inspected query, altering as necessary and building a set of comments for the query.

func ViewTruncate

func ViewTruncate(ctx context.Context, id string) (sql.Result, error)

ViewTruncate truncates the introspection view.

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.

Jump to

Keyboard shortcuts

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