Documentation
¶
Index ¶
- Constants
- type And
- type Column
- type ColumnValue
- type ColumnValues
- type Columns
- type Database
- type Fragment
- type GroupBy
- type Join
- type Joins
- type Limit
- type Offset
- type On
- type Or
- type Order
- type OrderBy
- type Raw
- type Returning
- type SortColumn
- type SortColumns
- type Statement
- type Table
- type Template
- type Type
- type Using
- type Value
- type ValueGroups
- type Values
- type Where
Constants ¶
const ( FragmentType_None uint64 = iota + 713910251627 FragmentType_And FragmentType_Column FragmentType_ColumnValue FragmentType_ColumnValues FragmentType_Columns FragmentType_Database FragmentType_GroupBy FragmentType_Join FragmentType_Joins FragmentType_Nil FragmentType_Or FragmentType_Limit FragmentType_Offset FragmentType_OrderBy FragmentType_Order FragmentType_Raw FragmentType_Returning FragmentType_SortBy FragmentType_SortColumn FragmentType_SortColumns FragmentType_Statement FragmentType_StatementType FragmentType_Table FragmentType_Value FragmentType_On FragmentType_Using FragmentType_ValueGroups FragmentType_Values FragmentType_Where )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type And ¶
type And Where
And represents an SQL AND operator.
func JoinWithAnd ¶
JoinWithAnd creates and returns a new And.
type Column ¶
type Column struct {
Name interface{}
}
Column represents a SQL column.
func ColumnWithName ¶
ColumnWithName creates and returns a Column with the given name.
type ColumnValue ¶
ColumnValue represents a bundle between a column and a corresponding value.
func (*ColumnValue) Compile ¶
func (c *ColumnValue) Compile(layout *Template) (compiled string, err error)
Compile transforms the ColumnValue into an equivalent SQL representation.
func (*ColumnValue) Hash ¶
func (c *ColumnValue) Hash() uint64
Hash returns a unique identifier for the struct.
type ColumnValues ¶
type ColumnValues struct {
ColumnValues []Fragment
}
ColumnValues represents an array of ColumnValue
func JoinColumnValues ¶
func JoinColumnValues(values ...Fragment) *ColumnValues
JoinColumnValues returns an array of ColumnValue
func (*ColumnValues) Compile ¶
func (c *ColumnValues) Compile(layout *Template) (compiled string, err error)
Compile transforms the ColumnValues into its SQL representation.
func (*ColumnValues) Hash ¶
func (c *ColumnValues) Hash() uint64
Hash returns a unique identifier for the struct.
func (*ColumnValues) Insert ¶
func (c *ColumnValues) Insert(values ...Fragment) *ColumnValues
Insert adds a column to the columns array.
type Columns ¶
type Columns struct {
Columns []Fragment
}
Columns represents an array of Column.
func JoinColumns ¶
JoinColumns creates and returns an array of Column.
type Database ¶
type Database struct {
Name string
}
Database represents a SQL database.
func DatabaseWithName ¶
DatabaseWithName returns a Database with the given name.
type GroupBy ¶
type GroupBy struct {
Columns Fragment
}
GroupBy represents a SQL's "group by" statement.
func GroupByColumns ¶
GroupByColumns creates and returns a GroupBy with the given column.
type Join ¶
Join represents a generic JOIN statement.
type Joins ¶
type Joins struct {
Conditions []Fragment
}
Joins represents the union of different join conditions.
func JoinConditions ¶
JoinConditions creates a Joins object.
type On ¶
type On Where
On represents JOIN conditions.
func OnConditions ¶
OnConditions creates and retuens a new On.
type Or ¶
type Or Where
Or represents an SQL OR operator.
func JoinWithOr ¶
JoinWithOr creates and returns a new Or.
type Order ¶
type Order uint8
Order represents the order in which SQL results are sorted.
type OrderBy ¶
type OrderBy struct {
SortColumns Fragment
}
OrderBy represents an ORDER BY clause.
func JoinWithOrderBy ¶
func JoinWithOrderBy(sc *SortColumns) *OrderBy
JoinWithOrderBy creates an returns an OrderBy using the given SortColumns.
type Raw ¶
type Raw struct {
Value string
}
Raw represents a value that is meant to be used in a query without escaping.
func NewRawValue ¶ added in v4.6.0
type Returning ¶
type Returning struct {
*Columns
}
Returning represents a RETURNING clause.
func ReturningColumns ¶
ReturningColumns creates and returns an array of Column.
type SortColumn ¶
SortColumn represents the column-order relation in an ORDER BY clause.
func (*SortColumn) Compile ¶
func (s *SortColumn) Compile(layout *Template) (compiled string, err error)
Compile transforms the SortColumn into an equivalent SQL representation.
func (*SortColumn) Hash ¶
func (s *SortColumn) Hash() uint64
Hash returns a unique identifier for the struct.
type SortColumns ¶
type SortColumns struct {
Columns []Fragment
}
SortColumns represents the columns in an ORDER BY clause.
func JoinSortColumns ¶
func JoinSortColumns(values ...Fragment) *SortColumns
JoinSortColumns creates and returns an array of column-order relations.
func (*SortColumns) Compile ¶
func (s *SortColumns) Compile(layout *Template) (compiled string, err error)
Compile transforms the SortColumns into an equivalent SQL representation.
func (*SortColumns) Hash ¶
func (s *SortColumns) Hash() uint64
Hash returns a unique identifier for the struct.
type Statement ¶
type Statement struct {
Type
Table Fragment
Database Fragment
Columns Fragment
Values Fragment
Distinct bool
ColumnValues Fragment
OrderBy Fragment
GroupBy Fragment
Joins Fragment
Where Fragment
Returning Fragment
Limit
Offset
SQL string
// contains filtered or unexported fields
}
represents different kinds of SQL statements.
func (*Statement) SetAmendment ¶
type Table ¶
type Table struct {
Name interface{}
}
Table struct represents a SQL table.
func TableWithName ¶
TableWithName creates an returns a Table with the given name.
type Template ¶
type Template struct {
AndKeyword string
AscKeyword string
AssignmentOperator string
ClauseGroup string
ClauseOperator string
ColumnAliasLayout string
ColumnSeparator string
ColumnValue string
CountLayout string
DeleteLayout string
DescKeyword string
DropDatabaseLayout string
DropTableLayout string
GroupByLayout string
IdentifierQuote string
IdentifierSeparator string
InsertLayout string
JoinLayout string
OnLayout string
OrKeyword string
OrderByLayout string
SelectLayout string
SortByColumnLayout string
TableAliasLayout string
TruncateLayout string
UpdateLayout string
UsingLayout string
ValueQuote string
ValueSeparator string
WhereLayout string
ComparisonOperator map[adapter.ComparisonOperator]string
*cache.Cache
// contains filtered or unexported fields
}
Template is an SQL template.
func (*Template) MustCompile ¶
type Type ¶
type Type uint8
Type is the type of SQL query the statement represents.
Values for Type.
type Using ¶
type Using Columns
Using represents a USING function.
func UsingColumns ¶
UsingColumns builds a Using from the given columns.
type Value ¶
type Value struct {
V interface{}
}
Value represents an escaped SQL value.
type ValueGroups ¶
type ValueGroups struct {
Values []*Values
}
ValueGroups represents an array of value groups.
func JoinValueGroups ¶
func JoinValueGroups(values ...*Values) *ValueGroups
JoinValueGroups creates a new *ValueGroups object.
func (*ValueGroups) Compile ¶
func (vg *ValueGroups) Compile(layout *Template) (compiled string, err error)
Compile transforms the ValueGroups into an equivalent SQL representation.
func (*ValueGroups) Hash ¶
func (vg *ValueGroups) Hash() uint64
Hash returns a unique identifier for the struct.
func (*ValueGroups) IsEmpty ¶
func (vg *ValueGroups) IsEmpty() bool
type Values ¶
type Values struct {
Values []Fragment
}
Values represents an array of Value.
func NewValueGroup ¶
NewValueGroup creates and returns an array of values.
type Where ¶
type Where struct {
Conditions []Fragment
}
Where represents an SQL WHERE clause.
func WhereConditions ¶
WhereConditions creates and retuens a new Where.