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:
+13
-6
@@ -25,11 +25,18 @@ func ExprStringers(values []fmt.Stringer) []Expression {
|
||||
return expressions
|
||||
}
|
||||
|
||||
// ExprStringKSUIDs converts StringKSUID pointers to Jet string expressions.
|
||||
func ExprStringKSUIDs(ids []*StringKSUID) []Expression {
|
||||
expressions := make([]Expression, len(ids))
|
||||
for i, id := range ids {
|
||||
expressions[i] = mysql.String(id.String())
|
||||
// StringKSUIDExpr returns a Jet expression for a string-encoded KSUID column.
|
||||
func StringKSUIDExpr(id StringKSUID) Expression {
|
||||
if id.IsNil() {
|
||||
return mysql.StringExp(mysql.NULL)
|
||||
}
|
||||
return expressions
|
||||
return mysql.String(id.String())
|
||||
}
|
||||
|
||||
// BinaryKSUIDExpr returns a Jet expression for a binary-encoded KSUID column.
|
||||
func BinaryKSUIDExpr(id BinaryKSUID) Expression {
|
||||
if id.IsNil() {
|
||||
return mysql.StringExp(mysql.NULL)
|
||||
}
|
||||
return mysql.String(string(id.Bytes()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user