stmt

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: MIT Imports: 2 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 {
	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 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 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 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.

Jump to

Keyboard shortcuts

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