schema_store

package
v0.9.32 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: Apache-2.0 Imports: 8 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Deserialize

func Deserialize(raw interface{}, column Column) interface{}

func GetCreateSchemaStatement

func GetCreateSchemaStatement(db *sql.DB, schemaName string) (error, string)

func GetTablesFromDB

func GetTablesFromDB(db *sql.DB, schema string) ([]string, error)

Types

type Column

type Column struct {
	Idx          int               `json:"idx"`
	Name         string            `json:"name"`
	ColType      string            `json:"col_type"`
	DefaultVal   ColumnValueString `json:"default_value_string"`
	IsNullable   bool              `json:"is_nullable"`
	IsUnsigned   bool              `json:"is_unsigned"`
	IsPrimaryKey bool              `json:"is_primary_key"`
}

Column

func (Column) EqualsDefault

func (col Column) EqualsDefault(value interface{}) bool

func (Column) IsDatetime

func (col Column) IsDatetime() bool

func (Column) IsTimestamp

func (col Column) IsTimestamp() bool

type ColumnValueString

type ColumnValueString struct {
	ValueString string `json:"value"`
	IsNull      bool   `json:"is_null"`
}

ColumnValueString is the same as sql.NullString We define it here in case we want to extend it.

func (*ColumnValueString) Equals

func (v1 *ColumnValueString) Equals(v2 *ColumnValueString) bool

type Schema

type Schema map[string]*Table

func GetSchemaFromDB

func GetSchemaFromDB(db *sql.DB, dbName string) (Schema, error)

type SchemaStore

type SchemaStore interface {
	GetSchema(database string) (Schema, error)
	InvalidateSchemaCache(schema string)
	InvalidateCache()
	IsInCache(dbName string) bool
	Close()
}

func NewSimpleSchemaStoreFromDBConn

func NewSimpleSchemaStoreFromDBConn(db *sql.DB) (SchemaStore, error)

type SimpleSchemaStore

type SimpleSchemaStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSimpleSchemaStore

func NewSimpleSchemaStore(dbCfg *utils.DBConfig) (*SimpleSchemaStore, error)

func (*SimpleSchemaStore) Close

func (store *SimpleSchemaStore) Close()

func (*SimpleSchemaStore) GetSchema

func (store *SimpleSchemaStore) GetSchema(dbName string) (Schema, error)

func (*SimpleSchemaStore) InvalidateCache

func (store *SimpleSchemaStore) InvalidateCache()

func (*SimpleSchemaStore) InvalidateSchemaCache

func (store *SimpleSchemaStore) InvalidateSchemaCache(schema string)

func (*SimpleSchemaStore) IsInCache

func (store *SimpleSchemaStore) IsInCache(dbName string) bool

type Table

type Table struct {
	Version string `json:"version"`
	Schema  string `json:"db_name"`
	Name    string `json:"table_name"`

	Columns            []Column            `json:"columns"`
	PrimaryKeyColumns  []Column            `json:"primary_key_columns"`
	UniqueKeyColumnMap map[string][]string `json:"unique_key_columns"`
	// contains filtered or unexported fields
}

Table

func GetTableDefFromDB

func GetTableDefFromDB(db *sql.DB, dbName string, tableName string) (*Table, error)

func (*Table) Column

func (t *Table) Column(col string) (c *Column, ok bool)

func (*Table) ColumnNames

func (t *Table) ColumnNames() []string

func (*Table) MustColumn

func (t *Table) MustColumn(col string) *Column

func (*Table) RenameColumn

func (t *Table) RenameColumn(origin, target string)

Jump to

Keyboard shortcuts

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