mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-06-21 02:23:12 +08:00
Used Prepared Statements for GetChannel in clickhousereader (#1414)
* feat: used db.Preparex
This commit is contained in:
parent
f8f903848e
commit
e39d2f799d
@ -374,14 +374,21 @@ func (r *ClickHouseReader) GetChannel(id string) (*model.ChannelItem, *model.Api
|
|||||||
idInt, _ := strconv.Atoi(id)
|
idInt, _ := strconv.Atoi(id)
|
||||||
channel := model.ChannelItem{}
|
channel := model.ChannelItem{}
|
||||||
|
|
||||||
query := fmt.Sprintf("SELECT id, created_at, updated_at, name, type, data data FROM notification_channels WHERE id=%d", idInt)
|
query := "SELECT id, created_at, updated_at, name, type, data data FROM notification_channels WHERE id=? "
|
||||||
|
|
||||||
err := r.localDB.Get(&channel, query)
|
stmt, err := r.localDB.Preparex(query)
|
||||||
|
|
||||||
zap.S().Info(query)
|
zap.S().Info(query, idInt)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
zap.S().Debug("Error in processing sql query: ", err)
|
zap.S().Debug("Error in preparing sql query for GetChannel : ", err)
|
||||||
|
return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = stmt.Get(&channel, idInt)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
zap.S().Debug(fmt.Sprintf("Error in getting channel with id=%d : ", idInt), err)
|
||||||
return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}
|
return nil, &model.ApiError{Typ: model.ErrorInternal, Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user