Skip to content

Commit

Permalink
feat: remove float64 field type
Browse files Browse the repository at this point in the history
  • Loading branch information
tr1v3r committed Apr 10, 2024
1 parent 1f55da1 commit b589b71
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 39 deletions.
18 changes: 8 additions & 10 deletions field/expr.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,20 @@ func (e expr) Length() Number[int] {
return newNumber[int](e.setE(clause.Expr{SQL: "LENGTH(?)", Vars: []interface{}{e.RawExpr()}}))
}

func (e expr) Max() Float64 {
return Float64{newNumber[float64](e.setE(clause.Expr{SQL: "MAX(?)", Vars: []interface{}{e.RawExpr()}}))}
func (e expr) Max() Number[float64] {
return newNumber[float64](e.setE(clause.Expr{SQL: "MAX(?)", Vars: []interface{}{e.RawExpr()}}))
}

func (e expr) Min() Float64 {
return Float64{newNumber[float64](e.setE(clause.Expr{SQL: "MIN(?)", Vars: []interface{}{e.RawExpr()}}))}

func (e expr) Min() Number[float64] {
return newNumber[float64](e.setE(clause.Expr{SQL: "MIN(?)", Vars: []interface{}{e.RawExpr()}}))
}

func (e expr) Avg() Float64 {
return Float64{newNumber[float64](e.setE(clause.Expr{SQL: "AVG(?)", Vars: []interface{}{e.RawExpr()}}))}

func (e expr) Avg() Number[float64] {
return newNumber[float64](e.setE(clause.Expr{SQL: "AVG(?)", Vars: []interface{}{e.RawExpr()}}))
}

func (e expr) Abs() Float64 {
return Float64{newNumber[float64](e.setE(clause.Expr{SQL: "ABS(?)", Vars: []interface{}{e.RawExpr()}}))}
func (e expr) Abs() Number[float64] {
return newNumber[float64](e.setE(clause.Expr{SQL: "ABS(?)", Vars: []interface{}{e.RawExpr()}}))
}

func (e expr) Null() AssignExpr {
Expand Down
17 changes: 0 additions & 17 deletions field/float.go

This file was deleted.

29 changes: 17 additions & 12 deletions field/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,62 +34,67 @@ func (field Number[T]) NotBetween(left T, right T) Expr {

// Add ...
func (field Number[T]) Add(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.add(value)}}
return newNumber[T](field.add(value))
}

// Sub ...
func (field Number[T]) Sub(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.sub(value)}}
return newNumber[T](field.sub(value))
}

// Mul ...
func (field Number[T]) Mul(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.mul(value)}}
return newNumber[T](field.mul(value))
}

// Div ...
func (field Number[T]) Div(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.div(value)}}
return newNumber[T](field.div(value))
}

// Mod ...
func (field Number[T]) Mod(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.mod(value)}}
return newNumber[T](field.mod(value))
}

// FloorDiv ...
func (field Number[T]) FloorDiv(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.floorDiv(value)}}
return newNumber[T](field.floorDiv(value))
}

// RightShift ...
func (field Number[T]) RightShift(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.rightShift(value)}}
return newNumber[T](field.rightShift(value))
}

// LeftShift ...
func (field Number[T]) LeftShift(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.leftShift(value)}}
return newNumber[T](field.leftShift(value))
}

// BitXor ...
func (field Number[T]) BitXor(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.bitXor(value)}}
return newNumber[T](field.bitXor(value))
}

// BitAnd ...
func (field Number[T]) BitAnd(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.bitAnd(value)}}
return newNumber[T](field.bitAnd(value))
}

// BitOr ...
func (field Number[T]) BitOr(value T) Number[T] {
return Number[T]{genericsField: genericsField[T]{field.bitOr(value)}}
return newNumber[T](field.bitOr(value))
}

// BitFlip ...
func (field Number[T]) BitFlip() Number[T] {
return Number[T]{genericsField: genericsField[T]{field.bitFlip()}}
return newNumber[T](field.bitFlip())
}

// Floor ...
func (field Number[T]) Floor() Number[T] {
return newNumber[T](field.floor())
}

// Zero set zero value
Expand Down

0 comments on commit b589b71

Please sign in to comment.