replaced the UUIDToBin functions with a singular UUID_TO_BIN
This commit is contained in:
parent
09fe45b09c
commit
33ec120437
4 changed files with 17 additions and 22 deletions
|
|
@ -222,6 +222,12 @@ var SUBSTR = jet.SUBSTR
|
|||
// REGEXP_LIKE Returns 1 if the string expr matches the regular expression specified by the pattern pat, 0 otherwise.
|
||||
var REGEXP_LIKE = jet.REGEXP_LIKE
|
||||
|
||||
// UUID_TO_BIN is a helper function that calls "uuid_to_bin" function on the passed value.
|
||||
func UUID_TO_BIN(str StringExpression) StringExpression {
|
||||
fn := Func("uuid_to_bin", str)
|
||||
return StringExp(fn)
|
||||
}
|
||||
|
||||
//----------------- Date/Time Functions and Operators ------------//
|
||||
|
||||
// EXTRACT function retrieves subfields such as year or hour from date/time values
|
||||
|
|
|
|||
11
mysql/functions_test.go
Normal file
11
mysql/functions_test.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestUUIDToBin(t *testing.T) {
|
||||
assertSerialize(t, UUID_TO_BIN(String(uuid.Nil.String())), `uuid_to_bin(?)`, uuid.Nil.String())
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package mysql
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/go-jet/jet/v2/internal/jet"
|
||||
|
|
@ -57,17 +56,6 @@ var String = jet.String
|
|||
// value can be any uuid type with a String method
|
||||
var UUID = jet.UUID
|
||||
|
||||
// UUIDToBin takes ay object with a String method and calls StringUUIDToBin.
|
||||
func UUIDToBin(str fmt.Stringer) StringExpression {
|
||||
return StringUUIDToBin(str.String())
|
||||
}
|
||||
|
||||
// StringUUIDToBin is a helper function that calls "uuid_to_bin" function on the passed value.
|
||||
func StringUUIDToBin(str string) StringExpression {
|
||||
fn := Func("uuid_to_bin", String(str))
|
||||
return StringExp(fn)
|
||||
}
|
||||
|
||||
// Date creates new date literal
|
||||
func Date(year int, month time.Month, day int) DateExpression {
|
||||
return CAST(jet.Date(year, month, day)).AS_DATE()
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@ import (
|
|||
"math"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
func TestBool(t *testing.T) {
|
||||
|
|
@ -83,11 +81,3 @@ func TestTimestamp(t *testing.T) {
|
|||
assertSerialize(t, Timestamp(2010, time.March, 30, 10, 15, 30), `TIMESTAMP(?)`, "2010-03-30 10:15:30")
|
||||
assertSerialize(t, TimestampT(time.Now()), `TIMESTAMP(?)`)
|
||||
}
|
||||
|
||||
func TestUUIDToBin(t *testing.T) {
|
||||
assertSerialize(t, UUIDToBin(uuid.Nil), `uuid_to_bin(?)`, uuid.Nil.String())
|
||||
}
|
||||
|
||||
func TestStringUUIDToBin(t *testing.T) {
|
||||
assertSerialize(t, StringUUIDToBin(uuid.Nil.String()), `uuid_to_bin(?)`, uuid.Nil.String())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue