Skip to content

Commit

Permalink
Merge pull request #325 from realbucksavage/master
Browse files Browse the repository at this point in the history
mysql: added a helper to compare UUID strings with uuid_to_bin
  • Loading branch information
go-jet committed Feb 23, 2024
2 parents 493d3a4 + 33ec120 commit a9cbf94
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mysql/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions mysql/functions_test.go
Original file line number Diff line number Diff line change
@@ -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())
}
3 changes: 2 additions & 1 deletion mysql/literal.go
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit a9cbf94

Please sign in to comment.