diff options
author | G <guillaume.dube.girard@gmail.com> | 2017-08-04 00:42:51 -0400 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2017-08-04 12:42:51 +0800 |
commit | 34df9deff198da7b863fc3aad185cf76dd2df064 (patch) | |
tree | c0bf848d25373bd6437fe4b1d8b4d87077aea342 /models | |
parent | fa8d40facab6d3cba0bd95a3c882edfc28d478fd (diff) | |
download | gitea-34df9deff198da7b863fc3aad185cf76dd2df064.tar.gz gitea-34df9deff198da7b863fc3aad185cf76dd2df064.zip |
Convert xorm literal queries to method calls (#2253)
Diffstat (limited to 'models')
-rw-r--r-- | models/migrations/migrations.go | 3 | ||||
-rw-r--r-- | models/migrations/v28.go | 3 |
2 files changed, 2 insertions, 4 deletions
diff --git a/models/migrations/migrations.go b/models/migrations/migrations.go index 45c410c4d4..75ef8f6c58 100644 --- a/models/migrations/migrations.go +++ b/models/migrations/migrations.go @@ -712,8 +712,7 @@ func convertDateToUnix(x *xorm.Engine) (err error) { offset := 0 for { beans := make([]*Bean, 0, 100) - if err = x.SQL(fmt.Sprintf("SELECT * FROM `%s` ORDER BY id ASC LIMIT 100 OFFSET %d", - table.name, offset)).Find(&beans); err != nil { + if err = x.Table(table.name).Asc("id").Limit(100, offset).Find(&beans); err != nil { return fmt.Errorf("select beans [table: %s, offset: %d]: %v", table.name, offset, err) } log.Trace("Table [%s]: offset: %d, beans: %d", table.name, offset, len(beans)) diff --git a/models/migrations/v28.go b/models/migrations/v28.go index f7b4cd6e30..ec8155b982 100644 --- a/models/migrations/v28.go +++ b/models/migrations/v28.go @@ -37,8 +37,7 @@ func addRepoSize(x *xorm.Engine) (err error) { offset := 0 for { repos := make([]*Repository, 0, 10) - if err = x.Sql(fmt.Sprintf("SELECT * FROM `repository` ORDER BY id ASC LIMIT 10 OFFSET %d", offset)). - Find(&repos); err != nil { + if err = x.Table("repository").Asc("id").Limit(10, offset).Find(&repos); err != nil { return fmt.Errorf("select repos [offset: %d]: %v", offset, err) } log.Trace("Select [offset: %d, repos: %d]", offset, len(repos)) |