Documentation ¶
Overview ¶
Package informationschema provides metadata readers that query tables from the information_schema schema. It tries to be database agnostic, but there is a set of options to configure what tables and columns to expect.
Index ¶
- Constants
- func New(opts ...metadata.ReaderOption) func(drivers.DB, ...metadata.ReaderOption) metadata.Reader
- func WithCheckConstraints(con bool) metadata.ReaderOption
- func WithConstraints(con bool) metadata.ReaderOption
- func WithCurrentSchema(expr string) metadata.ReaderOption
- func WithCustomClauses(cols map[ClauseName]string) metadata.ReaderOption
- func WithDataTypeFormatter(f func(metadata.Column) string) metadata.ReaderOption
- func WithFunctions(fun bool) metadata.ReaderOption
- func WithIndexes(ind bool) metadata.ReaderOption
- func WithPlaceholder(pf func(int) string) metadata.ReaderOption
- func WithSequences(seq bool) metadata.ReaderOption
- func WithSystemSchemas(schemas []string) metadata.ReaderOption
- type ClauseName
- type InformationSchema
- func (s InformationSchema) Columns(f metadata.Filter) (*metadata.ColumnSet, error)
- func (s InformationSchema) ConstraintColumns(f metadata.Filter) (*metadata.ConstraintColumnSet, error)
- func (s InformationSchema) Constraints(f metadata.Filter) (*metadata.ConstraintSet, error)
- func (s InformationSchema) FunctionColumns(f metadata.Filter) (*metadata.FunctionColumnSet, error)
- func (s InformationSchema) Functions(f metadata.Filter) (*metadata.FunctionSet, error)
- func (s InformationSchema) IndexColumns(f metadata.Filter) (*metadata.IndexColumnSet, error)
- func (s InformationSchema) Indexes(f metadata.Filter) (*metadata.IndexSet, error)
- func (s InformationSchema) Schemas(f metadata.Filter) (*metadata.SchemaSet, error)
- func (s InformationSchema) Sequences(f metadata.Filter) (*metadata.SequenceSet, error)
- func (s *InformationSchema) SetLimit(l int)
- func (s InformationSchema) Tables(f metadata.Filter) (*metadata.TableSet, error)
- type Logger
Constants ¶
const ( ColumnsDataType = ClauseName("columns.data_type") ColumnsColumnSize = ClauseName("columns.column_size") ColumnsNumericScale = ClauseName("columns.numeric_scale") ColumnsNumericPrecRadix = ClauseName("columns.numeric_precision_radix") ColumnsCharOctetLength = ClauseName("columns.character_octet_length") FunctionColumnsColumnSize = ClauseName("function_columns.column_size") FunctionColumnsNumericScale = ClauseName("function_columns.numeric_scale") FunctionColumnsNumericPrecRadix = ClauseName("function_columns.numeric_precision_radix") FunctionColumnsCharOctetLength = ClauseName("function_columns.character_octet_length") FunctionsSecurityType = ClauseName("functions.security_type") ConstraintIsDeferrable = ClauseName("constraint_columns.is_deferrable") ConstraintInitiallyDeferred = ClauseName("constraint_columns.initially_deferred") ConstraintJoinCond = ClauseName("constraint_join.fk") SequenceColumnsIncrement = ClauseName("sequence_columns.increment") )
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(opts ...metadata.ReaderOption) func(drivers.DB, ...metadata.ReaderOption) metadata.Reader
New InformationSchema reader
func WithCheckConstraints ¶ added in v0.9.0
func WithCheckConstraints(con bool) metadata.ReaderOption
WithCheckConstraints when the `statistics` table exists
func WithConstraints ¶ added in v0.9.0
func WithConstraints(con bool) metadata.ReaderOption
WithConstraints when the `statistics` table exists
func WithCurrentSchema ¶ added in v0.9.0
func WithCurrentSchema(expr string) metadata.ReaderOption
WithCurrentSchema expression to filter by when OnlyVisible filter is true
func WithCustomClauses ¶ added in v0.9.0
func WithCustomClauses(cols map[ClauseName]string) metadata.ReaderOption
WithCustomClauses to use different expressions for some columns
func WithDataTypeFormatter ¶ added in v0.11.1
func WithDataTypeFormatter(f func(metadata.Column) string) metadata.ReaderOption
WithDataTypeFormatter function to build updated string represenation of data type from Column
func WithFunctions ¶
func WithFunctions(fun bool) metadata.ReaderOption
WithFunctions when the `routines` and `parameters` tables exists
func WithIndexes ¶
func WithIndexes(ind bool) metadata.ReaderOption
WithIndexes when the `statistics` table exists
func WithPlaceholder ¶
func WithPlaceholder(pf func(int) string) metadata.ReaderOption
WithPlaceholder generator function, that usually returns either `?` or `$n`, where `n` is the argument.
func WithSequences ¶
func WithSequences(seq bool) metadata.ReaderOption
WithSequences when the `sequences` table exists
func WithSystemSchemas ¶ added in v0.9.0
func WithSystemSchemas(schemas []string) metadata.ReaderOption
WithSystemSchemas that are ignored unless WithSystem filter is true
Types ¶
type ClauseName ¶ added in v0.9.0
type ClauseName string
type InformationSchema ¶
type InformationSchema struct { metadata.LoggingReader // contains filtered or unexported fields }
InformationSchema metadata reader
func (InformationSchema) Columns ¶
Columns from selected catalog (or all, if empty), matching schemas and tables
func (InformationSchema) ConstraintColumns ¶ added in v0.9.0
func (s InformationSchema) ConstraintColumns(f metadata.Filter) (*metadata.ConstraintColumnSet, error)
ConstraintColumns from selected catalog (or all, if empty), matching schemas and constraints
func (InformationSchema) Constraints ¶ added in v0.9.0
func (s InformationSchema) Constraints(f metadata.Filter) (*metadata.ConstraintSet, error)
Constraintes from selected catalog (or all, if empty), matching schemas and names
func (InformationSchema) FunctionColumns ¶
func (s InformationSchema) FunctionColumns(f metadata.Filter) (*metadata.FunctionColumnSet, error)
FunctionColumns (arguments) from selected catalog (or all, if empty), matching schemas and functions
func (InformationSchema) Functions ¶
func (s InformationSchema) Functions(f metadata.Filter) (*metadata.FunctionSet, error)
Functions from selected catalog (or all, if empty), matching schemas, names and types
func (InformationSchema) IndexColumns ¶
func (s InformationSchema) IndexColumns(f metadata.Filter) (*metadata.IndexColumnSet, error)
IndexColumns from selected catalog (or all, if empty), matching schemas and indexes
func (InformationSchema) Indexes ¶
Indexes from selected catalog (or all, if empty), matching schemas and names
func (InformationSchema) Schemas ¶
Schemas from selected catalog (or all, if empty), matching schemas and tables
func (InformationSchema) Sequences ¶
func (s InformationSchema) Sequences(f metadata.Filter) (*metadata.SequenceSet, error)
Sequences from selected catalog (or all, if empty), matching schemas and names
func (*InformationSchema) SetLimit ¶ added in v0.9.0
func (s *InformationSchema) SetLimit(l int)