refactor(ksuid): replace BinExpr with top-level expr helpers

Adds StringKSUIDExpr and BinaryKSUIDExpr for use with ExprValues, plus
Expr() methods on both types. Removes ExprStringKSUIDs and BinExpr.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 18:47:18 -07:00
parent eafe84ef31
commit a712ccc38f
8 changed files with 75 additions and 35 deletions
+5 -9
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"io"
"github.com/go-jet/jet/v2/mysql"
"github.com/segmentio/ksuid"
)
@@ -44,19 +43,16 @@ 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}
}
// Expr returns a Jet expression for this BinaryKSUID. See [BinaryKSUIDExpr].
func (b BinaryKSUID) Expr() Expression {
return BinaryKSUIDExpr(b)
}
// Scan implements sql.Scanner for binary-backed KSUID columns.
func (b *BinaryKSUID) Scan(src any) error {
switch v := src.(type) {