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 {
func GetAllAlertQueryHandler(query *m.GetAllAlertsQuery) error {
var alerts []*m.Alert
err := x.Sql("select * from alert").Find(&alerts)
err := x.SQL("select * from alert").Find(&alerts)
if err != nil {
return err
}
......
......@@ -119,7 +119,7 @@ func getAlertNotificationInternal(query *m.GetAlertNotificationsQuery, sess *DBS
}
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
}
......
......@@ -223,7 +223,7 @@ func (r *SqlAnnotationRepo) Find(query *annotations.ItemQuery) ([]*annotations.I
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
}
......
......@@ -225,7 +225,7 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear
var res []DashboardSearchProjection
sql, params := sb.ToSql()
err := x.Sql(sql, params...).Find(&res)
err := x.SQL(sql, params...).Find(&res)
if err != nil {
return nil, err
}
......@@ -299,7 +299,7 @@ func GetDashboardTags(query *m.GetDashboardTagsQuery) error {
ORDER BY term`
query.Result = make([]*m.DashboardTagCloudItem, 0)
sess := x.Sql(sql, query.OrgId)
sess := x.SQL(sql, query.OrgId)
err := sess.Find(&query.Result)
return err
}
......@@ -413,7 +413,7 @@ func GetDashboardPermissionsForUser(query *m.GetDashboardPermissionsForUserQuery
params = append(params, query.UserId)
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 {
p.PermissionName = p.Permission.String()
......@@ -632,7 +632,7 @@ func HasEditPermissionInFolders(query *m.HasEditPermissionInFoldersQuery) error
}
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
}
......
......@@ -134,7 +134,7 @@ type TempUserDTO struct {
func (m *AddMissingUserSaltAndRandsMigration) Exec(sess *xorm.Session, mg *Migrator) error {
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 {
return err
}
......
......@@ -26,7 +26,7 @@ func GetPluginSettings(query *m.GetPluginSettingsQuery) error {
params = append(params, query.OrgId)
}
sess := x.Sql(sql, params...)
sess := x.SQL(sql, params...)
query.Result = make([]*m.PluginSettingInfoDTO, 0)
return sess.Find(&query.Result)
}
......
......@@ -38,7 +38,7 @@ func GetOrgQuotaByTarget(query *m.GetOrgQuotaByTargetQuery) error {
//get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(query.Target))
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
}
......@@ -81,7 +81,7 @@ func GetOrgQuotas(query *m.GetOrgQuotasQuery) error {
//get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where org_id=?", dialect.Quote(q.Target))
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
}
result[i] = &m.OrgQuotaDTO{
......@@ -140,7 +140,7 @@ func GetUserQuotaByTarget(query *m.GetUserQuotaByTargetQuery) error {
//get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(query.Target))
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
}
......@@ -183,7 +183,7 @@ func GetUserQuotas(query *m.GetUserQuotasQuery) error {
//get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s where user_id=?", dialect.Quote(q.Target))
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
}
result[i] = &m.UserQuotaDTO{
......@@ -231,7 +231,7 @@ func GetGlobalQuotaByTarget(query *m.GetGlobalQuotaByTargetQuery) error {
//get quota used.
rawSql := fmt.Sprintf("SELECT COUNT(*) as count from %s", dialect.Quote(query.Target))
resp := make([]*targetCount, 0)
if err := x.Sql(rawSql).Find(&resp); err != nil {
if err := x.SQL(rawSql).Find(&resp); err != nil {
return err
}
......
......@@ -169,7 +169,7 @@ func SearchTeams(query *m.SearchTeamsQuery) error {
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
}
......@@ -196,7 +196,7 @@ func GetTeamById(query *m.GetTeamByIdQuery) error {
sql.WriteString(` WHERE team.org_id = ? and team.id = ?`)
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 {
return err
......@@ -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(` 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
}
......
......@@ -96,7 +96,7 @@ func GetTempUsersQuery(query *m.GetTempUsersQuery) error {
rawSql += " ORDER BY tu.created desc"
query.Result = make([]*m.TempUserDTO, 0)
sess := x.Sql(rawSql, params...)
sess := x.SQL(rawSql, params...)
err := sess.Find(&query.Result)
return err
}
......@@ -121,7 +121,7 @@ func GetTempUserByCode(query *m.GetTempUserByCodeQuery) error {
WHERE tu.code=?`
var tempUser m.TempUserDTO
sess := x.Sql(rawSql, query.Code)
sess := x.SQL(rawSql, query.Code)
has, err := sess.Get(&tempUser)
if err != nil {
......
......@@ -372,11 +372,11 @@ func GetSignedInUser(query *m.GetSignedInUserQuery) error {
sess := x.Table("user")
if query.UserId > 0 {
sess.Sql(rawSql+"WHERE u.id=?", query.UserId)
sess.SQL(rawSql+"WHERE u.id=?", query.UserId)
} else if query.Login != "" {
sess.Sql(rawSql+"WHERE u.login=?", query.Login)
sess.SQL(rawSql+"WHERE u.login=?", query.Login)
} else if query.Email != "" {
sess.Sql(rawSql+"WHERE u.email=?", query.Email)
sess.SQL(rawSql+"WHERE u.email=?", query.Email)
}
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