Plugins: Fix problematic query (#46777)

Fixes mysql error "sql: expected 0 arguments, got 1" introduced via #46283
This commit is contained in:
Marcus Efraimsson 2022-03-21 15:42:05 +01:00 committed by GitHub
parent 912018ff64
commit 1044585b50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,21 +8,24 @@ import (
)
func (ss *SQLStore) GetPluginSettings(ctx context.Context, orgID int64) ([]*models.PluginSetting, error) {
var rslt = make([]*models.PluginSetting, 0)
sql := `SELECT org_id, plugin_id, enabled, pinned, plugin_version
FROM plugin_setting `
params := make([]interface{}, 0)
if orgID != 0 {
sql += "WHERE org_id=?"
params = append(params, orgID)
}
var rslt []*models.PluginSetting
err := ss.WithDbSession(ctx, func(sess *DBSession) error {
if orgID != 0 {
sess.Where("org_id", orgID)
}
err := sess.Find(&rslt)
if err != nil {
return err
}
return nil
return sess.SQL(sql, params...).Find(&rslt)
})
if err != nil {
return nil, err
}
return rslt, err
return rslt, nil
}
func (ss *SQLStore) GetPluginSettingById(ctx context.Context, query *models.GetPluginSettingByIdQuery) error {