MySQL float expressions.
This commit is contained in:
parent
6bf9c32c07
commit
163ecf4c42
13 changed files with 401 additions and 85 deletions
13
cast.go
13
cast.go
|
|
@ -13,6 +13,8 @@ type cast interface {
|
|||
AS_BIGINT() IntegerExpression
|
||||
// Cast expression AS numeric type, using precision and optionally scale
|
||||
AS_NUMERIC(precision int, scale ...int) FloatExpression
|
||||
// Cast expression AS numeric type, using precision and optionally scale
|
||||
AS_DECIMAL() FloatExpression
|
||||
// Cast expression AS real type
|
||||
AS_REAL() FloatExpression
|
||||
// Cast expression AS double precision type
|
||||
|
|
@ -56,14 +58,14 @@ func (b *castImpl) serialize(statement statementType, out *sqlBuilder, options .
|
|||
return castOverride(b.Expression, b.castType)(statement, out, options...)
|
||||
}
|
||||
|
||||
out.writeString("CAST")
|
||||
err := WRAP(b.Expression).serialize(statement, out, options...)
|
||||
out.writeString("CAST(")
|
||||
err := b.Expression.serialize(statement, out, options...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
out.writeString("AS")
|
||||
out.writeString(b.castType)
|
||||
out.writeString(b.castType + ")")
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
@ -102,6 +104,11 @@ func (b *castImpl) AS_NUMERIC(precision int, scale ...int) FloatExpression {
|
|||
return FloatExp(b)
|
||||
}
|
||||
|
||||
func (b *castImpl) AS_DECIMAL() FloatExpression {
|
||||
b.castType = "decimal"
|
||||
return FloatExp(b)
|
||||
}
|
||||
|
||||
// Cast expression AS real type
|
||||
func (b *castImpl) AS_REAL() FloatExpression {
|
||||
b.castType = "real"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue