services/user: Fix userimpl tests when running on Spanner. (#103715)

Fix userimpl tests when running on Spanner.
This commit is contained in:
Peter Štibraný
2025-04-11 10:28:21 +02:00
committed by GitHub
parent 4648ba396b
commit 54b8dde1e1
4 changed files with 47 additions and 31 deletions
+14
View File
@@ -27,7 +27,10 @@ type Dialect interface {
ShowCreateNull() bool
SQLType(col *Column) string
SupportEngine() bool
// Deprecated. This doesn't work correctly for all databases.
LikeStr() string
// LikeOperator returns SQL snippet and query parameter for case-insensitive LIKE operation, with optional wildcards (%) before/after the pattern.
LikeOperator(column string, wildcardBefore bool, pattern string, wildcardAfter bool) (string, string)
Default(col *Column) string
// BooleanValue can be used as an argument in SELECT or INSERT statements. For constructing
// raw SQL queries, please use BooleanStr instead.
@@ -153,6 +156,17 @@ func (b *BaseDialect) LikeStr() string {
return "LIKE"
}
func (b *BaseDialect) LikeOperator(column string, wildcardBefore bool, pattern string, wildcardAfter bool) (string, string) {
param := pattern
if wildcardBefore {
param = "%" + param
}
if wildcardAfter {
param = param + "%"
}
return fmt.Sprintf("%s LIKE ?", column), param
}
func (b *BaseDialect) OrStr() string {
return "OR"
}