Alerting: Fix kv_store query to escape reserved word (#40788) (#40795)

(cherry picked from commit a5501b7845)

Co-authored-by: Yuriy Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2021-10-22 09:27:19 +02:00
committed by GitHub
co-authored by Yuriy Tseretyan
parent 101a6f2f41
commit c7f488580a
+1 -1
View File
@@ -99,7 +99,7 @@ func (kv *kvStoreSQL) Del(ctx context.Context, orgId int64, namespace string, ke
func (kv *kvStoreSQL) Keys(ctx context.Context, orgId int64, namespace string, keyPrefix string) ([]Key, error) {
var keys []Key
err := kv.sqlStore.WithDbSession(ctx, func(dbSession *sqlstore.DBSession) error {
query := dbSession.Where("namespace = ?", namespace).And("key LIKE ?", keyPrefix+"%")
query := dbSession.Where("namespace = ?", namespace).And("\"key\" LIKE ?", keyPrefix+"%")
if orgId != AllOrganizations {
query.And("org_id = ?", orgId)
}