rel

package module
v0.0.0-...-bf1d7be Latest Latest
Warning

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

Go to latest
Published: May 13, 2014 License: MIT Imports: 7 Imported by: 0

README

Rel Build Status

A SQL AST manager for Go.

Usage

package main

import (
  "fmt"
  "rel"
)

func main() {
  sql := rel.Select(rel.Star()).From("users").ToSql()
  fmt.Println(sql) // SELECT * FROM "users"
}

Where

users := rel.NewTable("users")
users.Where(users.Attr("name").Eq(rel.Sql("amy")))
// SELECT * FROM "users" WHERE "users"."name" = "amy"

Joins

users := rel.NewTable("users")
preferences := rel.NewTable("preferences")
manager := rel.Select(rel.Star()).From(users).Join(preferences).On(preferences.Attr("user_id").Eq(users.Attr("user_id")))
fmt.Println(manager.ToSql()) // SELECT * FROM "users" INNER JOIN "preferences" ON "preferences"."user_id" = "users"."user_id"

Updates

users := rel.NewTable("users")
update := rel.NewUpdateManager(rel.RelEngine)
update.Table(users).Set(users.Attr("name"), rel.Sql("amy"))
fmt.Println(update.ToSql()) // UPDATE "users" SET "name" = amy

Deletes

users := rel.NewTable("users")
delete := rel.NewDeleteManager(rel.RelEngine)
delete.From(users).Where(users.Attr("id").Eq(rel.Sql(1)))
fmt.Println(delete.ToSql()) // DELETE FROM "users" WHERE "id" = 1

Inserts

users := rel.NewTable("users")
insert := rel.Insert().Into(users).Values(users.Attr("email"), Sql("a@b.com"))
fmt.Println(insert.ToSql()) // INSERT INTO "users" ("email") VALUES ('a@b.com')

Orders

users := rel.NewTable("users")
manager := users.Select(rel.Star()).Order(users.Attr("first_name"))
fmt.Println(manager.ToSql()) // SELECT * FROM "users" ORDER BY "users"."first_name"
With Direction
users := rel.NewTable("users")
manager := users.Select(rel.Star()).Order(users.Attr("first_name").Desc())
fmt.Println(manager.ToSql()) // SELECT * FROM "users" ORDER BY "users"."first_name" DESC

Group By

users := rel.NewTable("users")
manager := users.Select(rel.Star()).GroupBy(users.Attr("first_name"))
fmt.Println(manager.ToSql()) // SELECT * FROM "users" GROUP BY "users"."first_name"

Counts

users := rel.NewTable("users")
manager := users.Select(rel.Count())
fmt.Println(manager.ToSql()) // SELECT COUNT(1) FROM "users"
users := rel.NewTable("users")
manager := users.Select(users.Attr("id").Count())
fmt.Println(manager.ToSql()) // SELECT COUNT("users"."id") FROM "users"

Database Specific SQL

Nearly every RDBMS has it's own quirks and non-standard features. For the most general cases we use the ToSqlVisitor to handle compiling the AST to a SQL statement. It's likely that consumers will want to be more specific, for example using PostgreSQL, MySQL, or SQLite.

package main

import (
  "fmt"
  "rel"
)

func main() {
  rel.RegisterDatabase("postgresql")
  fmt.Println(rel.Select(rel.Sql("*")).From("users").ToSql()) // SELECT * FROM "users"
}

rel.RegisterDatabase is a shorthand to allow easy use of built in functionality for PostgreSQL, MySQL, or SQLite.

Method Interfaces

Several methods in Rel only allow values that satisfy the Visitable interface. Rel methods will generally return Visitable values. In some cases methods will allow primitive types as method inputs when the type of input is predictable.

users := rel.NewTable("users")
users.Having(users.Attr("id").Eq(rel.Sql(10)))
// SELECT FROM "users" HAVING "users"."id" = 10

Breaking down the code here, users is a Table type. Table#Having allows a variadic number of values that satisfy the Visitable interface. users.Attr("id") returns a pointer to an AttributeNode and only accepts a string. SQL table fields/attributes can be expressed in terms of strings so an input satifying the Visitable interface isn't required because it's only ever necessary to use a string. AttributeNode#Eq allows a single Visitable type as an input. We use the Sql method to wrap an int value in a SqlLiteralNode to satisfy the Visitable interface requirement of AttributeNode#Eq.

The type of input for AttributeNode#Eq is somewhat predictable ahead of time. In some cases a user may want to use an int, string, or another AttributeNode. That means using an interface. When an input type is unpredictable, Rel uses the Visitable type for input as opposed to an empty interface, and offers the Sql method as a way to convert primitive types to a value that will satisfy the Visitable interface.

Author

twitter/aaronackerman
Aaron Ackerman

License

MIT

Documentation

Index

Constants

View Source
const (
	WHERE    = " WHERE "
	SPACE    = " "
	COMMA    = ", "
	GROUP_BY = " GROUP BY "
	ORDER_BY = " ORDER BY "
	WINDOW   = " WINDOW "
	AND      = " AND "
	DISTINCT = "DISTINCT"
)

Variables

This section is empty.

Functions

func RegisterDatabase

func RegisterDatabase(db string)

func RegisterEngine

func RegisterEngine(engine Engine)

Types

type Aliaser

type Aliaser interface {
	As(SqlLiteralNode) *AsNode
	Visitable
}

type AndNode

type AndNode struct {
	Children *[]Visitable
	BaseVisitable
}

func (AndNode) Eq

func (node AndNode) Eq(other AndNode) bool

type AsNode

type AsNode struct {
	Left  Visitable
	Right Visitable
	BaseVisitable
}

func (AsNode) Eq

func (node AsNode) Eq(other AsNode) bool

type AscendingNode

type AscendingNode OrderingNode

func (*AscendingNode) Direction

func (node *AscendingNode) Direction() string

func (AscendingNode) Eq

func (node AscendingNode) Eq(other AscendingNode) bool

func (*AscendingNode) Reverse

func (node *AscendingNode) Reverse() *DescendingNode

type AssignmentNode

type AssignmentNode BinaryNode

type AttributeNode

type AttributeNode struct {
	Name     SqlLiteralNode
	Relation Visitable
	BaseVisitable
}

func NewAttributeNode

func NewAttributeNode(v Visitable, name string) *AttributeNode

func (*AttributeNode) As

func (node *AttributeNode) As(literal SqlLiteralNode) *AsNode

func (*AttributeNode) Asc

func (node *AttributeNode) Asc() *AscendingNode

func (*AttributeNode) Count

func (node *AttributeNode) Count() *CountNode

func (*AttributeNode) Desc

func (node *AttributeNode) Desc() *DescendingNode

func (*AttributeNode) DoesNotMatch

func (node *AttributeNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (*AttributeNode) DoesNotMatchAll

func (node *AttributeNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (*AttributeNode) DoesNotMatchAny

func (node *AttributeNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (*AttributeNode) Eq

func (node *AttributeNode) Eq(visitable Visitable) *EqualityNode

func (*AttributeNode) EqAll

func (node *AttributeNode) EqAll(visitables ...Visitable) *GroupingNode

func (*AttributeNode) EqAny

func (node *AttributeNode) EqAny(visitables ...Visitable) *GroupingNode

func (*AttributeNode) Extract

func (node *AttributeNode) Extract(literal SqlLiteralNode) *ExtractNode

func (*AttributeNode) Gt

func (node *AttributeNode) Gt(visitable Visitable) *GreaterThanNode

func (*AttributeNode) GtAll

func (node *AttributeNode) GtAll(visitables ...Visitable) *GroupingNode

func (*AttributeNode) GtAny

func (node *AttributeNode) GtAny(visitables ...Visitable) *GroupingNode

func (*AttributeNode) GtEq

func (node *AttributeNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (*AttributeNode) GtEqAll

func (node *AttributeNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (*AttributeNode) GtEqAny

func (node *AttributeNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (*AttributeNode) In

func (node *AttributeNode) In(visitables []Visitable) Visitable

func (*AttributeNode) InAll

func (node *AttributeNode) InAll(visitableslices ...[]Visitable) Visitable

func (*AttributeNode) InAny

func (node *AttributeNode) InAny(visitableslices ...[]Visitable) Visitable

func (*AttributeNode) Lt

func (node *AttributeNode) Lt(visitable Visitable) *LessThanNode

func (*AttributeNode) LtAll

func (node *AttributeNode) LtAll(visitables ...Visitable) *GroupingNode

func (*AttributeNode) LtAny

func (node *AttributeNode) LtAny(visitables ...Visitable) *GroupingNode

func (*AttributeNode) LtEq

func (node *AttributeNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (*AttributeNode) LtEqAll

func (node *AttributeNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (*AttributeNode) LtEqAny

func (node *AttributeNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (*AttributeNode) Matches

func (node *AttributeNode) Matches(literal SqlLiteralNode) *MatchesNode

func (*AttributeNode) MatchesAll

func (node *AttributeNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (*AttributeNode) MatchesAny

func (node *AttributeNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (*AttributeNode) NotEq

func (node *AttributeNode) NotEq(visitable Visitable) *NotEqualNode

func (*AttributeNode) NotEqAll

func (node *AttributeNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (*AttributeNode) NotEqAny

func (node *AttributeNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (*AttributeNode) NotIn

func (node *AttributeNode) NotIn(visitables []Visitable) Visitable

func (*AttributeNode) NotInAll

func (node *AttributeNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (*AttributeNode) NotInAny

func (node *AttributeNode) NotInAny(visitableslices ...[]Visitable) Visitable

type AvgNode

type AvgNode FunctionNode

func Avg

func Avg(attr *AttributeNode) *AvgNode

type BaseVisitable

type BaseVisitable struct{}

BaseVisitable satisfies the Visitable Interface All other nodes should have an embedded BaseVisitable

func (BaseVisitable) NewAndNode

func (v BaseVisitable) NewAndNode(n ...Visitable) *AndNode

func (BaseVisitable) NewFalseNode

func (v BaseVisitable) NewFalseNode() *FalseNode

func (BaseVisitable) NewGroupingNode

func (v BaseVisitable) NewGroupingNode() *GroupingNode

func (BaseVisitable) NewInnerJoinNode

func (v BaseVisitable) NewInnerJoinNode() *InnerJoinNode

func (BaseVisitable) NewNamedFunctionNode

func (v BaseVisitable) NewNamedFunctionNode() *NamedFunctionNode

func (BaseVisitable) NewNotNode

func (v BaseVisitable) NewNotNode() *NotNode

func (BaseVisitable) NewOnNode

func (v BaseVisitable) NewOnNode(visitable Visitable) *OnNode

func (BaseVisitable) NewOuterJoinNode

func (v BaseVisitable) NewOuterJoinNode() *OuterJoinNode

func (BaseVisitable) NewTableAliasNode

func (v BaseVisitable) NewTableAliasNode(t *Table, name string) *TableAliasNode

func (BaseVisitable) NewTrueNode

func (v BaseVisitable) NewTrueNode() *TrueNode

func (BaseVisitable) String

func (v BaseVisitable) String() string

type BetweenNode

type BetweenNode BinaryNode

type BinNode

type BinNode UnaryNode

func NewBinNode

func NewBinNode(visitable Visitable) *BinNode

func (BinNode) Eq

func (node BinNode) Eq(other BinNode) bool

type BinaryNode

type BinaryNode struct {
	Left  Visitable
	Right Visitable
	BaseVisitable
}

func NewBinaryNode

func NewBinaryNode(left Visitable, right Visitable) BinaryNode

type BindParamNode

type BindParamNode struct {
	Raw string
	BaseVisitable
}

func NewBindParamNode

func NewBindParamNode(raw string) *BindParamNode

func (*BindParamNode) String

func (node *BindParamNode) String() string

type Connector

type Connector interface {
	QuoteTableName(string) string
	QuoteColumnName(string) string
	Quote(interface{}) string
}

type CountNode

type CountNode FunctionNode

func Count

func Count() *CountNode

func (*CountNode) As

func (node *CountNode) As(literal SqlLiteralNode) *AsNode

func (*CountNode) Asc

func (node *CountNode) Asc() *AscendingNode

func (*CountNode) Desc

func (node *CountNode) Desc() *DescendingNode

func (CountNode) Eq

func (node CountNode) Eq(other CountNode) bool

func (*CountNode) Over

func (node *CountNode) Over(visitable Visitable) *OverNode

type CurrentRowNode

type CurrentRowNode UnaryNode

type DefaultConnector

type DefaultConnector struct{}

func (DefaultConnector) Quote

func (c DefaultConnector) Quote(thing interface{}) string

func (DefaultConnector) QuoteColumnName

func (c DefaultConnector) QuoteColumnName(name string) string

func (DefaultConnector) QuoteTableName

func (c DefaultConnector) QuoteTableName(name string) string

type DefaultEngine

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

func (DefaultEngine) Visitor

func (e DefaultEngine) Visitor() Visitor

type DeleteManager

type DeleteManager struct {
	Engine Engine
	Ast    *DeleteStatementNode
	BaseVisitable
}

func Delete

func Delete() *DeleteManager

func NewDeleteManager

func NewDeleteManager(engine Engine) *DeleteManager

func (*DeleteManager) From

func (mgr *DeleteManager) From(table interface{}) *DeleteManager

func (*DeleteManager) FromTable

func (mgr *DeleteManager) FromTable(table *Table) *DeleteManager

func (*DeleteManager) ToSql

func (mgr *DeleteManager) ToSql() string

func (*DeleteManager) Where

func (mgr *DeleteManager) Where(visitable Visitable) *DeleteManager

type DeleteStatementNode

type DeleteStatementNode struct {
	Relation *Table
	Wheres   *[]Visitable
	BaseVisitable
}

func NewDeleteStatementNode

func NewDeleteStatementNode() *DeleteStatementNode

func (DeleteStatementNode) Eq

type DescendingNode

type DescendingNode OrderingNode

func (*DescendingNode) Direction

func (node *DescendingNode) Direction() string

func (DescendingNode) Eq

func (node DescendingNode) Eq(other DescendingNode) bool

func (*DescendingNode) Reverse

func (node *DescendingNode) Reverse() *AscendingNode

type DistinctNode

type DistinctNode struct {
	BaseVisitable
}

type DistinctOnNode

type DistinctOnNode UnaryNode

func NewDistinctOnNode

func NewDistinctOnNode(visitable Visitable) *DistinctOnNode

type DoesNotMatchNode

type DoesNotMatchNode BinaryNode

type Engine

type Engine interface {
	Visitor() Visitor
}
var RelEngine Engine = &DefaultEngine{
	visitor: &ToSqlVisitor{Conn: DefaultConnector{}},
}

type EqualityNode

type EqualityNode struct {
	Left  Visitable
	Right Visitable
	BaseVisitable
}

func NewEqualityNode

func NewEqualityNode(left Visitable, right Visitable) EqualityNode

func (EqualityNode) And

func (node EqualityNode) And(other Visitable) *GroupingNode

func (EqualityNode) Or

func (node EqualityNode) Or(other Visitable) *GroupingNode

type ExceptNode

type ExceptNode BinaryNode

type ExistsNode

type ExistsNode FunctionNode

func NewExistsNode

func NewExistsNode(v Visitable) *ExistsNode

func (ExistsNode) As

func (node ExistsNode) As(literal SqlLiteralNode) *AsNode

func (ExistsNode) Asc

func (node ExistsNode) Asc() *AscendingNode

func (ExistsNode) Count

func (node ExistsNode) Count() *CountNode

func (ExistsNode) Desc

func (node ExistsNode) Desc() *DescendingNode

func (ExistsNode) DoesNotMatch

func (node ExistsNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (ExistsNode) DoesNotMatchAll

func (node ExistsNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (ExistsNode) DoesNotMatchAny

func (node ExistsNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (ExistsNode) Eq

func (node ExistsNode) Eq(visitable Visitable) *EqualityNode

func (ExistsNode) EqAll

func (node ExistsNode) EqAll(visitables ...Visitable) *GroupingNode

func (ExistsNode) EqAny

func (node ExistsNode) EqAny(visitables ...Visitable) *GroupingNode

func (ExistsNode) Extract

func (node ExistsNode) Extract(literal SqlLiteralNode) *ExtractNode

func (ExistsNode) Gt

func (node ExistsNode) Gt(visitable Visitable) *GreaterThanNode

func (ExistsNode) GtAll

func (node ExistsNode) GtAll(visitables ...Visitable) *GroupingNode

func (ExistsNode) GtAny

func (node ExistsNode) GtAny(visitables ...Visitable) *GroupingNode

func (ExistsNode) GtEq

func (node ExistsNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (ExistsNode) GtEqAll

func (node ExistsNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (ExistsNode) GtEqAny

func (node ExistsNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (ExistsNode) In

func (node ExistsNode) In(visitables []Visitable) Visitable

func (ExistsNode) InAll

func (node ExistsNode) InAll(visitableslices ...[]Visitable) Visitable

func (ExistsNode) InAny

func (node ExistsNode) InAny(visitableslices ...[]Visitable) Visitable

func (ExistsNode) Lt

func (node ExistsNode) Lt(visitable Visitable) *LessThanNode

func (ExistsNode) LtAll

func (node ExistsNode) LtAll(visitables ...Visitable) *GroupingNode

func (ExistsNode) LtAny

func (node ExistsNode) LtAny(visitables ...Visitable) *GroupingNode

func (ExistsNode) LtEq

func (node ExistsNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (ExistsNode) LtEqAll

func (node ExistsNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (ExistsNode) LtEqAny

func (node ExistsNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (ExistsNode) Matches

func (node ExistsNode) Matches(literal SqlLiteralNode) *MatchesNode

func (ExistsNode) MatchesAll

func (node ExistsNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (ExistsNode) MatchesAny

func (node ExistsNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (ExistsNode) NotEq

func (node ExistsNode) NotEq(visitable Visitable) *NotEqualNode

func (ExistsNode) NotEqAll

func (node ExistsNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (ExistsNode) NotEqAny

func (node ExistsNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (ExistsNode) NotIn

func (node ExistsNode) NotIn(visitables []Visitable) Visitable

func (ExistsNode) NotInAll

func (node ExistsNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (ExistsNode) NotInAny

func (node ExistsNode) NotInAny(visitableslices ...[]Visitable) Visitable

type ExtractNode

type ExtractNode struct {
	Expressions []Visitable
	Field       *SqlLiteralNode
	Alias       *SqlLiteralNode
	BaseVisitable
}

func (*ExtractNode) As

func (node *ExtractNode) As(n SqlLiteralNode) *ExtractNode

func (*ExtractNode) Asc

func (node *ExtractNode) Asc() *AscendingNode

func (*ExtractNode) Count

func (node *ExtractNode) Count() *CountNode

func (*ExtractNode) Desc

func (node *ExtractNode) Desc() *DescendingNode

func (*ExtractNode) DoesNotMatch

func (node *ExtractNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (*ExtractNode) DoesNotMatchAll

func (node *ExtractNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (*ExtractNode) DoesNotMatchAny

func (node *ExtractNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (*ExtractNode) Eq

func (node *ExtractNode) Eq(visitable Visitable) *EqualityNode

func (*ExtractNode) EqAll

func (node *ExtractNode) EqAll(visitables ...Visitable) *GroupingNode

func (*ExtractNode) EqAny

func (node *ExtractNode) EqAny(visitables ...Visitable) *GroupingNode

func (*ExtractNode) Extract

func (node *ExtractNode) Extract(literal SqlLiteralNode) *ExtractNode

func (*ExtractNode) Gt

func (node *ExtractNode) Gt(visitable Visitable) *GreaterThanNode

func (*ExtractNode) GtAll

func (node *ExtractNode) GtAll(visitables ...Visitable) *GroupingNode

func (*ExtractNode) GtAny

func (node *ExtractNode) GtAny(visitables ...Visitable) *GroupingNode

func (*ExtractNode) GtEq

func (node *ExtractNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (*ExtractNode) GtEqAll

func (node *ExtractNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (*ExtractNode) GtEqAny

func (node *ExtractNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (*ExtractNode) In

func (node *ExtractNode) In(visitables []Visitable) Visitable

func (*ExtractNode) InAll

func (node *ExtractNode) InAll(visitableslices ...[]Visitable) Visitable

func (*ExtractNode) InAny

func (node *ExtractNode) InAny(visitableslices ...[]Visitable) Visitable

func (*ExtractNode) Lt

func (node *ExtractNode) Lt(visitable Visitable) *LessThanNode

func (*ExtractNode) LtAll

func (node *ExtractNode) LtAll(visitables ...Visitable) *GroupingNode

func (*ExtractNode) LtAny

func (node *ExtractNode) LtAny(visitables ...Visitable) *GroupingNode

func (*ExtractNode) LtEq

func (node *ExtractNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (*ExtractNode) LtEqAll

func (node *ExtractNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (*ExtractNode) LtEqAny

func (node *ExtractNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (*ExtractNode) Matches

func (node *ExtractNode) Matches(literal SqlLiteralNode) *MatchesNode

func (*ExtractNode) MatchesAll

func (node *ExtractNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (*ExtractNode) MatchesAny

func (node *ExtractNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (*ExtractNode) NotEq

func (node *ExtractNode) NotEq(visitable Visitable) *NotEqualNode

func (*ExtractNode) NotEqAll

func (node *ExtractNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (*ExtractNode) NotEqAny

func (node *ExtractNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (*ExtractNode) NotIn

func (node *ExtractNode) NotIn(visitables []Visitable) Visitable

func (*ExtractNode) NotInAll

func (node *ExtractNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (*ExtractNode) NotInAny

func (node *ExtractNode) NotInAny(visitableslices ...[]Visitable) Visitable

type FalseNode

type FalseNode struct {
	BaseVisitable
}

type FollowingNode

type FollowingNode UnaryNode

type FunctionNode

type FunctionNode struct {
	Expressions []Visitable
	Alias       *SqlLiteralNode
	Distinct    bool
	BaseVisitable
}

func (*FunctionNode) Count

func (node *FunctionNode) Count() *CountNode

func (*FunctionNode) DoesNotMatch

func (node *FunctionNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (*FunctionNode) DoesNotMatchAll

func (node *FunctionNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (*FunctionNode) DoesNotMatchAny

func (node *FunctionNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (*FunctionNode) Eq

func (node *FunctionNode) Eq(visitable Visitable) *EqualityNode

func (*FunctionNode) EqAll

func (node *FunctionNode) EqAll(visitables ...Visitable) *GroupingNode

func (*FunctionNode) EqAny

func (node *FunctionNode) EqAny(visitables ...Visitable) *GroupingNode

func (*FunctionNode) Extract

func (node *FunctionNode) Extract(literal SqlLiteralNode) *ExtractNode

func (*FunctionNode) Gt

func (node *FunctionNode) Gt(visitable Visitable) *GreaterThanNode

func (*FunctionNode) GtAll

func (node *FunctionNode) GtAll(visitables ...Visitable) *GroupingNode

func (*FunctionNode) GtAny

func (node *FunctionNode) GtAny(visitables ...Visitable) *GroupingNode

func (*FunctionNode) GtEq

func (node *FunctionNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (*FunctionNode) GtEqAll

func (node *FunctionNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (*FunctionNode) GtEqAny

func (node *FunctionNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (*FunctionNode) In

func (node *FunctionNode) In(visitables []Visitable) Visitable

func (*FunctionNode) InAll

func (node *FunctionNode) InAll(visitableslices ...[]Visitable) Visitable

func (*FunctionNode) InAny

func (node *FunctionNode) InAny(visitableslices ...[]Visitable) Visitable

func (*FunctionNode) Lt

func (node *FunctionNode) Lt(visitable Visitable) *LessThanNode

func (*FunctionNode) LtAll

func (node *FunctionNode) LtAll(visitables ...Visitable) *GroupingNode

func (*FunctionNode) LtAny

func (node *FunctionNode) LtAny(visitables ...Visitable) *GroupingNode

func (*FunctionNode) LtEq

func (node *FunctionNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (*FunctionNode) LtEqAll

func (node *FunctionNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (*FunctionNode) LtEqAny

func (node *FunctionNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (*FunctionNode) Matches

func (node *FunctionNode) Matches(literal SqlLiteralNode) *MatchesNode

func (*FunctionNode) MatchesAll

func (node *FunctionNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (*FunctionNode) MatchesAny

func (node *FunctionNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (*FunctionNode) NotEq

func (node *FunctionNode) NotEq(visitable Visitable) *NotEqualNode

func (*FunctionNode) NotEqAll

func (node *FunctionNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (*FunctionNode) NotEqAny

func (node *FunctionNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (*FunctionNode) NotIn

func (node *FunctionNode) NotIn(visitables []Visitable) Visitable

func (*FunctionNode) NotInAll

func (node *FunctionNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (*FunctionNode) NotInAny

func (node *FunctionNode) NotInAny(visitableslices ...[]Visitable) Visitable

func (*FunctionNode) Over

func (node *FunctionNode) Over(visitable Visitable) *OverNode

type GreaterThanNode

type GreaterThanNode BinaryNode

type GreaterThanOrEqualNode

type GreaterThanOrEqualNode BinaryNode

type GroupNode

type GroupNode UnaryNode

func NewGroupNode

func NewGroupNode(visitable Visitable) *GroupNode

type GroupingNode

type GroupingNode struct {
	Expr []Visitable
	BaseVisitable
}

func (GroupingNode) As

func (node GroupingNode) As(literal SqlLiteralNode) *AsNode

func (GroupingNode) Asc

func (node GroupingNode) Asc() *AscendingNode

func (GroupingNode) Count

func (node GroupingNode) Count() *CountNode

func (GroupingNode) Desc

func (node GroupingNode) Desc() *DescendingNode

func (GroupingNode) DoesNotMatch

func (node GroupingNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (GroupingNode) DoesNotMatchAll

func (node GroupingNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (GroupingNode) DoesNotMatchAny

func (node GroupingNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (GroupingNode) Eq

func (node GroupingNode) Eq(visitable Visitable) *EqualityNode

func (GroupingNode) EqAll

func (node GroupingNode) EqAll(visitables ...Visitable) *GroupingNode

func (GroupingNode) EqAny

func (node GroupingNode) EqAny(visitables ...Visitable) *GroupingNode

func (GroupingNode) Extract

func (node GroupingNode) Extract(literal SqlLiteralNode) *ExtractNode

func (GroupingNode) Gt

func (node GroupingNode) Gt(visitable Visitable) *GreaterThanNode

func (GroupingNode) GtAll

func (node GroupingNode) GtAll(visitables ...Visitable) *GroupingNode

func (GroupingNode) GtAny

func (node GroupingNode) GtAny(visitables ...Visitable) *GroupingNode

func (GroupingNode) GtEq

func (node GroupingNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (GroupingNode) GtEqAll

func (node GroupingNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (GroupingNode) GtEqAny

func (node GroupingNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (GroupingNode) In

func (node GroupingNode) In(visitables []Visitable) Visitable

func (GroupingNode) InAll

func (node GroupingNode) InAll(visitableslices ...[]Visitable) Visitable

func (GroupingNode) InAny

func (node GroupingNode) InAny(visitableslices ...[]Visitable) Visitable

func (GroupingNode) Lt

func (node GroupingNode) Lt(visitable Visitable) *LessThanNode

func (GroupingNode) LtAll

func (node GroupingNode) LtAll(visitables ...Visitable) *GroupingNode

func (GroupingNode) LtAny

func (node GroupingNode) LtAny(visitables ...Visitable) *GroupingNode

func (GroupingNode) LtEq

func (node GroupingNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (GroupingNode) LtEqAll

func (node GroupingNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (GroupingNode) LtEqAny

func (node GroupingNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (GroupingNode) Matches

func (node GroupingNode) Matches(literal SqlLiteralNode) *MatchesNode

func (GroupingNode) MatchesAll

func (node GroupingNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (GroupingNode) MatchesAny

func (node GroupingNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (GroupingNode) NotEq

func (node GroupingNode) NotEq(visitable Visitable) *NotEqualNode

func (GroupingNode) NotEqAll

func (node GroupingNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (GroupingNode) NotEqAny

func (node GroupingNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (GroupingNode) NotIn

func (node GroupingNode) NotIn(visitables []Visitable) Visitable

func (GroupingNode) NotInAll

func (node GroupingNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (GroupingNode) NotInAny

func (node GroupingNode) NotInAny(visitableslices ...[]Visitable) Visitable

type HavingNode

type HavingNode UnaryNode

func NewHavingNode

func NewHavingNode(visitable Visitable) *HavingNode

type InNode

type InNode struct {
	Left  Visitable
	Right []Visitable
	BaseVisitable
}

type InfixOperationNode

type InfixOperationNode struct {
	Operator SqlLiteralNode
	Left     Visitable
	Right    Visitable
	BaseVisitable
}

func (InfixOperationNode) As

func (node InfixOperationNode) As(literal SqlLiteralNode) *AsNode

func (InfixOperationNode) Asc

func (node InfixOperationNode) Asc() *AscendingNode

func (InfixOperationNode) Count

func (node InfixOperationNode) Count() *CountNode

func (InfixOperationNode) Desc

func (node InfixOperationNode) Desc() *DescendingNode

func (InfixOperationNode) DoesNotMatch

func (node InfixOperationNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (InfixOperationNode) DoesNotMatchAll

func (node InfixOperationNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (InfixOperationNode) DoesNotMatchAny

func (node InfixOperationNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (InfixOperationNode) Eq

func (node InfixOperationNode) Eq(visitable Visitable) *EqualityNode

func (InfixOperationNode) EqAll

func (node InfixOperationNode) EqAll(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) EqAny

func (node InfixOperationNode) EqAny(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) Extract

func (node InfixOperationNode) Extract(literal SqlLiteralNode) *ExtractNode

func (InfixOperationNode) Gt

func (node InfixOperationNode) Gt(visitable Visitable) *GreaterThanNode

func (InfixOperationNode) GtAll

func (node InfixOperationNode) GtAll(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) GtAny

func (node InfixOperationNode) GtAny(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) GtEq

func (node InfixOperationNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (InfixOperationNode) GtEqAll

func (node InfixOperationNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) GtEqAny

func (node InfixOperationNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) In

func (node InfixOperationNode) In(visitables []Visitable) Visitable

func (InfixOperationNode) InAll

func (node InfixOperationNode) InAll(visitableslices ...[]Visitable) Visitable

func (InfixOperationNode) InAny

func (node InfixOperationNode) InAny(visitableslices ...[]Visitable) Visitable

func (InfixOperationNode) Lt

func (node InfixOperationNode) Lt(visitable Visitable) *LessThanNode

func (InfixOperationNode) LtAll

func (node InfixOperationNode) LtAll(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) LtAny

func (node InfixOperationNode) LtAny(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) LtEq

func (node InfixOperationNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (InfixOperationNode) LtEqAll

func (node InfixOperationNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) LtEqAny

func (node InfixOperationNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) Matches

func (node InfixOperationNode) Matches(literal SqlLiteralNode) *MatchesNode

func (InfixOperationNode) MatchesAll

func (node InfixOperationNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (InfixOperationNode) MatchesAny

func (node InfixOperationNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (InfixOperationNode) NotEq

func (node InfixOperationNode) NotEq(visitable Visitable) *NotEqualNode

func (InfixOperationNode) NotEqAll

func (node InfixOperationNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) NotEqAny

func (node InfixOperationNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (InfixOperationNode) NotIn

func (node InfixOperationNode) NotIn(visitables []Visitable) Visitable

func (InfixOperationNode) NotInAll

func (node InfixOperationNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (InfixOperationNode) NotInAny

func (node InfixOperationNode) NotInAny(visitableslices ...[]Visitable) Visitable

type InnerJoinNode

type InnerJoinNode JoinNode

type InsertManager

type InsertManager struct {
	Engine Engine
	Ast    *InsertStatementNode
	BaseVisitable
}

func Insert

func Insert() *InsertManager

func NewInsertManager

func NewInsertManager(engine Engine) *InsertManager

func (*InsertManager) CreateValues

func (mgr *InsertManager) CreateValues(values []interface{}, columns []*AttributeNode) *ValuesNode

func (*InsertManager) Insert

func (mgr *InsertManager) Insert(column *AttributeNode, value interface{}) *InsertManager

func (*InsertManager) Into

func (mgr *InsertManager) Into(table *Table) *InsertManager

func (*InsertManager) SetValues

func (mgr *InsertManager) SetValues(values *ValuesNode)

func (*InsertManager) ToSql

func (mgr *InsertManager) ToSql() string

func (*InsertManager) Values

func (mgr *InsertManager) Values(column *AttributeNode, value interface{}) *InsertManager

type InsertStatementNode

type InsertStatementNode struct {
	Relation *Table
	Columns  *[]*AttributeNode
	Values   *ValuesNode
	BaseVisitable
}

func (*InsertStatementNode) Eq

type IntersectNode

type IntersectNode BinaryNode

type JoinNode

type JoinNode BinaryNode

type JoinSource

type JoinSource struct {
	Left  Visitable
	Right []Visitable
	BaseVisitable
}

type LessThanNode

type LessThanNode BinaryNode

type LessThanOrEqualNode

type LessThanOrEqualNode BinaryNode

type LimitNode

type LimitNode UnaryNode

func NewLimitNode

func NewLimitNode(visitable Visitable) *LimitNode

type LockNode

type LockNode UnaryNode

func NewLockNode

func NewLockNode(visitable Visitable) *LockNode

type MatchesNode

type MatchesNode BinaryNode

type MaxNode

type MaxNode FunctionNode

func Max

func Max(attr *AttributeNode) *MaxNode

type MinNode

type MinNode FunctionNode

func Min

func Min(attr *AttributeNode) *MinNode

type MultiStatementManager

type MultiStatementManager struct {
	Engine Engine
	Ast    Visitable
	BaseVisitable
}

A TreeManager allowing for EXCEPT, INTERSECT, UNION and UNION ALL statements

func NewMultiStatementManager

func NewMultiStatementManager(e Engine) *MultiStatementManager

func (*MultiStatementManager) Except

func (*MultiStatementManager) Intersect

func (mgr *MultiStatementManager) Intersect(stmt1 Visitable, stmt2 Visitable) *MultiStatementManager

func (*MultiStatementManager) ToSql

func (mgr *MultiStatementManager) ToSql() string

func (*MultiStatementManager) Union

func (*MultiStatementManager) UnionAll

func (mgr *MultiStatementManager) UnionAll(stmt1 Visitable, stmt2 Visitable) *MultiStatementManager

type MysqlVisitor

type MysqlVisitor struct {
	Conn Connector
}

func (MysqlVisitor) Accept

func (v MysqlVisitor) Accept(visitable Visitable) string

func (MysqlVisitor) Quote

func (v MysqlVisitor) Quote(thing interface{}) string

func (MysqlVisitor) QuoteColumnName

func (v MysqlVisitor) QuoteColumnName(literal SqlLiteralNode) string

func (MysqlVisitor) QuoteTableName

func (v MysqlVisitor) QuoteTableName(visitable Visitable) string

func (MysqlVisitor) Visit

func (v MysqlVisitor) Visit(visitable Visitable) string

type NamedFunctionNode

type NamedFunctionNode struct {
	Name *SqlLiteralNode
	FunctionNode
}

type NamedWindowNode

type NamedWindowNode struct {
	Name    SqlLiteralNode
	Orders  *[]Visitable
	Framing Visitable
	BaseVisitable
}

func (*NamedWindowNode) Frame

func (node *NamedWindowNode) Frame(v Visitable) Visitable

func (*NamedWindowNode) Order

func (node *NamedWindowNode) Order(v Visitable) *NamedWindowNode

func (*NamedWindowNode) Range

func (node *NamedWindowNode) Range(v Visitable) Visitable

func (*NamedWindowNode) Rows

func (node *NamedWindowNode) Rows(v Visitable) Visitable

type NotEqualNode

type NotEqualNode BinaryNode

type NotInNode

type NotInNode struct {
	Left  Visitable
	Right []Visitable
	BaseVisitable
}

type NotNode

type NotNode UnaryNode

func NewNotNode

func NewNotNode(visitable Visitable) *NotNode

type OffsetNode

type OffsetNode UnaryNode

func NewOffsetNode

func NewOffsetNode(visitable Visitable) *OffsetNode

type OnNode

type OnNode UnaryNode

type OrNode

type OrNode BinaryNode

type Orderer

type Orderer interface {
	Desc() *DescendingNode
	Asc() *AscendingNode
	Visitable
}

type OrderingNode

type OrderingNode UnaryNode

func NewOrderingNode

func NewOrderingNode(visitable Visitable) *OrderingNode

type OuterJoinNode

type OuterJoinNode JoinNode

type OverNode

type OverNode BinaryNode

func (*OverNode) As

func (node *OverNode) As(literal SqlLiteralNode) *AsNode

type PostgreSQLVisitor

type PostgreSQLVisitor struct {
	Conn Connector
}

Used to handle generating Postgres specific sql

func (*PostgreSQLVisitor) Accept

func (v *PostgreSQLVisitor) Accept(visitable Visitable) string

func (PostgreSQLVisitor) Quote

func (v PostgreSQLVisitor) Quote(thing interface{}) string

func (PostgreSQLVisitor) QuoteColumnName

func (v PostgreSQLVisitor) QuoteColumnName(literal SqlLiteralNode) string

func (PostgreSQLVisitor) QuoteTableName

func (v PostgreSQLVisitor) QuoteTableName(visitable Visitable) string

func (*PostgreSQLVisitor) Visit

func (v *PostgreSQLVisitor) Visit(visitable Visitable) string

type PrecedingNode

type PrecedingNode UnaryNode

type QuotedNode

type QuotedNode struct {
	Raw string
	BaseVisitable
}

Handles specific cases where sql must be single quoted As is the case with matching statements such as LIKE and NOT LIKE as well as ILIKE and NOT ILIKE in PostgreSQL

type RangeNode

type RangeNode UnaryNode

type RowsNode

type RowsNode UnaryNode

type SQLiteVisitor

type SQLiteVisitor struct {
	Conn Connector
}

Used to handle generating Postgres specific sql

func (SQLiteVisitor) Accept

func (v SQLiteVisitor) Accept(visitable Visitable) string

func (SQLiteVisitor) Quote

func (v SQLiteVisitor) Quote(thing interface{}) string

func (SQLiteVisitor) QuoteColumnName

func (v SQLiteVisitor) QuoteColumnName(literal SqlLiteralNode) string

func (SQLiteVisitor) QuoteTableName

func (v SQLiteVisitor) QuoteTableName(visitable Visitable) string

func (SQLiteVisitor) Visit

func (v SQLiteVisitor) Visit(visitable Visitable) string

type SelectCoreNode

type SelectCoreNode struct {
	Source        *JoinSource
	Top           *TopNode
	Selections    *[]Visitable
	SetQuantifier Visitable
	Wheres        *[]Visitable
	Groups        *[]Visitable
	Having        *HavingNode
	Windows       *[]Visitable
	BaseVisitable
}

func NewSelectCoreNode

func NewSelectCoreNode() *SelectCoreNode

func (*SelectCoreNode) SetFrom

func (node *SelectCoreNode) SetFrom(v Visitable)

type SelectManager

type SelectManager struct {
	Engine Engine
	Ast    *SelectStatementNode
	Ctx    *SelectCoreNode
	BaseVisitable
}

func NewSelectManager

func NewSelectManager(engine Engine, table *Table) *SelectManager

func Select

func Select(visitables ...Visitable) *SelectManager

func (*SelectManager) As

func (mgr *SelectManager) As(name string) *TableAliasNode

func (*SelectManager) Distinct

func (mgr *SelectManager) Distinct() *SelectManager

func (*SelectManager) Except

func (mgr *SelectManager) Except(stmt1 Visitable, stmt2 Visitable) *MultiStatementManager

func (*SelectManager) Exists

func (mgr *SelectManager) Exists() *ExistsNode

func (*SelectManager) From

func (mgr *SelectManager) From(table interface{}) *SelectManager

func (*SelectManager) Group

func (mgr *SelectManager) Group(visitables ...Visitable) *SelectManager

func (*SelectManager) GroupBy

func (mgr *SelectManager) GroupBy(visitables ...Visitable) *SelectManager

func (*SelectManager) Having

func (mgr *SelectManager) Having(visitables ...Visitable) *SelectManager

func (*SelectManager) InnerJoin

func (mgr *SelectManager) InnerJoin(visitable Visitable) *SelectManager

func (*SelectManager) Intersect

func (mgr *SelectManager) Intersect(stmt1 Visitable, stmt2 Visitable) *MultiStatementManager

func (*SelectManager) Join

func (mgr *SelectManager) Join(visitable Visitable) *SelectManager

func (*SelectManager) Limit

func (mgr *SelectManager) Limit(i int) *SelectManager

func (*SelectManager) Lock

func (mgr *SelectManager) Lock(node SqlLiteralNode) *SelectManager

func (*SelectManager) LockForUpdate

func (mgr *SelectManager) LockForUpdate() *SelectManager

func (*SelectManager) NotDistinct

func (mgr *SelectManager) NotDistinct() *SelectManager

func (*SelectManager) Offset

func (mgr *SelectManager) Offset(i int) *SelectManager

func (*SelectManager) On

func (mgr *SelectManager) On(visitables ...Visitable) *SelectManager

func (*SelectManager) Order

func (mgr *SelectManager) Order(visitables ...Visitable) *SelectManager

func (*SelectManager) OuterJoin

func (mgr *SelectManager) OuterJoin(visitable Visitable) *SelectManager

func (*SelectManager) Project

func (mgr *SelectManager) Project(visitables ...Visitable) *SelectManager

func (*SelectManager) Select

func (mgr *SelectManager) Select(visitables ...Visitable) *SelectManager

func (*SelectManager) Skip

func (mgr *SelectManager) Skip(i int) *SelectManager

func (*SelectManager) Take

func (mgr *SelectManager) Take(i int) *SelectManager

func (*SelectManager) ToSql

func (mgr *SelectManager) ToSql() string

func (*SelectManager) Union

func (mgr *SelectManager) Union(stmt1 Visitable, stmt2 Visitable) *MultiStatementManager

func (*SelectManager) UnionAll

func (mgr *SelectManager) UnionAll(stmt1 Visitable, stmt2 Visitable) *MultiStatementManager

func (*SelectManager) Using

func (mgr *SelectManager) Using(str string) *SelectManager

func (*SelectManager) Where

func (mgr *SelectManager) Where(visitable Visitable) *SelectManager

func (*SelectManager) Window

func (mgr *SelectManager) Window(node SqlLiteralNode) *NamedWindowNode

func (*SelectManager) With

func (mgr *SelectManager) With(visitable Visitable) *SelectManager

func (*SelectManager) WithRecursive

func (mgr *SelectManager) WithRecursive(visitable Visitable) *SelectManager

type SelectStatementNode

type SelectStatementNode struct {
	Cores  []*SelectCoreNode
	Limit  *LimitNode
	Orders *[]Visitable
	Lock   *LockNode
	With   Visitable // WithNode or WithRecursiveNode
	Offset *OffsetNode
	Visitable
}

func NewSelectStatementNode

func NewSelectStatementNode() *SelectStatementNode

func (*SelectStatementNode) IsEqual

type SqlLiteralNode

type SqlLiteralNode struct {
	Raw string
	BaseVisitable
}

func Sql

func Sql(thing interface{}) SqlLiteralNode

func Star

func Star() SqlLiteralNode

func (SqlLiteralNode) As

func (node SqlLiteralNode) As(literal SqlLiteralNode) *AsNode

func (SqlLiteralNode) Asc

func (node SqlLiteralNode) Asc() *AscendingNode

func (SqlLiteralNode) Count

func (node SqlLiteralNode) Count() *CountNode

func (SqlLiteralNode) Desc

func (node SqlLiteralNode) Desc() *DescendingNode

func (SqlLiteralNode) DoesNotMatch

func (node SqlLiteralNode) DoesNotMatch(literal SqlLiteralNode) *DoesNotMatchNode

func (SqlLiteralNode) DoesNotMatchAll

func (node SqlLiteralNode) DoesNotMatchAll(literals ...SqlLiteralNode) *GroupingNode

func (SqlLiteralNode) DoesNotMatchAny

func (node SqlLiteralNode) DoesNotMatchAny(literals ...SqlLiteralNode) *GroupingNode

func (SqlLiteralNode) Eq

func (node SqlLiteralNode) Eq(visitable Visitable) *EqualityNode

func (SqlLiteralNode) EqAll

func (node SqlLiteralNode) EqAll(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) EqAny

func (node SqlLiteralNode) EqAny(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) Extract

func (node SqlLiteralNode) Extract(literal SqlLiteralNode) *ExtractNode

func (SqlLiteralNode) Gt

func (node SqlLiteralNode) Gt(visitable Visitable) *GreaterThanNode

func (SqlLiteralNode) GtAll

func (node SqlLiteralNode) GtAll(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) GtAny

func (node SqlLiteralNode) GtAny(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) GtEq

func (node SqlLiteralNode) GtEq(visitable Visitable) *GreaterThanOrEqualNode

func (SqlLiteralNode) GtEqAll

func (node SqlLiteralNode) GtEqAll(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) GtEqAny

func (node SqlLiteralNode) GtEqAny(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) In

func (node SqlLiteralNode) In(visitables []Visitable) Visitable

func (SqlLiteralNode) InAll

func (node SqlLiteralNode) InAll(visitableslices ...[]Visitable) Visitable

func (SqlLiteralNode) InAny

func (node SqlLiteralNode) InAny(visitableslices ...[]Visitable) Visitable

func (SqlLiteralNode) Lt

func (node SqlLiteralNode) Lt(visitable Visitable) *LessThanNode

func (SqlLiteralNode) LtAll

func (node SqlLiteralNode) LtAll(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) LtAny

func (node SqlLiteralNode) LtAny(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) LtEq

func (node SqlLiteralNode) LtEq(visitable Visitable) *LessThanOrEqualNode

func (SqlLiteralNode) LtEqAll

func (node SqlLiteralNode) LtEqAll(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) LtEqAny

func (node SqlLiteralNode) LtEqAny(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) Matches

func (node SqlLiteralNode) Matches(literal SqlLiteralNode) *MatchesNode

func (SqlLiteralNode) MatchesAll

func (node SqlLiteralNode) MatchesAll(literals ...SqlLiteralNode) *GroupingNode

func (SqlLiteralNode) MatchesAny

func (node SqlLiteralNode) MatchesAny(literals ...SqlLiteralNode) *GroupingNode

func (SqlLiteralNode) NotEq

func (node SqlLiteralNode) NotEq(visitable Visitable) *NotEqualNode

func (SqlLiteralNode) NotEqAll

func (node SqlLiteralNode) NotEqAll(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) NotEqAny

func (node SqlLiteralNode) NotEqAny(visitables ...Visitable) *GroupingNode

func (SqlLiteralNode) NotIn

func (node SqlLiteralNode) NotIn(visitables []Visitable) Visitable

func (SqlLiteralNode) NotInAll

func (node SqlLiteralNode) NotInAll(visitableslices ...[]Visitable) Visitable

func (SqlLiteralNode) NotInAny

func (node SqlLiteralNode) NotInAny(visitableslices ...[]Visitable) Visitable

func (SqlLiteralNode) String

func (node SqlLiteralNode) String() string

type SumNode

type SumNode FunctionNode

func Sum

func Sum(attr *AttributeNode) *SumNode

type Table

type Table struct {
	Name       string
	Engine     Engine
	TableAlias string
	Aliases    *[]*TableAliasNode
	BaseVisitable
}

func NewTable

func NewTable(name string) *Table

func (*Table) Alias

func (t *Table) Alias() *TableAliasNode

func (*Table) Attr

func (t *Table) Attr(name string) *AttributeNode

func (*Table) From

func (t *Table) From(relation *Table) *SelectManager

func (*Table) Group

func (t *Table) Group(visitables ...Visitable) *SelectManager

func (*Table) Having

func (t *Table) Having(visitables ...Visitable) *SelectManager

func (*Table) InnerJoin

func (t *Table) InnerJoin(visitable Visitable) *SelectManager

func (*Table) InsertManager

func (t *Table) InsertManager() *InsertManager

func (*Table) Join

func (t *Table) Join(visitable Visitable) *SelectManager

func (*Table) Offset

func (t *Table) Offset(i int) *SelectManager

func (*Table) Order

func (t *Table) Order(visitables ...Visitable) *SelectManager

func (*Table) OuterJoin

func (t *Table) OuterJoin(visitable Visitable) *SelectManager

func (*Table) Project

func (t *Table) Project(visitables ...Visitable) *SelectManager

func (*Table) Select

func (t *Table) Select(visitables ...Visitable) *SelectManager

func (*Table) SelectManager

func (t *Table) SelectManager(relation *Table) *SelectManager

func (*Table) SetTableAlias

func (t *Table) SetTableAlias(name string)

func (*Table) Skip

func (t *Table) Skip(i int) *SelectManager

func (*Table) String

func (t *Table) String() string

func (*Table) Take

func (t *Table) Take(i int) *SelectManager

func (*Table) Where

func (t *Table) Where(visitable Visitable) *SelectManager

type TableAliasNode

type TableAliasNode struct {
	Name     string
	Quoted   bool      // Flag to indentify if the alias should be quoted
	Relation Visitable // Generally a *Table, *GroupingNode; a GroupingNode can allow a SelectStatement to be aliased
	BinaryNode
}

func (*TableAliasNode) Attr

func (t *TableAliasNode) Attr(name string) *AttributeNode

func (*TableAliasNode) String

func (t *TableAliasNode) String() string

type ToSqlVisitor

type ToSqlVisitor struct {
	Conn Connector
}

func (*ToSqlVisitor) Accept

func (v *ToSqlVisitor) Accept(visitable Visitable) string

func (ToSqlVisitor) Quote

func (v ToSqlVisitor) Quote(thing interface{}) string

func (ToSqlVisitor) QuoteColumnName

func (v ToSqlVisitor) QuoteColumnName(literal SqlLiteralNode) string

func (ToSqlVisitor) QuoteTableName

func (v ToSqlVisitor) QuoteTableName(visitable Visitable) string

func (*ToSqlVisitor) Visit

func (v *ToSqlVisitor) Visit(visitable Visitable) string

type TopNode

type TopNode UnaryNode

func NewTopNode

func NewTopNode(visitable Visitable) *TopNode

type TreeManager

type TreeManager interface {
	ToSql() string
}

type TrueNode

type TrueNode struct {
	BaseVisitable
}

type UnaryNode

type UnaryNode struct {
	Expr Visitable
	BaseVisitable
}

func NewUnaryNode

func NewUnaryNode(visitable Visitable) *UnaryNode

type UnionAllNode

type UnionAllNode BinaryNode

type UnionNode

type UnionNode BinaryNode

type UnqualifiedColumnNode

type UnqualifiedColumnNode struct {
	Expr *AttributeNode
	BaseVisitable
}

func (*UnqualifiedColumnNode) Name

type UpdateManager

type UpdateManager struct {
	Engine Engine
	Ast    *UpdateStatementNode
	BaseVisitable
}

func NewUpdateManager

func NewUpdateManager(engine Engine) *UpdateManager

func (*UpdateManager) From

func (mgr *UpdateManager) From(relation *Table) *UpdateManager

func (*UpdateManager) Order

func (mgr *UpdateManager) Order(expressions ...Visitable) *UpdateManager

func (*UpdateManager) Set

func (mgr *UpdateManager) Set(field *AttributeNode, value Visitable) *UpdateManager

func (*UpdateManager) SetKey

func (mgr *UpdateManager) SetKey(node *AttributeNode) *UpdateManager

func (*UpdateManager) Table

func (mgr *UpdateManager) Table(relation *Table) *UpdateManager

func (*UpdateManager) Take

func (mgr *UpdateManager) Take(limit int) *UpdateManager

func (*UpdateManager) ToSql

func (mgr *UpdateManager) ToSql() string

func (*UpdateManager) Where

func (mgr *UpdateManager) Where(visitable Visitable) *UpdateManager

type UpdateStatementNode

type UpdateStatementNode struct {
	Relation *Table
	Wheres   *[]Visitable
	Values   *[]Visitable
	Orders   *[]Visitable
	Limit    *LimitNode
	Key      Visitable // SqlLiteralNode AttributeNode
	BaseVisitable
}

func NewUpdateStatementNode

func NewUpdateStatementNode() *UpdateStatementNode

type UsingNode

type UsingNode UnaryNode

type ValuesNode

type ValuesNode struct {
	Values  []interface{}
	Columns []*AttributeNode
	BaseVisitable
}

type Visitable

type Visitable interface {
	NewTrueNode() *TrueNode
	NewFalseNode() *FalseNode
	NewTableAliasNode(*Table, string) *TableAliasNode
	NewInnerJoinNode() *InnerJoinNode
	NewOuterJoinNode() *OuterJoinNode
	NewAndNode(...Visitable) *AndNode
	NewOnNode(Visitable) *OnNode
	NewNotNode() *NotNode
	NewGroupingNode() *GroupingNode
	String() string
}

type Visitor

type Visitor interface {
	Accept(Visitable) string
	QuoteColumnName(SqlLiteralNode) string
	QuoteTableName(Visitable) string
	Quote(interface{}) string
	Visit(Visitable) string
}

type WindowNode

type WindowNode struct {
	Orders  *[]Visitable
	Framing Visitable
	BaseVisitable
}

func (*WindowNode) Order

func (node *WindowNode) Order(v Visitable) *WindowNode

type Windower

type Windower interface {
	Over(Visitable) *OverNode
	Visitable
}

type WithNode

type WithNode UnaryNode

func NewWithNode

func NewWithNode(visitable Visitable) *WithNode

type WithRecursiveNode

type WithRecursiveNode UnaryNode

func NewWithRecursiveNode

func NewWithRecursiveNode(visitable Visitable) *WithRecursiveNode

Jump to

Keyboard shortcuts

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