engine

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package engine executes logic operations on sequences.

Index

Constants

View Source
const (
	IntType = iota
	StringType
	NullType
)

Variables

This section is empty.

Functions

func CastValueInterface added in v1.0.0

func CastValueInterface(v ValueInterface)

HandleValue - Function to take an instance of ValueInterface and cast to a specific implementation

Types

type Column

type Column struct {
	Name   string
	Type   token.Token
	Values []ValueInterface
}

Column - part of the Table containing name of Column and values in it

type ColumnDoesNotExistError added in v1.0.0

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

ColumnDoesNotExistError - error thrown when user tries to make operation on un-existing column

func (*ColumnDoesNotExistError) Error added in v1.0.0

func (m *ColumnDoesNotExistError) Error() string

type DbEngine

type DbEngine struct {
	Tables Tables
}

func New

func New() *DbEngine

New Return new DbEngine struct

func (*DbEngine) Evaluate added in v1.0.0

func (engine *DbEngine) Evaluate(sequences *ast.Sequence) (string, error)

Evaluate - it takes sequences, map them to specific implementation and then process it in SQL engine

type IntegerValue added in v0.0.2

type IntegerValue struct {
	Value int
}

IntegerValue - Implementation of ValueInterface that is containing integer values

func (IntegerValue) GetType added in v0.0.2

func (value IntegerValue) GetType() SupportedTypes

GetType implementations

func (IntegerValue) IsEqual added in v0.0.2

func (value IntegerValue) IsEqual(valueInterface ValueInterface) bool

IsEqual implementations

func (IntegerValue) ToString added in v0.0.2

func (value IntegerValue) ToString() string

ToString implementations

type InvalidNumberOfParametersError added in v1.0.0

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

InvalidNumberOfParametersError - error thrown when user provides invalid number of expected parameters (ex. fewer values in insert than defined )

func (*InvalidNumberOfParametersError) Error added in v1.0.0

type InvalidValueTypeError added in v1.0.0

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

InvalidValueTypeError - error thrown when user provides value of different type than expected

func (*InvalidValueTypeError) Error added in v1.0.0

func (m *InvalidValueTypeError) Error() string

type NullValue added in v1.0.0

type NullValue struct {
}

NullValue - Implementation of ValueInterface that is containing null

func (NullValue) GetType added in v1.0.0

func (value NullValue) GetType() SupportedTypes

func (NullValue) IsEqual added in v1.0.0

func (value NullValue) IsEqual(valueInterface ValueInterface) bool

func (NullValue) ToString added in v1.0.0

func (value NullValue) ToString() string

type Rows added in v1.0.0

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

Rows - Contain rows that store values, alternative to Table, some operations are easier

func MapTableToRows added in v1.0.0

func MapTableToRows(table *Table) Rows

MapTableToRows - transform Table struct into Rows

type StringValue added in v0.0.2

type StringValue struct {
	Value string
}

StringValue - Implementation of ValueInterface that is containing string values

func (StringValue) GetType added in v0.0.2

func (value StringValue) GetType() SupportedTypes

func (StringValue) IsEqual added in v0.0.2

func (value StringValue) IsEqual(valueInterface ValueInterface) bool

func (StringValue) ToString added in v0.0.2

func (value StringValue) ToString() string

type SupportedTypes added in v0.0.2

type SupportedTypes int

type Table added in v0.0.2

type Table struct {
	Columns []*Column
}

Table - Contain Columns that store values in engine

func (*Table) ToString added in v0.0.2

func (table *Table) ToString() string

ToString - Return string contain all values and Column names in Table

type TableAlreadyExistsError added in v1.0.0

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

TableAlreadyExistsError - error thrown when user tries to create table using name that already exists in database

func (*TableAlreadyExistsError) Error added in v1.0.0

func (m *TableAlreadyExistsError) Error() string

type TableDoesNotExistError added in v1.0.0

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

TableDoesNotExistError - error thrown when user tries to make operation on un-existing table

func (*TableDoesNotExistError) Error added in v1.0.0

func (m *TableDoesNotExistError) Error() string

type Tables added in v1.0.0

type Tables map[string]*Table

type UnsupportedCommandTypeFromParserError added in v1.0.0

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

UnsupportedCommandTypeFromParserError - error thrown when engine found unsupported command from parser

func (*UnsupportedCommandTypeFromParserError) Error added in v1.0.0

type UnsupportedConditionalTokenError added in v1.0.0

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

UnsupportedConditionalTokenError - error thrown when engine found unsupported conditional token inside expression (supported are: EQUAL, NOT)

func (*UnsupportedConditionalTokenError) Error added in v1.0.0

type UnsupportedExpressionTypeError added in v1.0.0

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

UnsupportedExpressionTypeError - error thrown when engine found unsupported expression type

func (*UnsupportedExpressionTypeError) Error added in v1.0.0

type UnsupportedOperationTokenError added in v1.0.0

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

UnsupportedOperationTokenError - error thrown when engine found unsupported operation token (supported are: AND, OR)

func (*UnsupportedOperationTokenError) Error added in v1.0.0

type UnsupportedValueType added in v1.0.0

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

UnsupportedValueType - error thrown when engine found unsupported data type to be stored inside the columns

func (*UnsupportedValueType) Error added in v1.0.0

func (m *UnsupportedValueType) Error() string

type ValueInterface added in v0.0.2

type ValueInterface interface {
	ToString() string
	GetType() SupportedTypes
	IsEqual(valueInterface ValueInterface) bool
	// contains filtered or unexported methods
}

ValueInterface - Represent all supported types of data that can be inserted into Table

Jump to

Keyboard shortcuts

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