Merge pull request #325 from realbucksavage/master

mysql: added a helper to compare UUID strings with uuid_to_bin
This commit is contained in:
go-jet 2024-02-23 17:27:00 +01:00 committed by GitHub
commit a9cbf94d68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 1 deletions

View file

@ -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
View 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())
}

View file

@ -1,8 +1,9 @@
package mysql
import (
"github.com/go-jet/jet/v2/internal/jet"
"time"
"github.com/go-jet/jet/v2/internal/jet"
)
// Keywords