refactor with improved developer ux in mind
- Most functions now live directly in the dbx package - dbxp and dbxm are now ONLY the few functions that cannot be shared
This commit is contained in:
16
utility.go
16
utility.go
@@ -1,9 +1,25 @@
|
||||
package dbx
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/go-jet/jet/v2/mysql"
|
||||
)
|
||||
|
||||
// StringToFilter processes a string to be used as a filter in an SQL LIKE
|
||||
// statement. It replaces all spaces with % and adds % to the beginning and
|
||||
// end of the string.
|
||||
func StringToFilter(str string) string {
|
||||
// Remove any existing leading or trailing % characters
|
||||
str = strings.Trim(str, "%")
|
||||
|
||||
// Replace all spaces with % and add % to the beginning and end of the string
|
||||
str = strings.ReplaceAll(str, " ", "%")
|
||||
str = "%" + str + "%"
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
// ExprID converts a list of uint64 values to a list of mysql.Expression values
|
||||
func ExprID(ids []uint64) []mysql.Expression {
|
||||
expressions := make([]mysql.Expression, len(ids))
|
||||
|
||||
Reference in New Issue
Block a user