Skip to content

Commit

Permalink
Rollback some of the deleted postgres unsigned integer constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
go-jet committed Nov 3, 2024
1 parent f8f2f75 commit cf0923f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions postgres/literal.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ func Int64(value int64) IntegerExpression {
return CAST(jet.Int(value)).AS_BIGINT()
}

// Uint8 is constructor for 8 bit unsigned integer expressions literals.
func Uint8(value uint8) IntegerExpression {
return CAST(jet.Uint8(value)).AS_SMALLINT()
}

// Uint16 is constructor for 16 bit unsigned integer expressions literals.
func Uint16(value uint16) IntegerExpression {
return CAST(jet.Uint16(value)).AS_INTEGER()
}

// Uint32 is constructor for 32 bit unsigned integer expressions literals.
func Uint32(value uint32) IntegerExpression {
return CAST(jet.Uint32(value)).AS_BIGINT()
}

// Float creates new float literal expression
var Float = jet.Float

Expand Down
15 changes: 15 additions & 0 deletions postgres/literal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ func TestInt64(t *testing.T) {
assertSerialize(t, Int64(val), `$1::bigint`, val)
}

func TestUint8(t *testing.T) {
val := uint8(math.MaxUint8)
assertSerialize(t, Uint8(val), `$1::smallint`, val)
}

func TestUint16(t *testing.T) {
val := uint16(math.MaxUint16)
assertSerialize(t, Uint16(val), `$1::integer`, val)
}

func TestUint32(t *testing.T) {
val := uint32(math.MaxUint32)
assertSerialize(t, Uint32(val), `$1::bigint`, val)
}

func TestFloat(t *testing.T) {
assertSerialize(t, Float(12.34), `$1`, float64(12.34))

Expand Down

0 comments on commit cf0923f

Please sign in to comment.