8053aafa6f
Replace mysql/postgres intersection interfaces with mysql type aliases per go-jet/jet#555 and generalize Apply/Expr signatures. Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
711 B
Go
27 lines
711 B
Go
package dbx
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/go-jet/jet/v2/mysql"
|
|
)
|
|
|
|
// ExprValues converts a list of values to a list of Expression values using
|
|
// function f to transform the values (mysql.String for strings, mysql.Uint64, etc).
|
|
func ExprValues[T any](values []T, f func(T) Expression) []Expression {
|
|
expressions := make([]Expression, len(values))
|
|
for i, v := range values {
|
|
expressions[i] = f(v)
|
|
}
|
|
return expressions
|
|
}
|
|
|
|
// ExprStringers converts a list of fmt.Stringers to a list of Expression values.
|
|
func ExprStringers(values []fmt.Stringer) []Expression {
|
|
expressions := make([]Expression, len(values))
|
|
for i, v := range values {
|
|
expressions[i] = mysql.String(v.String())
|
|
}
|
|
return expressions
|
|
}
|