types

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDatasetNotFound = errors.New("dataset not found")
)

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Type  AttributeType `json:"type"`
	Value string        `json:"value,omitempty"`
}

func (*Attribute) Clean

func (a *Attribute) Clean() error

func (*Attribute) Copy

func (a *Attribute) Copy() *Attribute

Copy returns a copy of the attribute

type AttributeType

type AttributeType string
const (
	PRIMARY_KEY AttributeType = "PRIMARY_KEY"
	UNIQUE      AttributeType = "UNIQUE"
	NOT_NULL    AttributeType = "NOT_NULL"
	DEFAULT     AttributeType = "DEFAULT"
	MIN         AttributeType = "MIN"
	MAX         AttributeType = "MAX"
	MIN_LENGTH  AttributeType = "MIN_LENGTH"
	MAX_LENGTH  AttributeType = "MAX_LENGTH"
)

func (*AttributeType) Clean

func (a *AttributeType) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*AttributeType) IsValid

func (a *AttributeType) IsValid() bool

func (AttributeType) String

func (a AttributeType) String() string

type Column

type Column struct {
	Name       string       `json:"name"`
	Type       DataType     `json:"type"`
	Attributes []*Attribute `json:"attributes,omitempty"`
}

func (*Column) Clean

func (c *Column) Clean() error

func (*Column) Copy

func (c *Column) Copy() *Column

Copy returns a copy of the column

type DataType

type DataType string
const (
	NULL DataType = "NULL"
	TEXT DataType = "TEXT"
	INT  DataType = "INT"
	BLOB DataType = "BLOB"
)

Data Types

func (*DataType) Clean

func (d *DataType) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*DataType) IsNumeric

func (d *DataType) IsNumeric() bool

func (*DataType) IsText

func (d *DataType) IsText() bool

will check if the data type is a text type

func (*DataType) IsValid

func (d *DataType) IsValid() bool

func (DataType) String

func (d DataType) String() string

type ExecutionData

type ExecutionData struct {
	// Dataset is the DBID of the dataset that was called.
	// Even if a procedure in another dataset is called, this will always be the original dataset.
	Dataset string

	// Procedure is the original procedure that was called.
	// Even if a nested procedure is called, this will always be the original procedure.
	Procedure string

	// Mutative indicates whether the execution can mutate state.
	Mutative bool

	// Args are the arguments that were passed to the procedure.
	Args []any

	// Signer is the address of public key that signed the incoming transaction.
	Signer []byte

	// Caller is a string identifier for the signer.
	// It is derived from the signer's registered authenticator.
	// It is injected as a variable for usage in the query, under
	// the variable name "@caller".
	Caller string
}

ExecutionData is contextual data that is passed to a procedure during call / execution. It is scoped to the lifetime of a single execution.

func (*ExecutionData) Clean

func (e *ExecutionData) Clean() error

type Extension

type Extension struct {
	Name           string             `json:"name"`
	Initialization []*ExtensionConfig `json:"initialization"`
	Alias          string             `json:"alias"`
}

func (*Extension) Clean

func (e *Extension) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*Extension) CleanMap

func (e *Extension) CleanMap() map[string]string

CleanMap returns a map of the config values for the extension. Since the Kueiform parser parses all values as strings, it cleans the single quotes from the values.

type ExtensionConfig

type ExtensionConfig struct {
	Key   string `json:"name"`
	Value string `json:"value"`
}

ExtensionConfig is a key value pair that represents a configuration value for an extension

type ForeignKey

type ForeignKey struct {
	// ChildKeys are the columns that are referencing another.
	// For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "a" is the child key
	ChildKeys []string `json:"child_keys"`

	// ParentKeys are the columns that are being referred to.
	// For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "tbl2.b" is the parent key
	ParentKeys []string `json:"parent_keys"`

	// ParentTable is the table that holds the parent columns.
	// For example, in FOREIGN KEY (a) REFERENCES tbl2(b), "tbl2.b" is the parent table
	ParentTable string `json:"parent_table"`

	// Action refers to what the foreign key should do when the parent is altered.
	// This is NOT the same as a database action;
	// however sqlite's docs refer to these as actions,
	// so we should be consistent with that.
	// For example, ON DELETE CASCADE is a foreign key action
	Actions []*ForeignKeyAction `json:"actions"`
}

func (*ForeignKey) Clean

func (f *ForeignKey) Clean() error

Clean runs a set of validations and cleans the foreign key

func (*ForeignKey) Copy

func (f *ForeignKey) Copy() *ForeignKey

Copy returns a copy of the foreign key

type ForeignKeyAction

type ForeignKeyAction struct {
	// On can be either "UPDATE" or "DELETE"
	On ForeignKeyActionOn `json:"on"`

	// Do specifies what a foreign key action should do
	Do ForeignKeyActionDo `json:"do"`
}

ForeignKeyAction is used to specify what should occur if a parent key is updated or deleted

func (*ForeignKeyAction) Clean

func (f *ForeignKeyAction) Clean() error

Clean runs a set of validations and cleans the attributes in ForeignKeyAction

func (*ForeignKeyAction) Copy

Copy returns a copy of the foreign key action

type ForeignKeyActionDo

type ForeignKeyActionDo string

ForeignKeyActionDo specifies what should be done when a foreign key action is triggered.

const (
	// DO_NO_ACTION does nothing when a parent key is altered
	DO_NO_ACTION ForeignKeyActionDo = "NO ACTION"

	// DO_RESTRICT prevents the parent key from being altered
	DO_RESTRICT ForeignKeyActionDo = "RESTRICT"

	// DO_SET_NULL sets the child key(s) to NULL
	DO_SET_NULL ForeignKeyActionDo = "SET NULL"

	// DO_SET_DEFAULT sets the child key(s) to their default values
	DO_SET_DEFAULT ForeignKeyActionDo = "SET DEFAULT"

	// DO_CASCADE updates the child key(s) or deletes the records (depending on the action type)
	DO_CASCADE ForeignKeyActionDo = "CASCADE"
)

func (*ForeignKeyActionDo) Clean

func (f *ForeignKeyActionDo) Clean() error

Clean checks the validity or the string, and converts it to the correct case

func (*ForeignKeyActionDo) IsValid

func (f *ForeignKeyActionDo) IsValid() bool

IsValid checks if the string is a valid ForeignKeyActionDo

func (ForeignKeyActionDo) String

func (f ForeignKeyActionDo) String() string

String returns the ForeignKeyActionDo as a string

type ForeignKeyActionOn

type ForeignKeyActionOn string

ForeignKeyActionOn specifies when a foreign key action should occur. It can be either "UPDATE" or "DELETE".

const (
	// ON_UPDATE is used to specify an action should occur when a parent key is updated
	ON_UPDATE ForeignKeyActionOn = "UPDATE"
	// ON_DELETE is used to specify an action should occur when a parent key is deleted
	ON_DELETE ForeignKeyActionOn = "DELETE"
)

func (*ForeignKeyActionOn) Clean

func (f *ForeignKeyActionOn) Clean() error

Clean checks whether the string is valid, and will convert it to the correct case.

func (*ForeignKeyActionOn) IsValid

func (f *ForeignKeyActionOn) IsValid() bool

IsValid checks whether or not the string is a valid ForeignKeyActionOn

func (ForeignKeyActionOn) String

func (f ForeignKeyActionOn) String() string

String returns the ForeignKeyActionOn as a string

type Index

type Index struct {
	Name    string    `json:"name"`
	Columns []string  `json:"columns"`
	Type    IndexType `json:"type"`
}

func (*Index) Clean

func (i *Index) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*Index) Copy

func (i *Index) Copy() *Index

Copy returns a copy of the index.

type IndexType

type IndexType string
const (
	BTREE        IndexType = "BTREE"
	UNIQUE_BTREE IndexType = "UNIQUE_BTREE"
	PRIMARY      IndexType = "PRIMARY"
)

func (*IndexType) Clean

func (i *IndexType) Clean() error

func (*IndexType) IsValid

func (i *IndexType) IsValid() bool

func (IndexType) String

func (i IndexType) String() string

type Modifier

type Modifier string
const (
	// View means that an action does not modify the database.
	ModifierView Modifier = "VIEW"

	// Authenticated requires that the caller is identified.
	ModifierAuthenticated Modifier = "AUTHENTICATED"

	// Owner requires that the caller is the owner of the database.
	ModifierOwner Modifier = "OWNER"
)

func (*Modifier) Clean

func (m *Modifier) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*Modifier) IsValid

func (m *Modifier) IsValid() bool

func (Modifier) String

func (m Modifier) String() string

type Procedure

type Procedure struct {
	Name        string     `json:"name"`
	Annotations []string   `json:"annotations,omitempty"`
	Args        []string   `json:"inputs"`
	Public      bool       `json:"public"`
	Modifiers   []Modifier `json:"modifiers"`
	Statements  []string   `json:"statements"`
}

func (*Procedure) Clean

func (p *Procedure) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*Procedure) EnsureContainsModifier

func (p *Procedure) EnsureContainsModifier(mod Modifier)

func (*Procedure) IsMutative

func (p *Procedure) IsMutative() bool

IsMutative returns true if the procedure is mutative.

func (*Procedure) IsOwnerOnly

func (p *Procedure) IsOwnerOnly() bool

func (*Procedure) RequiresAuthentication

func (p *Procedure) RequiresAuthentication() bool

type Schema

type Schema struct {
	Name string
	// Owner is the identifier (generally an address in bytes or public key) of the owner of the schema
	Owner      []byte
	Extensions []*Extension
	Tables     []*Table
	Procedures []*Procedure
}

func (*Schema) Clean

func (s *Schema) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*Schema) DBID

func (s *Schema) DBID() string

type Table

type Table struct {
	Name        string        `json:"name"`
	Columns     []*Column     `json:"columns"`
	Indexes     []*Index      `json:"indexes,omitempty"`
	ForeignKeys []*ForeignKey `json:"foreign_keys"`
}

func (*Table) Clean

func (t *Table) Clean() error

Clean validates rules about the data in the struct (naming conventions, syntax, etc.).

func (*Table) Copy

func (t *Table) Copy() *Table

Copy returns a copy of the table

func (*Table) GetPrimaryKey

func (t *Table) GetPrimaryKey() ([]string, error)

GetPrimaryKey returns the names of the column(s) that make up the primary key. If there is more than one, or no primary key, an error is returned.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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