Help us shape the future of Go! Take the 2026 Go Developer Survey

schema

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinFamilyNameLength = 3
	MaxFamilyNameLength = 30
)
View Source
const (
	MinFieldNameLength = 1
	MaxFieldNameLength = 64
)
View Source
const (
	MinTableNameLength = 3
	MaxTableNameLength = 50
)
View Source
const (
	MinWriterNameLength = 3
	MaxWriterNameLength = 50
)
View Source
const DMLTxBeginKey = "--- BEGIN"

These are the markers used to indicate the start and end of transactions in ctldb's DML log.

View Source
const DMLTxEndKey = "--- COMMIT"

Variables

View Source
var (
	ErrFamilyNameInvalid  = errors.New("Family names must be only letters, numbers, and single underscore")
	ErrFamilyNameTooLong  = fmt.Errorf("Family names can only be up to %d characters", MaxFamilyNameLength)
	ErrFamilyNameTooShort = fmt.Errorf("Family names must be at least %d characters", MinFamilyNameLength)
)
View Source
var (
	ErrFieldNameInvalid  = errors.New("Field names must be only letters, numbers, and underscore")
	ErrFieldNameTooLong  = fmt.Errorf("Field names can only be up to %d characters", MaxFieldNameLength)
	ErrFieldNameTooShort = fmt.Errorf("Field names must be at least %d characters", MinFieldNameLength)
)
View Source
var (
	ErrTableNameInvalid  = errors.New("Table names must be only letters, numbers, and single underscore")
	ErrTableNameTooLong  = fmt.Errorf("Table names can only be up to %d characters", MaxTableNameLength)
	ErrTableNameTooShort = fmt.Errorf("Table names must be at least %d characters", MinTableNameLength)
)
View Source
var (
	ErrWriterNameTooLong  = fmt.Errorf("Writer names can only be up to %d characters", MaxWriterNameLength)
	ErrWriterNameTooShort = fmt.Errorf("Writer names must be at least %d characters", MinWriterNameLength)
)
View Source
var FieldTypeStringsByFieldType = map[FieldType]string{
	FTString:     "string",
	FTInteger:    "integer",
	FTDecimal:    "decimal",
	FTText:       "text",
	FTBinary:     "binary",
	FTByteString: "bytestring",
}

Maps FieldTypes to their stringly typed version

View Source
var PrimaryKeyZero = PrimaryKey{}
View Source
var TableNameZero = TableName{}

Functions

func DecodeLDBTableName

func DecodeLDBTableName(tableName string) (fn FamilyName, tn TableName, err error)

The opposite of ldbTableName()

func FieldTypeMap

func FieldTypeMap() map[string]FieldType

Returns a map of stringly typed field types to strongly typed field types

func LDBTableName

func LDBTableName(famName FamilyName, tblName TableName) string

Converts a family/table name pair to a concatenated version that works with SQLite, which doesn't support SQL schema objects. Use ___ to avoid easy accidental hijacks.

func StringifyFieldNames

func StringifyFieldNames(fns []FieldName) []string

Types

type DBColumnInfo

type DBColumnInfo struct {
	TableName    string
	Index        int
	ColumnName   string
	DataType     string
	IsPrimaryKey bool
}

type DBColumnMeta

type DBColumnMeta struct {
	Name string
	Type string
}

func DBColumnMetaFromRows

func DBColumnMetaFromRows(rows *sql.Rows) ([]DBColumnMeta, error)

type DMLSequence

type DMLSequence int64

func (DMLSequence) Int

func (seq DMLSequence) Int() int64

type DMLStatement

type DMLStatement struct {
	Sequence  DMLSequence
	Timestamp time.Time
	Statement string
}

func NewTestDMLStatement

func NewTestDMLStatement(statement string) DMLStatement

used for testing

type FamilyName

type FamilyName struct {
	Name string
}

func NewFamilyName

func NewFamilyName(name string) (FamilyName, error)

func (FamilyName) String

func (fn FamilyName) String() string

type FamilyTable

type FamilyTable struct {
	Family string `json:"family"`
	Table  string `json:"table"`
}

FamilyTable composes a family name and a table name

func ParseFamilyTable

func ParseFamilyTable(fullName string) (ft FamilyTable, ok bool)

parseFamilyTable breaks up a full table name into family/table parts.

func (FamilyTable) String

func (ft FamilyTable) String() string

String is a Stringer implementation that produces the fully qualified table name

func (FamilyTable) Tag

func (ft FamilyTable) Tag() stats.Tag

Tag produces a stats tag that can be used to represent this table

type FieldName

type FieldName struct {
	Name string
}

func NewFieldName

func NewFieldName(name string) (FieldName, error)

func (FieldName) String

func (f FieldName) String() string

type FieldType

type FieldType int
const (
	FTString FieldType
	FTInteger
	FTDecimal
	FTText
	FTBinary
	FTByteString
)

func SqlTypeToFieldType

func SqlTypeToFieldType(sqlType string) (FieldType, bool)

Convert a known SQL type string to a FieldType

func UnzipFieldsParam

func UnzipFieldsParam(fields [][]string) (fieldNames []string, fieldTypes []FieldType, err error)

func (FieldType) CanBeKey

func (ft FieldType) CanBeKey() bool

CanBeKey returns if the field type can be used in a PK

func (FieldType) String

func (ft FieldType) String() string

type NamedFieldType

type NamedFieldType struct {
	Name      FieldName
	FieldType FieldType
}

Roses are red, Violets are blue, This type would fill me with less existential dread, If Go had a tuple type instead

type PrimaryKey

type PrimaryKey struct {
	Fields []FieldName
	Types  []FieldType
}

func NewPKFromRawNamesAndFieldTypes

func NewPKFromRawNamesAndFieldTypes(names []string, types []FieldType) (PrimaryKey, error)

builds a new primary key from a slice of field names and the corresponding field types.

func NewPKFromRawNamesAndTypes

func NewPKFromRawNamesAndTypes(names []string, types []string) (PrimaryKey, error)

builds a new primary key from a slice of field name and the string representation of the field types. The field types in this case should have entries in the _sqlTypesToFieldTypes map. A failure to map from a field type string to a FieldType will result in an error.

func (*PrimaryKey) Strings

func (pk *PrimaryKey) Strings() []string

Returns the list of fields as strings

func (*PrimaryKey) Zero

func (pk *PrimaryKey) Zero() bool

Is this a zero value?

type Table

type Table struct {
	Family    string     `json:"family"`
	Name      string     `json:"name"`
	Fields    [][]string `json:"fields"`
	KeyFields []string   `json:"keyFields"`
}

type TableName

type TableName struct {
	Name string
}

use newTableName to construct a tableName

func NewTableName

func NewTableName(name string) (TableName, error)

func (TableName) String

func (tn TableName) String() string

type WriterName

type WriterName struct {
	Name string
}

use newWriterName to construct a writerName

func NewWriterName

func NewWriterName(name string) (WriterName, error)

func (WriterName) String

func (wn WriterName) String() string

Jump to

Keyboard shortcuts

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