mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 17:57:33 +00:00
* fix(query): escape like wildcards * test: search query wildcards * add do nothing
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/zitadel/logging"
|
||||
@@ -84,6 +85,7 @@ func (db *DB) QueryRowContext(ctx context.Context, scan func(row *sql.Row) error
|
||||
}()
|
||||
|
||||
row := tx.QueryRowContext(ctx, query, args...)
|
||||
logging.OnError(row.Err()).Error("unexpected query error")
|
||||
|
||||
err = scan(row)
|
||||
if err != nil {
|
||||
@@ -170,3 +172,9 @@ func (c Config) Password() string {
|
||||
func (c Config) Type() string {
|
||||
return c.connector.Type()
|
||||
}
|
||||
|
||||
func EscapeLikeWildcards(value string) string {
|
||||
value = strings.ReplaceAll(value, "%", "\\%")
|
||||
value = strings.ReplaceAll(value, "_", "\\_")
|
||||
return value
|
||||
}
|
||||
|
Reference in New Issue
Block a user