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 ( DefaultOrder = Order(iota) Ascendent Descendent )
Possible values for Order
const ( NoOp = Type(iota) Truncate DropTable DropDatabase Count Insert Select Update Delete SQL )
Values for Type.
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{}
Alias string
// contains filtered or unexported fields
}
Column represents a SQL column.
func ColumnWithName ¶
ColumnWithName creates and returns a Column with the given name.
type ColumnValue ¶
type ColumnValue struct {
Column Fragment
Operator string
Value Fragment
// contains filtered or unexported fields
}
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() string
Hash returns a unique identifier for the struct.
type ColumnValues ¶
type ColumnValues struct {
ColumnValues []Fragment
// contains filtered or unexported fields
}
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() string
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
// contains filtered or unexported fields
}
Columns represents an array of Column.
func JoinColumns ¶
JoinColumns creates and returns an array of Column.
type Database ¶
type Database struct {
Name string
// contains filtered or unexported fields
}
Database represents a SQL database.
func DatabaseWithName ¶
DatabaseWithName returns a Database with the given name.
type GroupBy ¶
type GroupBy struct {
Columns Fragment
// contains filtered or unexported fields
}
GroupBy represents a SQL's "group by" statement.
func GroupByColumns ¶
GroupByColumns creates and returns a GroupBy with the given column.
type Join ¶
type Join struct {
Type string
Table Fragment
On Fragment
Using Fragment
// contains filtered or unexported fields
}
Join represents a generic JOIN statement.
type Joins ¶
type Joins struct {
Conditions []Fragment
// contains filtered or unexported fields
}
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
// contains filtered or unexported fields
}
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 // Value should not be modified after assigned.
// contains filtered or unexported fields
}
Raw represents a value that is meant to be used in a query without escaping.
type Returning ¶
type Returning struct {
*Columns
// contains filtered or unexported fields
}
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() string
Hash returns a unique identifier for the struct.
type SortColumns ¶
type SortColumns struct {
Columns []Fragment
// contains filtered or unexported fields
}
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() string
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{}
// contains filtered or unexported fields
}
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 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{}
// contains filtered or unexported fields
}
Value represents an escaped SQL value.
type ValueGroups ¶
type ValueGroups struct {
Values []*Values
// contains filtered or unexported fields
}
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() string
Hash returns a unique identifier for the struct.
func (*ValueGroups) IsEmpty ¶
func (vg *ValueGroups) IsEmpty() bool
type Values ¶
type Values struct {
Values []Fragment
// contains filtered or unexported fields
}
Values represents an array of Value.
func NewValueGroup ¶
NewValueGroup creates and returns an array of values.
type Where ¶
type Where struct {
Conditions []Fragment
// contains filtered or unexported fields
}
Where represents an SQL WHERE clause.
func WhereConditions ¶
WhereConditions creates and retuens a new Where.