mirror of
https://github.com/muety/wakapi.git
synced 2023-08-10 21:12:56 +03:00
fix: invalid search query in Postgres
This commit is contained in:
parent
8de56a4c7b
commit
74390bfccf
@ -2,6 +2,7 @@ package repositories
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/muety/wakapi/config"
|
||||||
"github.com/muety/wakapi/models"
|
"github.com/muety/wakapi/models"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
@ -36,8 +37,12 @@ func (r *KeyValueRepository) GetString(key string) (*models.KeyStringValue, erro
|
|||||||
|
|
||||||
func (r *KeyValueRepository) Search(like string) ([]*models.KeyStringValue, error) {
|
func (r *KeyValueRepository) Search(like string) ([]*models.KeyStringValue, error) {
|
||||||
var keyValues []*models.KeyStringValue
|
var keyValues []*models.KeyStringValue
|
||||||
|
condition := "key like ?"
|
||||||
|
if r.db.Config.Name() == config.SQLDialectMysql {
|
||||||
|
condition = "`key` like ?"
|
||||||
|
}
|
||||||
if err := r.db.Table("key_string_values").
|
if err := r.db.Table("key_string_values").
|
||||||
Where("`key` like ?", like).
|
Where(condition, like).
|
||||||
Find(&keyValues).
|
Find(&keyValues).
|
||||||
Error; err != nil {
|
Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
Reference in New Issue
Block a user