schemer

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2025 License: MIT Imports: 9 Imported by: 0

README

Schemer

Provide schema information about databases

Implemented DB drivers

Help wanted

We would happily accept pull requests with schemer implementations for:

  • MySQL
  • Oracle
  • PostgreSQL
  • Spanner
  • Tarantool

Documentation

Index

Constants

View Source
const (
	CatalogsCollection = "catalogs"
	SchemasCollection  = "schemas"
)

Variables

This section is empty.

Functions

func FindTable added in v0.11.0

func FindTable(tables datatug.Tables, catalog, schema, name string) *datatug.CollectionInfo

FullFind can be called in any order and always do a full table scan

func NewSchemaKey added in v0.11.0

func NewSchemaKey(catalog, schema string) *dal.Key

Types

type CollectionsProvider added in v0.11.0

type CollectionsProvider interface {
	// GetCollections returns root collections if parentKey is nil or sub-collection if parenKey is provided
	GetCollections(c context.Context, parentKey *dal.Key) (CollectionsReader, error)
}

CollectionsProvider provides Tables

type CollectionsReader added in v0.11.0

type CollectionsReader interface {
	NextCollection() (*datatug.CollectionInfo, error)
}

CollectionsReader reads collection info

type Column

type Column struct {
	TableRef
	datatug.ColumnInfo
}

Column defines column

type ColumnsProvider

type ColumnsProvider interface {
	GetColumns(c context.Context, catalog, schemaName, tableName string) (ColumnsReader, error)
}

ColumnsProvider reads columns info

type ColumnsReader

type ColumnsReader interface {
	// NextColumn returns next column
	NextColumn() (Column, error)
}

ColumnsReader provides columns

type Constraint

type Constraint struct {
	TableRef
	ColumnName                                                            string
	UniqueConstraintCatalog, UniqueConstraintSchema, UniqueConstraintName string // can be null
	MatchOption, UpdateRule, DeleteRule                                   string // can be null
	RefTableCatalog, RefTableSchema, RefTableName, RefColName             string // can be null
	*datatug.Constraint
}

Constraint defines a constraint

type ConstraintsProvider

type ConstraintsProvider interface {
	// GetConstraints returns constrains
	GetConstraints(c context.Context, catalog, schema, table string) (ConstraintsReader, error)
}

ConstraintsProvider provides constraints

type ConstraintsReader

type ConstraintsReader interface {
	NextConstraint() (*Constraint, error)
}

ConstraintsReader reads constraint

type Index

type Index struct {
	TableRef
	*datatug.Index
}

Index defines index

type IndexColumn

type IndexColumn struct {
	TableRef
	IndexName string
	*datatug.IndexColumn
}

IndexColumn defines index column

type IndexColumnsProvider

type IndexColumnsProvider interface {
	// GetIndexColumns returns index columns
	GetIndexColumns(c context.Context, catalog, schema, table, index string) (IndexColumnsReader, error)
}

IndexColumnsProvider provides index columns

type IndexColumnsReader

type IndexColumnsReader interface {
	// NextIndexColumn returns index column
	NextIndexColumn() (*IndexColumn, error)
}

IndexColumnsReader provides index columns

type IndexesProvider

type IndexesProvider interface {
	// GetIndexes returns next index
	GetIndexes(c context.Context, catalog, schema, table string) (IndexesReader, error)
}

IndexesProvider provides indexes

type IndexesReader

type IndexesReader interface {
	// NextIndex returns next index
	NextIndex() (*Index, error)
}

IndexesReader provides indexes

type RecordsCountProvider

type RecordsCountProvider interface {
	RecordsCount(c context.Context, catalog, schema, table string) (*int, error)
}

RecordsCountProvider provides count for a recordset

type Scanner

type Scanner interface {
	ScanCatalog(c context.Context, name string) (database *datatug.DbCatalog, err error)
}

Scanner defines scanner

func NewScanner

func NewScanner(schemaProvider SchemaProvider) Scanner

NewScanner creates new scanner

type SchemaProvider

type SchemaProvider interface {
	IsBulkProvider() bool // TODO: Needs clarification what it does and how it is used
	CollectionsProvider
	ColumnsProvider
	IndexesProvider
	IndexColumnsProvider
	ConstraintsProvider
	RecordsCountProvider
}

SchemaProvider provides schema info

type SortedIndexes added in v0.11.0

type SortedIndexes struct {
	// contains filtered or unexported fields
}

func (*SortedIndexes) Reset added in v0.11.0

func (sorted *SortedIndexes) Reset()

func (*SortedIndexes) SequentialFind added in v0.11.0

func (sorted *SortedIndexes) SequentialFind(schema, table, name string) *Index

SequentialFind will work if calls to it are issued in lexical order

type SortedTables added in v0.11.0

type SortedTables struct {
	Tables []*datatug.CollectionInfo
	// contains filtered or unexported fields
}

func (*SortedTables) Reset added in v0.11.0

func (sorted *SortedTables) Reset()

func (*SortedTables) SequentialFind added in v0.11.0

func (sorted *SortedTables) SequentialFind(catalog, schema, name string) *datatug.CollectionInfo

SequentialFind will work if calls to it are issued in lexical order

type TableRef

type TableRef struct {
	SchemaName string
	TableName  string
	TableType  string
}

TableRef defines a reference to a table

Jump to

Keyboard shortcuts

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