model

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateQuery

func GenerateQuery(rft map[TableName][]Record, schema Schema) []string

func GenerateRecordsForTables

func GenerateRecordsForTables(vfc map[ColumnFullName][]Value, schema Schema, n int) map[TableName][]Record

func GenerateValuesForColumns

func GenerateValuesForColumns(cg ColumnGraph, n int) map[ColumnFullName][]Value

TODO: better to be defined as a method of map[ColumnFullName][]Value? TODO: shuffle values. currently, values with constraints are just simple sum of strings in the order.

Types

type AdjacencyMatrix

type AdjacencyMatrix [][]int

type Column

type Column struct {
	Name          ColumnName
	FullName      ColumnFullName
	Type          ColumnType
	AutoIncrement bool
	Unsigned      bool
	Constraints   []Constraint
}

func NewColumn

func NewColumn(fullName ColumnFullName, ct ColumnType) Column

func (Column) GenerateData

func (c Column) GenerateData(n int) []Value

func (Column) GenerateRandomData

func (c Column) GenerateRandomData() ColumnData

func (Column) HasConstraint

func (c Column) HasConstraint() bool

func (*Column) SetAutoIncrement

func (c *Column) SetAutoIncrement()

func (*Column) SetConstraint

func (c *Column) SetConstraint(constraint Constraint)

func (*Column) SetUnsigned

func (c *Column) SetUnsigned(b bool)

type ColumnData

type ColumnData string

TODO: rethink if these types are needed

type ColumnFullName

type ColumnFullName string

func NewColumnFullName

func NewColumnFullName(tn TableName, cn ColumnName) ColumnFullName

type ColumnGraph

type ColumnGraph struct {
	AdjacencyMatrix AdjacencyMatrix
	ColumnNodes     []ColumnNode
}

Graph structure of columns expressed by adjacency matrix and nodes

func GenerateColumnGraph

func GenerateColumnGraph(schema Schema) ColumnGraph

func (ColumnGraph) ChildrenNodeIndexes

func (cg ColumnGraph) ChildrenNodeIndexes(i int) ([]int, error)

func (ColumnGraph) HasChildrenNodes

func (cg ColumnGraph) HasChildrenNodes(i int) (bool, error)

func (ColumnGraph) HasParentNodes

func (cg ColumnGraph) HasParentNodes(i int) (bool, error)

TODO: adopt error handling such as Stacktrace

func (ColumnGraph) IsParentNodesAreAllDone

func (cg ColumnGraph) IsParentNodesAreAllDone(i int) (bool, error)

func (ColumnGraph) ParentNodeIndexes

func (cg ColumnGraph) ParentNodeIndexes(i int) ([]int, error)

type ColumnName

type ColumnName string

type ColumnNode

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

func (*ColumnNode) Done

func (cn *ColumnNode) Done()

func (ColumnNode) GetColumn

func (cn ColumnNode) GetColumn() Column

func (ColumnNode) IsDone

func (cn ColumnNode) IsDone() bool

type ColumnType

type ColumnType struct {
	Base  ColumnTypeBase
	Param ColumnTypeParam
}

type ColumnTypeBase

type ColumnTypeBase string
const (
	Varchar    ColumnTypeBase = "varchar"
	Varbinary  ColumnTypeBase = "varbinary"
	Mediumblob ColumnTypeBase = "mediumblob"
	Text       ColumnTypeBase = "text"
	Tinyint    ColumnTypeBase = "tinyint"
	Smallint   ColumnTypeBase = "smallint"
	Mediumint  ColumnTypeBase = "mediumint"
	Int        ColumnTypeBase = "int"
	Bigint     ColumnTypeBase = "bigint"
	Timestamp  ColumnTypeBase = "timestamp"
	Datetime   ColumnTypeBase = "datetime"
	Json       ColumnTypeBase = "json"
)

func StrToColumnTypeBase

func StrToColumnTypeBase(str string) (ColumnTypeBase, error)

type ColumnTypeParam

type ColumnTypeParam int

type Constraint

type Constraint struct {
	TableName
	ColumnName
}

func NewConstraint

func NewConstraint(tn TableName, cn ColumnName) Constraint

type Record

type Record []Value

type Schema

type Schema struct {
	Tables []Table
}

func (*Schema) AddTable

func (s *Schema) AddTable(table Table)

func (*Schema) LastTable

func (s *Schema) LastTable() *Table

type Table

type Table struct {
	Name    TableName
	Columns []Column
}

func NewTable

func NewTable(name TableName, columns []Column) Table

func (*Table) AddColumns

func (t *Table) AddColumns(column Column)

type TableName

type TableName string

type Value

type Value string

Jump to

Keyboard shortcuts

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