Merge pull request #1072 from jinzhu/revert-1064-jay/limit-offset

Revert "Use int64 for limit/offset values to ensure values > 32-bit int are addressable."
This commit is contained in:
Jinzhu 2016-06-16 16:32:24 +08:00 committed by GitHub
commit cf3f9927ae
5 changed files with 9 additions and 9 deletions

View File

@ -35,7 +35,7 @@ type Dialect interface {
HasColumn(tableName string, columnName string) bool HasColumn(tableName string, columnName string) bool
// LimitAndOffsetSQL return generated SQL with Limit and Offset, as mssql has special case // LimitAndOffsetSQL return generated SQL with Limit and Offset, as mssql has special case
LimitAndOffsetSQL(limit, offset int64) string LimitAndOffsetSQL(limit, offset int) string
// SelectFromDummyTable return select values, for most dbs, `SELECT values` just works, mysql needs `SELECT value FROM DUAL` // SelectFromDummyTable return select values, for most dbs, `SELECT values` just works, mysql needs `SELECT value FROM DUAL`
SelectFromDummyTable() string SelectFromDummyTable() string
// LastInsertIdReturningSuffix most dbs support LastInsertId, but postgres needs to use `RETURNING` // LastInsertIdReturningSuffix most dbs support LastInsertId, but postgres needs to use `RETURNING`

View File

@ -122,7 +122,7 @@ func (s commonDialect) currentDatabase() (name string) {
return return
} }
func (commonDialect) LimitAndOffsetSQL(limit, offset int64) (sql string) { func (commonDialect) LimitAndOffsetSQL(limit, offset int) (sql string) {
if limit > 0 || offset > 0 { if limit > 0 || offset > 0 {
if limit >= 0 { if limit >= 0 {
sql += fmt.Sprintf(" LIMIT %d", limit) sql += fmt.Sprintf(" LIMIT %d", limit)

View File

@ -127,7 +127,7 @@ func (s mssql) currentDatabase() (name string) {
return return
} }
func (mssql) LimitAndOffsetSQL(limit, offset int64) (sql string) { func (mssql) LimitAndOffsetSQL(limit, offset int) (sql string) {
if limit > 0 || offset > 0 { if limit > 0 || offset > 0 {
if offset < 0 { if offset < 0 {
offset = 0 offset = 0

View File

@ -156,12 +156,12 @@ func (s *DB) Not(query interface{}, args ...interface{}) *DB {
} }
// Limit specify the number of records to be retrieved // Limit specify the number of records to be retrieved
func (s *DB) Limit(limit int64) *DB { func (s *DB) Limit(limit int) *DB {
return s.clone().search.Limit(limit).db return s.clone().search.Limit(limit).db
} }
// Offset specify the number of records to skip before starting to return the records // Offset specify the number of records to skip before starting to return the records
func (s *DB) Offset(offset int64) *DB { func (s *DB) Offset(offset int) *DB {
return s.clone().search.Offset(offset).db return s.clone().search.Offset(offset).db
} }

View File

@ -15,8 +15,8 @@ type search struct {
omits []string omits []string
orders []string orders []string
preload []searchPreload preload []searchPreload
offset int64 offset int
limit int64 limit int
group string group string
tableName string tableName string
raw bool raw bool
@ -82,12 +82,12 @@ func (s *search) Omit(columns ...string) *search {
return s return s
} }
func (s *search) Limit(limit int64) *search { func (s *search) Limit(limit int) *search {
s.limit = limit s.limit = limit
return s return s
} }
func (s *search) Offset(offset int64) *search { func (s *search) Offset(offset int) *search {
s.offset = offset s.offset = offset
return s return s
} }