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

This section is empty.

Types

type DBColumn

type DBColumn struct {
	ID         int32
	Name       string
	Type       string
	Array      bool
	NotNull    bool
	PrimaryKey bool
	UniqueKey  bool
	FullText   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 sql.NullString
	Type string
}

type DBFunction

type DBFunction struct {
	Name   string
	Params []DBFuncParam
}

func DiscoverFunctions

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

type DBInfo

type DBInfo struct {
	Type      string
	Version   int
	Schema    string
	Name      string
	Tables    []DBTable
	Functions []DBFunction
	VTables   []VirtualTable
	// 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)

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 {
	SingularSuffix SingularInfo // singular suffix
	// 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(schema, table string) (map[string]DBTable, error)

func (*DBSchema) GetFunctions

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

func (*DBSchema) GetSecondDegree

func (s *DBSchema) GetSecondDegree(schema, table string) (map[string]DBTable, error)

func (*DBSchema) GetTables

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

func (*DBSchema) IsAlias

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

type DBTable

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

func NewDBTable

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

func (*DBTable) GetColumn

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

func (*DBTable) String

func (ti *DBTable) String() string

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 SingularInfo

type SingularInfo struct {
	Value string // Suffix value defined by the user
	Lower string // Lower-cased suffix used for treatment inside our code
}

type TEdge

type TEdge struct {
	From, To, Weight int32

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

type TPath

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

type VirtualTable

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