Add wiki Expressions page.
This commit is contained in:
parent
3516d2861c
commit
6a6ee0561d
17 changed files with 399 additions and 109 deletions
|
|
@ -5,38 +5,58 @@ import (
|
|||
"fmt"
|
||||
)
|
||||
|
||||
// An Expression
|
||||
// Common expression interface
|
||||
type Expression interface {
|
||||
clause
|
||||
projection
|
||||
groupByClause
|
||||
OrderByClause
|
||||
|
||||
// Test expression whether it is a NULL value.
|
||||
IS_NULL() BoolExpression
|
||||
// Test expression whether it is a non-NULL value.
|
||||
IS_NOT_NULL() BoolExpression
|
||||
|
||||
// Check if this expressions matches any in expressions list
|
||||
IN(expressions ...Expression) BoolExpression
|
||||
// Check if this expressions is different of all expressions in expressions list
|
||||
NOT_IN(expressions ...Expression) BoolExpression
|
||||
|
||||
// The temporary alias name to assign to the expression
|
||||
AS(alias string) projection
|
||||
|
||||
// Expression will be used to sort query result in ascending order
|
||||
ASC() OrderByClause
|
||||
// Expression will be used to sort query result in ascending order
|
||||
DESC() OrderByClause
|
||||
|
||||
// casts
|
||||
// Cast expression to dbType
|
||||
TO(dbType string) Expression
|
||||
// Cast expression to bool type
|
||||
TO_BOOL() BoolExpression
|
||||
// Cast expression to smallint type
|
||||
TO_SMALLINT() IntegerExpression
|
||||
// Cast expression to integer type
|
||||
TO_INTEGER() IntegerExpression
|
||||
// Cast expression to bigint type
|
||||
TO_BIGINT() IntegerExpression
|
||||
// Cast expression to numeric type, using precision and optionally scale
|
||||
TO_NUMERIC(precision int, scale ...int) FloatExpression
|
||||
// Cast expression to real type
|
||||
TO_REAL() FloatExpression
|
||||
// Cast expression to double precision type
|
||||
TO_DOUBLE() FloatExpression
|
||||
// Cast expression to text type
|
||||
TO_TEXT() StringExpression
|
||||
// Cast expression to date type
|
||||
TO_DATE() DateExpression
|
||||
// Cast expression to time type
|
||||
TO_TIME() TimeExpression
|
||||
// Cast expression to time with time timezone type
|
||||
TO_TIMEZ() TimezExpression
|
||||
// Cast expression to timestamp type
|
||||
TO_TIMESTAMP() TimestampExpression
|
||||
// Cast expression to timestamp with timezone type
|
||||
TO_TIMESTAMPZ() TimestampzExpression
|
||||
}
|
||||
|
||||
|
|
@ -139,15 +159,15 @@ func (e *expressionInterfaceImpl) TO_TIMESTAMPZ() TimestampzExpression {
|
|||
}
|
||||
|
||||
func (e *expressionInterfaceImpl) serializeForGroupBy(statement statementType, out *queryData) error {
|
||||
return e.parent.serialize(statement, out, NO_WRAP)
|
||||
return e.parent.serialize(statement, out, noWrap)
|
||||
}
|
||||
|
||||
func (e *expressionInterfaceImpl) serializeForProjection(statement statementType, out *queryData) error {
|
||||
return e.parent.serialize(statement, out, NO_WRAP)
|
||||
return e.parent.serialize(statement, out, noWrap)
|
||||
}
|
||||
|
||||
func (e *expressionInterfaceImpl) serializeForOrderBy(statement statementType, out *queryData) error {
|
||||
return e.parent.serialize(statement, out, NO_WRAP)
|
||||
return e.parent.serialize(statement, out, noWrap)
|
||||
}
|
||||
|
||||
// Representation of binary operations (e.g. comparisons, arithmetic)
|
||||
|
|
@ -177,7 +197,7 @@ func (c *binaryOpExpression) serialize(statement statementType, out *queryData,
|
|||
return errors.New("nil rhs")
|
||||
}
|
||||
|
||||
wrap := !contains(options, NO_WRAP)
|
||||
wrap := !contains(options, noWrap)
|
||||
|
||||
if wrap {
|
||||
out.writeString("(")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue