Literal and cast clean up.
This commit is contained in:
parent
9a34dc9fd7
commit
614c7e9754
22 changed files with 438 additions and 177 deletions
|
|
@ -1,17 +1,7 @@
|
|||
package jet
|
||||
|
||||
import "strconv"
|
||||
|
||||
type Cast interface {
|
||||
AS(castType string) Expression
|
||||
|
||||
AS_CHAR(lenght ...int) StringExpression
|
||||
// Cast expression AS date type
|
||||
AS_DATE() DateExpression
|
||||
// Cast expression AS numeric type, using precision and optionally scale
|
||||
AS_DECIMAL() FloatExpression
|
||||
// Cast expression AS time type
|
||||
AS_TIME() TimeExpression
|
||||
}
|
||||
|
||||
type CastImpl struct {
|
||||
|
|
@ -37,29 +27,6 @@ func (b *CastImpl) AS(castType string) Expression {
|
|||
return castExp
|
||||
}
|
||||
|
||||
func (b *CastImpl) AS_CHAR(lenght ...int) StringExpression {
|
||||
if len(lenght) > 0 {
|
||||
return StringExp(b.AS("CHAR(" + strconv.Itoa(lenght[0]) + ")"))
|
||||
}
|
||||
|
||||
return StringExp(b.AS("CHAR"))
|
||||
}
|
||||
|
||||
// Cast expression AS date type
|
||||
func (b *CastImpl) AS_DATE() DateExpression {
|
||||
return DateExp(b.AS("DATE"))
|
||||
}
|
||||
|
||||
// Cast expression AS date type
|
||||
func (b *CastImpl) AS_DECIMAL() FloatExpression {
|
||||
return FloatExp(b.AS("DECIMAL"))
|
||||
}
|
||||
|
||||
// Cast expression AS date type
|
||||
func (b *CastImpl) AS_TIME() TimeExpression {
|
||||
return TimeExp(b.AS("TIME"))
|
||||
}
|
||||
|
||||
type castExpression struct {
|
||||
ExpressionInterfaceImpl
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue