loader

package
v5.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 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 Constraints

func Constraints(ctx context.Context) ([]*models.Constraint, error)

Constraints returns the database procs.

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 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 PQPostgresGoType

func PQPostgresGoType(d xo.Type, schema, itype, _ string) (string, string, error)

PQPostgresGoType parses a type into a Go type based on the databate type definition.

For array types, it returns the equivalent as defined in `github.com/lib/pq`.

func PostgresFlags

func PostgresFlags() []xo.Flag

PostgresFlags returnss the postgres flags.

func PostgresGoType

func PostgresGoType(d xo.Type, schema, itype 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 StdlibPostgresGoType

func StdlibPostgresGoType(d xo.Type, schema, itype, _ string) (string, string, error)

StdlibPostgresGoType parses a type into a Go type based on the databate type definition.

For array types, it returns the standard go array ([]<type>).

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 TableGenerations

func TableGenerations(ctx context.Context, table string) ([]*models.Generated, error)

TableGenerations returns the database table generations.

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)
	Constraints      func(context.Context, models.DB, string) ([]*models.Constraint, 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)
	TableGenerations func(context.Context, models.DB, string, string) ([]*models.Generated, 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