Commit f73236f8 by Mario Trangoni

pkg/services/sqlstore: Fix x.Sql is deprecated: use SQL instead. (megacheck)

See,
$ gometalinter --vendor --disable-all --enable=megacheck --disable=gotype --deadline 6m ./... | grep SQL
alert.go:43:9:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
alert_notification.go:122:12:warning: sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
annotation.go:226:12:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:228:9:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:302:10:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:416:9:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
dashboard.go:635:12:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
migrations/user_mig.go:137:9:warning: sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
plugin_setting.go:29:10:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:41:12:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:84:13:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:143:12:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:186:13:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
quota.go:234:12:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
team.go:172:12:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
team.go:199:17:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
team.go:223:9:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
temp_user.go:99:10:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
temp_user.go:124:10:warning: x.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
user.go:375:3:warning: sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
user.go:377:3:warning: sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
user.go:379:3:warning: sess.Sql is deprecated: use SQL instead.  (SA1019) (megacheck)
parent dd0b1d84
...@@ -40,7 +40,7 @@ func GetAlertById(query *m.GetAlertByIdQuery) error { ...@@ -40,7 +40,7 @@ func GetAlertById(query *m.GetAlertByIdQuery) error {
func GetAllAlertQueryHandler(query *m.GetAllAlertsQuery) error { func GetAllAlertQueryHandler(query *m.GetAllAlertsQuery) error {
var alerts []*m.Alert var alerts []*m.Alert
err := x.Sql("select * from alert").Find(&alerts) err := x.SQL("select * from alert").Find(&alerts)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -119,7 +119,7 @@ func getAlertNotificationInternal(query *m.GetAlertNotificationsQuery, sess *DBS ...@@ -119,7 +119,7 @@ func getAlertNotificationInternal(query *m.GetAlertNotificationsQuery, sess *DBS
} }
results := make([]*m.AlertNotification, 0) results := make([]*m.AlertNotification, 0)
if err := sess.Sql(sql.String(), params...).Find(&results); err != nil { if err := sess.SQL(sql.String(), params...).Find(&results); err != nil {
return err return err
} }
......
...@@ -223,7 +223,7 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I ...@@ -223,7 +223,7 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
items := make([]*annotations.ItemDTO, 0) items := make([]*annotations.ItemDTO, 0)
if err := x.Sql(sql.String(), params...).Find(&items); err != nil { if err := x.SQL(sql.String(), params...).Find(&items); err != nil {
return nil, err return nil, err
} }
......
...@@ -225,7 +225,7 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear ...@@ -225,7 +225,7 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear
var res []DashboardSearchProjection var res []DashboardSearchProjection
sql, params := sb.ToSql() sql, params := sb.ToSql()
err := x.Sql(sql, params...).Find(&res) err := x.SQL(sql, params...).Find(&res)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -299,7 +299,7 @@ func GetDashboardTags(query *m.GetDashboardTagsQuery) error { ...@@ -299,7 +299,7 @@ func GetDashboardTags(query *m.GetDashboardTagsQuery) error {
ORDER BY term` ORDER BY term`
query.Result = make([]*m.DashboardTagCloudItem, 0) query.Result = make([]*m.DashboardTagCloudItem, 0)
sess := x.Sql(sql, query.OrgId) sess := x.SQL(sql, query.OrgId)
err := sess.Find(&query.Result) err := sess.Find(&query.Result)
return err return err
} }
...@@ -413,7 +413,7 @@ func GetDashboardPermissionsForUser(query *m.GetDashboardPermissionsForUserQuery ...@@ -413,7 +413,7 @@ func GetDashboardPermissionsForUser(query *m.GetDashboardPermissionsForUserQuery
params = append(params, query.UserId) params = append(params, query.UserId)
params = append(params, dialect.BooleanStr(false)) params = append(params, dialect.BooleanStr(false))
err := x.Sql(sql, params...).Find(&query.Result) err := x.SQL(sql, params...).Find(&query.Result)
for _, p := range query.Result { for _, p := range query.Result {
p.PermissionName = p.Permission.String() p.PermissionName = p.Permission.String()
...@@ -632,7 +632,7 @@ func HasEditPermissionInFolders(query *m.HasEditPermissionInFoldersQuery) error ...@@ -632,7 +632,7 @@ func HasEditPermissionInFolders(query *m.HasEditPermissionInFoldersQuery) error
} }
resp := make([]*folderCount, 0) resp := make([]*folderCount, 0)
if err := x.Sql(builder.GetSqlString(), builder.params...).Find(&resp); err != nil { if err := x.SQL(builder.GetSqlString(), builder.params...).Find(&resp); err != nil {
return err return err
} }
......
...@@ -134,7 +134,7 @@ type TempUserDTO struct { ...@@ -134,7 +134,7 @@ type TempUserDTO struct {
func (m *AddMissingUserSaltAndRandsMigration) Exec(sess *xorm.Session, mg *Migrator) error { func (m *AddMissingUserSaltAndRandsMigration) Exec(sess *xorm.Session, mg *Migrator) error {
users := make([]*TempUserDTO, 0) users := make([]*TempUserDTO, 0)
err := sess.Sql(fmt.Sprintf("SELECT id, login from %s WHERE rands = ''", mg.Dialect.Quote("user"))).Find(&users) err := sess.SQL(fmt.Sprintf("SELECT id, login from %s WHERE rands = ''", mg.Dialect.Quote("user"))).Find(&users)
if err != nil { if err != nil {
return err return err
} }
......
...@@ -26,7 +26,7 @@ func GetPluginSettings(query *m.GetPluginSettingsQuery) error { ...@@ -26,7 +26,7 @@ func GetPluginSettings(query *m.GetPluginSettingsQuery) error {
params = append(params, query.OrgId) params = append(params, query.OrgId)
} }
sess := x.Sql(sql, params...) sess := x.SQL(sql, params...)
query.Result = make([]*m.PluginSettingInfoDTO, 0) query.Result = make([]*m.PluginSettingInfoDTO, 0)
return sess.Find(&query.Result) return sess.Find(&query.Result)
} }
......
...@@ -38,7 +38,7 @@ func GetOrgQuotaByTarget(query *m.GetOrgQuotaByTargetQuery) error { ...@@ -38,7 +38,7 @@ func GetOrgQuotaByTarget(query *m.GetOrgQuotaByTargetQuery) error {
//get quota used. //get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(query.Target)) rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(query.Target))
resp := make([]*targetCount, 0) resp := make([]*targetCount, 0)
if err := x.Sql(rawSql, query.OrgId).Find(&resp); err != nil { if err := x.SQL(rawSql, query.OrgId).Find(&resp); err != nil {
return err return err
} }
...@@ -81,7 +81,7 @@ func GetOrgQuotas(query *m.GetOrgQuotasQuery) error { ...@@ -81,7 +81,7 @@ func GetOrgQuotas(query *m.GetOrgQuotasQuery) error {
//get quota used. //get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(q.Target)) rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(q.Target))
resp := make([]*targetCount, 0) resp := make([]*targetCount, 0)
if err := x.Sql(rawSql, q.OrgId).Find(&resp); err != nil { if err := x.SQL(rawSql, q.OrgId).Find(&resp); err != nil {
return err return err
} }
result[i] = &m.OrgQuotaDTO{ result[i] = &m.OrgQuotaDTO{
...@@ -140,7 +140,7 @@ func GetUserQuotaByTarget(query *m.GetUserQuotaByTargetQuery) error { ...@@ -140,7 +140,7 @@ func GetUserQuotaByTarget(query *m.GetUserQuotaByTargetQuery) error {
//get quota used. //get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(query.Target)) rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(query.Target))
resp := make([]*targetCount, 0) resp := make([]*targetCount, 0)
if err := x.Sql(rawSql, query.UserId).Find(&resp); err != nil { if err := x.SQL(rawSql, query.UserId).Find(&resp); err != nil {
return err return err
} }
...@@ -183,7 +183,7 @@ func GetUserQuotas(query *m.GetUserQuotasQuery) error { ...@@ -183,7 +183,7 @@ func GetUserQuotas(query *m.GetUserQuotasQuery) error {
//get quota used. //get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(q.Target)) rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(q.Target))
resp := make([]*targetCount, 0) resp := make([]*targetCount, 0)
if err := x.Sql(rawSql, q.UserId).Find(&resp); err != nil { if err := x.SQL(rawSql, q.UserId).Find(&resp); err != nil {
return err return err
} }
result[i] = &m.UserQuotaDTO{ result[i] = &m.UserQuotaDTO{
...@@ -231,7 +231,7 @@ func GetGlobalQuotaByTarget(query *m.GetGlobalQuotaByTargetQuery) error { ...@@ -231,7 +231,7 @@ func GetGlobalQuotaByTarget(query *m.GetGlobalQuotaByTargetQuery) error {
//get quota used. //get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s", dialect.Quote(query.Target)) rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s", dialect.Quote(query.Target))
resp := make([]*targetCount, 0) resp := make([]*targetCount, 0)
if err := x.Sql(rawSql).Find(&resp); err != nil { if err := x.SQL(rawSql).Find(&resp); err != nil {
return err return err
} }
......
...@@ -169,7 +169,7 @@ func SearchTeams(query *m.SearchTeamsQuery) error { ...@@ -169,7 +169,7 @@ func SearchTeams(query *m.SearchTeamsQuery) error {
sql.WriteString(dialect.LimitOffset(int64(query.Limit), int64(offset))) sql.WriteString(dialect.LimitOffset(int64(query.Limit), int64(offset)))
} }
if err := x.Sql(sql.String(), params...).Find(&query.Result.Teams); err != nil { if err := x.SQL(sql.String(), params...).Find(&query.Result.Teams); err != nil {
return err return err
} }
...@@ -196,7 +196,7 @@ func GetTeamById(query *m.GetTeamByIdQuery) error { ...@@ -196,7 +196,7 @@ func GetTeamById(query *m.GetTeamByIdQuery) error {
sql.WriteString(` WHERE team.org_id = ? and team.id = ?`) sql.WriteString(` WHERE team.org_id = ? and team.id = ?`)
var team m.TeamDTO var team m.TeamDTO
exists, err := x.Sql(sql.String(), query.OrgId, query.Id).Get(&team) exists, err := x.SQL(sql.String(), query.OrgId, query.Id).Get(&team)
if err != nil { if err != nil {
return err return err
...@@ -220,7 +220,7 @@ func GetTeamsByUser(query *m.GetTeamsByUserQuery) error { ...@@ -220,7 +220,7 @@ func GetTeamsByUser(query *m.GetTeamsByUserQuery) error {
sql.WriteString(` INNER JOIN team_member on team.id = team_member.team_id`) sql.WriteString(` INNER JOIN team_member on team.id = team_member.team_id`)
sql.WriteString(` WHERE team.org_id = ? and team_member.user_id = ?`) sql.WriteString(` WHERE team.org_id = ? and team_member.user_id = ?`)
err := x.Sql(sql.String(), query.OrgId, query.UserId).Find(&query.Result) err := x.SQL(sql.String(), query.OrgId, query.UserId).Find(&query.Result)
return err return err
} }
......
...@@ -96,7 +96,7 @@ func GetTempUsersQuery(query *m.GetTempUsersQuery) error { ...@@ -96,7 +96,7 @@ func GetTempUsersQuery(query *m.GetTempUsersQuery) error {
rawSql += " ORDER BY tu.created desc" rawSql += " ORDER BY tu.created desc"
query.Result = make([]*m.TempUserDTO, 0) query.Result = make([]*m.TempUserDTO, 0)
sess := x.Sql(rawSql, params...) sess := x.SQL(rawSql, params...)
err := sess.Find(&query.Result) err := sess.Find(&query.Result)
return err return err
} }
...@@ -121,7 +121,7 @@ func GetTempUserByCode(query *m.GetTempUserByCodeQuery) error { ...@@ -121,7 +121,7 @@ func GetTempUserByCode(query *m.GetTempUserByCodeQuery) error {
WHERE tu.code=?` WHERE tu.code=?`
var tempUser m.TempUserDTO var tempUser m.TempUserDTO
sess := x.Sql(rawSql, query.Code) sess := x.SQL(rawSql, query.Code)
has, err := sess.Get(&tempUser) has, err := sess.Get(&tempUser)
if err != nil { if err != nil {
......
...@@ -372,11 +372,11 @@ func GetSignedInUser(query *m.GetSignedInUserQuery) error { ...@@ -372,11 +372,11 @@ func GetSignedInUser(query *m.GetSignedInUserQuery) error {
sess := x.Table("user") sess := x.Table("user")
if query.UserId > 0 { if query.UserId > 0 {
sess.Sql(rawSql+"WHERE u.id=?", query.UserId) sess.SQL(rawSql+"WHERE u.id=?", query.UserId)
} else if query.Login != "" { } else if query.Login != "" {
sess.Sql(rawSql+"WHERE u.login=?", query.Login) sess.SQL(rawSql+"WHERE u.login=?", query.Login)
} else if query.Email != "" { } else if query.Email != "" {
sess.Sql(rawSql+"WHERE u.email=?", query.Email) sess.SQL(rawSql+"WHERE u.email=?", query.Email)
} }
var user m.SignedInUser var user m.SignedInUser
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment