stmt

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type And

type And struct {
	Left  Expr
	Right Expr
}

And represents an And boolean expression.

func (*And) Write

func (a *And) Write(b Builder) error

Write writes the AND boolean expression.

type BuildError

type BuildError struct {
	Op  string
	Err error
}

BuildError is the error type usually returned by functions in the stmt package. It describes the current operation, occurred of an error.

func (*BuildError) Error

func (b *BuildError) Error() string

func (*BuildError) Unwrap

func (b *BuildError) Unwrap() error

Unwrap unwraps the wrapped error. This method is implemented to satisfy an interface of errors.Unwap.

type Builder

type Builder interface {
	WritePlaceholder()
	WriteString(string)
	AppendArgs(args ...interface{})
}

Builder an interface used to build SQL queries.

WriteString method uses the passed string is writing to the query builder. AppendArgs method uses for pass arguments corresponding to variables.

type Columns added in v0.0.2

type Columns []string

Columns represents columns field.

func (Columns) Write added in v0.0.2

func (c Columns) Write(b Builder) error

Write writes a string with concatenated column names. i.e. "col1", "col1, col2, col3"

type CompBetween

type CompBetween struct {
	Negative bool
	Left     interface{}
	Right    interface{}
}

CompBetween represents condition for using "BETWEEN".

If enabled Negative field, it's meaning use "NOT BETWEEN". This struct will convert to be like "BETWEEN left_expr AND right_expr".

func (*CompBetween) WriteComparison

func (c *CompBetween) WriteComparison(b Builder) error

WriteComparison implemented Comparisoner interface.

type CompIn

type CompIn struct {
	Negative bool
	Values   []interface{}
}

CompIn represents condition for using "IN".

If enabled Negative field, it's meaning use "NOT IN". Values field should set list to use for comparison. This struct will convert to be like "IN (?, ?, ?)".

func (*CompIn) WriteComparison

func (c *CompIn) WriteComparison(b Builder) error

WriteComparison implemented Comparisoner interface.

type CompLike

type CompLike struct {
	Negative bool
	Value    interface{}
}

CompLike represents condition for using "LIKE".

If enabled Negative field, it's meaning use "NOT LIKE". Value field should set the value to use for comparison.

func (*CompLike) WriteComparison

func (c *CompLike) WriteComparison(b Builder) error

WriteComparison implemented Comparisoner interface.

type CompOp

type CompOp struct {
	Op    string
	Value interface{}
}

CompOp represents condition for using operators.

Op field should contain "=", ">=", ">", "<=", "<", "!=", "IS", "IS NOT" Value field should set the value to use for comparison.

func (*CompOp) WriteComparison

func (c *CompOp) WriteComparison(b Builder) error

WriteComparison implemented Comparisoner interface.

type Comparisoner

type Comparisoner interface {
	WriteComparison(b Builder) error
}

Comparisoner implemented WriteComparison method.

This interface represents a conditional expression.

type Condition

type Condition struct {
	Column  string
	Compare Comparisoner
}

Condition represents condition for using Comparisoner interface.

this struct creates "<column_name> <comparable_condition>" <comparable_condition> indicates Comparisoner interface.

func (*Condition) Write

func (c *Condition) Write(b Builder) error

Write implements Expr interface.

For example: category = "music" category != "music" category LIKE "music" category NOT LIKE "music" category IN ("music", "video") category NOT IN ("music", "video")

type Expr

type Expr interface {
	Write(Builder) error
}

Expr implemented Write method.

This interface represents an expression.

type Limit added in v0.0.2

type Limit int64

Limit represents "LIMIT <limit_num>".

func (Limit) Write added in v0.0.2

func (l Limit) Write(b Builder) error

Write writes the number of limitations that the Limit has.

type Numeric added in v0.0.2

type Numeric int64

Numeric is able to replace bindvars with numeric.

i.e. "LIMIT ?" => "LIMIT numeric"

func (Numeric) Write added in v0.0.2

func (n Numeric) Write(b Builder) error

Write writes the numeric.

type Offset added in v0.0.2

type Offset int64

Offset represents "OFFSET <offset_num>".

func (Offset) Write added in v0.0.2

func (o Offset) Write(b Builder) error

Write writes the number of offsets that the Offset has.

type Or

type Or struct {
	Left  Expr
	Right Expr
}

Or represents an OR boolean expression.

func (*Or) Write

func (o *Or) Write(b Builder) error

Write writes the OR boolean expression with parentheses. Currently, the OR operator is the only one that's lower precedence than AND on most of databases.

type OrderBy added in v0.0.2

type OrderBy struct {
	Column string
	Desc   bool
	Next   *OrderBy
}

OrderBy represents "<column_name>", "<column_name> DESC". If there is Next, it represents like "<column_name>, <column_name> DESC".

func (*OrderBy) Write added in v0.0.2

func (o *OrderBy) Write(b Builder) error

Write writes expression for "ORDER BY".

type Paren

type Paren struct {
	Expr Expr
}

Paren represents a parenthesized expression.

func (*Paren) Write

func (p *Paren) Write(b Builder) error

Write writes the expression with parentheses.

type String added in v0.0.2

type String string

String is able to replace bindvars with string.

i.e. "SELECT * FROM ?" => "SELECT * FROM string"

func (String) Write added in v0.0.2

func (s String) Write(b Builder) error

Write writes the string.

Jump to

Keyboard shortcuts

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