Add DECIMAL constructor for Float literal.

DECIMAL constructor is used to pass a decimal number to the SQL query without precision loss.
This commit is contained in:
go-jet 2021-05-09 16:25:54 +02:00
parent 08cc316101
commit 92d02fef78
3 changed files with 18 additions and 2 deletions

View file

@ -140,7 +140,7 @@ type floatLiteral struct {
literalExpressionImpl
}
// Float creates new float literal
// Float creates new float literal from float64 value
func Float(value float64) FloatExpression {
floatLiteral := floatLiteral{}
floatLiteral.literalExpressionImpl = *literal(value)
@ -150,6 +150,16 @@ func Float(value float64) FloatExpression {
return &floatLiteral
}
// Decimal creates new float literal from string value
func Decimal(value string) FloatExpression {
floatLiteral := floatLiteral{}
floatLiteral.literalExpressionImpl = *literal(value)
floatLiteral.floatInterfaceImpl.parent = &floatLiteral
return &floatLiteral
}
//---------------------------------------------------//
type stringLiteral struct {
stringInterfaceImpl