feat(ksuid): add BinExpr, flexible parsers, and expression helpers
Adds ParseStringKSUIDAny, ParseBinaryKSUIDAny, BinaryKSUID.BinExpr, and ExprStringKSUIDs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/go-jet/jet/v2/mysql"
|
||||
"github.com/segmentio/ksuid"
|
||||
)
|
||||
|
||||
@@ -43,6 +44,14 @@ func ParseBinaryKSUID(b []byte) (BinaryKSUID, error) {
|
||||
return BinaryKSUID{KSUID: id}, nil
|
||||
}
|
||||
|
||||
// BinExpr returns a Jet string expression for binary-encoded IN clauses.
|
||||
func (b BinaryKSUID) BinExpr() mysql.StringExpression {
|
||||
if b.IsNil() {
|
||||
return mysql.StringExp(mysql.NULL)
|
||||
}
|
||||
return mysql.String(string(b.Bytes()))
|
||||
}
|
||||
|
||||
// AsStringKSUID returns a StringKSUID view of the same identifier.
|
||||
func (b BinaryKSUID) AsStringKSUID() StringKSUID {
|
||||
return StringKSUID{KSUID: b.KSUID}
|
||||
|
||||
Reference in New Issue
Block a user