sdata

package
v2.0.30 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFromEdgeNotFound   = errors.New("from edge not found")
	ErrToEdgeNotFound     = errors.New("to edge not found")
	ErrPathNotFound       = errors.New("path not found")
	ErrThoughNodeNotFound = errors.New("though node not found")
)

Functions

func GetRelName added in v2.0.21

func GetRelName(colName string) string

Types

type DBColumn

type DBColumn struct {
	Comment     string
	ID          int32
	Name        string
	Type        string
	Array       bool
	NotNull     bool
	PrimaryKey  bool
	UniqueKey   bool
	FullText    bool
	FKRecursive bool
	FKeySchema  string
	FKeyTable   string
	FKeyCol     string
	Blocked     bool
	Table       string
	Schema      string
}

func DiscoverColumns

func DiscoverColumns(db *sql.DB, dbtype string, blockList []string) ([]DBColumn, error)

func (DBColumn) String

func (col DBColumn) String() string

type DBFuncParam

type DBFuncParam struct {
	ID    int
	Name  string
	Type  string
	Array bool
}

type DBFunction

type DBFunction struct {
	Comment string
	Schema  string
	Name    string
	Type    string
	Agg     bool
	Inputs  []DBFuncParam
	Outputs []DBFuncParam
}

func DiscoverFunctions

func DiscoverFunctions(db *sql.DB, dbtype string, blockList []string) ([]DBFunction, error)

func (*DBFunction) GetInput

func (fn *DBFunction) GetInput(name string) (ret DBFuncParam, err error)

func (DBFunction) String

func (fn DBFunction) String() string

type DBInfo

type DBInfo struct {
	Type    string
	Version int
	Schema  string
	Name    string

	Tables    []DBTable
	Functions []DBFunction
	VTables   []VirtualTable `json:"-"`
	// contains filtered or unexported fields
}

func GetDBInfo

func GetDBInfo(
	db *sql.DB,
	dbType string,
	blockList []string) (*DBInfo, error)

func GetTestDBInfo

func GetTestDBInfo() *DBInfo

func NewDBInfo

func NewDBInfo(
	dbType string,
	dbVersion int,
	dbSchema string,
	dbName string,
	cols []DBColumn,
	funcs []DBFunction,
	blockList []string) *DBInfo

func (*DBInfo) AddTable

func (di *DBInfo) AddTable(t DBTable)

func (*DBInfo) GetColumn

func (di *DBInfo) GetColumn(schema, table, column string) (*DBColumn, error)

func (*DBInfo) GetTable

func (di *DBInfo) GetTable(schema, table string) (*DBTable, error)

func (*DBInfo) Hash

func (di *DBInfo) Hash() int

type DBRel

type DBRel struct {
	Type  RelType
	Left  DBRelLeft
	Right DBRelRight
}

func PathToRel

func PathToRel(p TPath) DBRel

func (*DBRel) String

func (re *DBRel) String() string

type DBRelLeft

type DBRelLeft struct {
	Ti  DBTable
	Col DBColumn
}

type DBRelRight

type DBRelRight struct {
	VTable string
	Ti     DBTable
	Col    DBColumn
}

type DBSchema

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

func GetTestSchema

func GetTestSchema() (*DBSchema, error)

func NewDBSchema

func NewDBSchema(
	info *DBInfo,
	aliases map[string][]string,
) (*DBSchema, error)

func (*DBSchema) DBName

func (s *DBSchema) DBName() string

func (*DBSchema) DBSchema

func (s *DBSchema) DBSchema() string

func (*DBSchema) DBType

func (s *DBSchema) DBType() string

func (*DBSchema) DBVersion

func (s *DBSchema) DBVersion() int

func (*DBSchema) Find

func (s *DBSchema) Find(schema, name string) (DBTable, error)

func (*DBSchema) FindPath

func (s *DBSchema) FindPath(from, to, through string) ([]TPath, error)

func (*DBSchema) GetAliases

func (s *DBSchema) GetAliases() map[string]DBTable

func (*DBSchema) GetFirstDegree

func (s *DBSchema) GetFirstDegree(t DBTable) (items []RelNode, err error)

func (*DBSchema) GetFunctions

func (s *DBSchema) GetFunctions() map[string]DBFunction

func (*DBSchema) GetSecondDegree

func (s *DBSchema) GetSecondDegree(t DBTable) (items []RelNode, err error)

func (*DBSchema) GetTables

func (s *DBSchema) GetTables() []DBTable

func (*DBSchema) IsAlias

func (s *DBSchema) IsAlias(name string) bool

func (*DBSchema) PrintEdgeInfo

func (s *DBSchema) PrintEdgeInfo(e edgeInfo)

func (*DBSchema) PrintLines

func (s *DBSchema) PrintLines(lines []util.Edge)

type DBTable

type DBTable struct {
	Comment      string
	Schema       string
	Name         string
	Type         string
	Columns      []DBColumn
	PrimaryCol   DBColumn
	SecondaryCol DBColumn
	FullText     []DBColumn
	Blocked      bool
	Func         DBFunction
	// contains filtered or unexported fields
}

func NewDBTable

func NewDBTable(schema, name, _type string, cols []DBColumn) DBTable

func (*DBTable) ColumnExists

func (ti *DBTable) ColumnExists(name string) (DBColumn, bool)

func (*DBTable) GetColumn

func (ti *DBTable) GetColumn(name string) (DBColumn, error)

func (*DBTable) String

func (ti *DBTable) String() string

type RelNode added in v2.0.21

type RelNode struct {
	Name  string
	Type  RelType
	Table DBTable
}

type RelType

type RelType int
const (
	RelNone RelType = iota
	RelOneToOne
	RelOneToMany
	RelPolymorphic
	RelRecursive
	RelEmbedded
	RelRemote
	RelSkip
)

func (RelType) String

func (i RelType) String() string

type TEdge

type TEdge struct {
	From, To, Weight int32

	Type   RelType
	LT, RT DBTable
	L, R   DBColumn
	CName  string
	// contains filtered or unexported fields
}

type TPath

type TPath struct {
	Rel RelType
	LT  DBTable
	LC  DBColumn
	RT  DBTable
	RC  DBColumn
}

func (*TPath) String

func (tp *TPath) String() string

type VirtualTable

type VirtualTable struct {
	Name       string
	IDColumn   string
	TypeColumn string
	FKeyColumn string
}

Jump to

Keyboard shortcuts

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