Documentation
¶
Index ¶
- Constants
- Variables
- func IsSchemaColumsQuery(stmt sql.Select) bool
- func NewSchemaColumnsQueryFromTableNames(tableNames []string) (sql.Select, error)
- func NewSchemaColumnsResultSetSchema() (resultset.Schema, error)
- type ColumnOption
- type Constraint
- type DataType
- type ResultSet
- type SchemaColumn
- type SchemaColumnOption
- type SchemaColumnsResultSet
- type SchemaColumnsStatement
- type SchemaColumnsStatementOption
Constants ¶
const ( DefaultSchemaColumnsCatalog = "def" InformationSchema = "information_schema" InformationSchemaColumns = "COLUMNS" SchemaColumns = InformationSchema + "." + InformationSchemaColumns SchemaColumnsCatalog = "TABLE_CATALOG" SchemaColumnsSchema = "TABLE_SCHEMA" SchemaColumnsTableName = "TABLE_NAME" SchemaColumnsColumnName = "COLUMN_NAME" SchemaColumnsDataType = "DATA_TYPE" SchemaColumnsQuery = "SELECT * FROM " + SchemaColumns )
Variables ¶
var ErrInvalid = errors.New("invalid")
ErrInvalid is returned when the value is invalid.
var ErrNotFound = errors.New("not found")
ErrNotFound is returned when the value is not found.
Functions ¶
func IsSchemaColumsQuery ¶
IsSchemaColumsQuery returns true if the statement is a schema columns query.
func NewSchemaColumnsQueryFromTableNames ¶
NewSchemaColumnsQueryFromTableNames returns a new schema columns query with table names.
func NewSchemaColumnsResultSetSchema ¶
SchemaColumnsResultSet represents a schema columns resultset.
Types ¶
type ColumnOption ¶
type ColumnOption func(*column) error
func WithColumnCatalog ¶
func WithColumnCatalog(a any) ColumnOption
WithColumnCatalog returns a column option to set the catalog name.
func WithColumnConstraint ¶
func WithColumnConstraint(v any) ColumnOption
WithColumnConstraint returns a column option to set the column constraint.
func WithColumnDataType ¶
func WithColumnDataType(v any) ColumnOption
WithColumnDataType returns a column option to set the data type.
func WithColumnName ¶
func WithColumnName(a any) ColumnOption
WithColumnName returns a column option to set the column name.
func WithColumnSchema ¶
func WithColumnSchema(a any) ColumnOption
WithColumnSchema returns a column option to set the schema name.
func WithColumnTable ¶
func WithColumnTable(a any) ColumnOption
WithColumnTable returns a column option to set the table name.
type SchemaColumn ¶
type SchemaColumn interface { // Catalog returns the catalog name. Catalog() string // Schema returns the schema name. Schema() string // Table returns the table name. Table() string // Name returns the column name. Name() string // DataType returns the data type. DataType() DataType // Constraint returns the column constraint. Constraint() Constraint }
SchemaColumn represents a schema column interface.
func NewColumn ¶
func NewColumn(opts ...ColumnOption) (SchemaColumn, error)
NewColumn returns a new column.
type SchemaColumnOption ¶
type SchemaColumnOption func(*rs)
NewSchemaColumns returns a new SchemaColumns instance.
func WithColumns ¶
func WithColumns(columns []SchemaColumn) SchemaColumnOption
WithColumns returns a SchemaColumnOption that sets the columns.
type SchemaColumnsResultSet ¶
type SchemaColumnsResultSet interface { // Columns returns the columns. Columns() []SchemaColumn // LookupColumn returns the column by name. LookupColumn(name string) (SchemaColumn, error) }
SchemaColumnsResultSet represents a schema columns result set.
func NewSchemaColumns ¶
func NewSchemaColumns(opts ...SchemaColumnOption) SchemaColumnsResultSet
NewSchemaColumns returns a new SchemaColumns instance.
func NewSchemaColumnsResultSetFromResultSet ¶
func NewSchemaColumnsResultSetFromResultSet(rs ResultSet) (SchemaColumnsResultSet, error)
NewSchemaColumnsResultSetFromResultSet returns a new SchemaColumnsResultSet instance from the specified ResultSet.
type SchemaColumnsStatement ¶
type SchemaColumnsStatement interface { // Statement returns the statement. Statement() sql.Select // DatabaseName returns the database name. DatabaseName() string // TableNames returns the table names. TableNames() []string }
SchemaColumnsStatement represents a schema columns statement.
func NewSchemaColumnsStatement ¶
func NewSchemaColumnsStatement(opts ...SchemaColumnsStatementOption) (SchemaColumnsStatement, error)
NewSchemaColumnsStatement returns a new SchemaColumnsStatement.
type SchemaColumnsStatementOption ¶
type SchemaColumnsStatementOption func(*schemaColumnsStatement)
SchemaColumnsStatement represents a schema columns statement.
func WithSchemaColumnsStatementDatabaseName ¶
func WithSchemaColumnsStatementDatabaseName(db string) SchemaColumnsStatementOption
With SchemaColumnsStatementDatabaseName sets the database name.
func WithSchemaColumnsStatementSelect ¶
func WithSchemaColumnsStatementSelect(sel sql.Select) SchemaColumnsStatementOption
WithSchemaColumnsStatementSelect sets the select statement.
func WithSchemaColumnsStatementTableNames ¶
func WithSchemaColumnsStatementTableNames(tables []string) SchemaColumnsStatementOption
WithSchemaColumnsStatementTableName sets the table name.