Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
f02b286a
Commit
f02b286a
authored
Aug 16, 2013
by
slene
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
orm make offset simple, can use any numeric type
parent
0372b817
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
orm_queryset.go
orm/orm_queryset.go
+17
-4
types.go
orm/types.go
+2
-2
No files found.
orm/orm_queryset.go
View file @
f02b286a
...
...
@@ -2,6 +2,7 @@ package orm
import
(
"fmt"
"reflect"
)
type
querySet
struct
{
...
...
@@ -33,16 +34,28 @@ func (o querySet) Exclude(expr string, args ...interface{}) QuerySeter {
return
&
o
}
func
(
o
querySet
)
Limit
(
limit
int
,
args
...
int64
)
QuerySeter
{
func
(
o
*
querySet
)
setOffset
(
num
interface
{})
{
val
:=
reflect
.
ValueOf
(
num
)
switch
num
.
(
type
)
{
case
int
,
int8
,
int16
,
int32
,
int64
:
o
.
offset
=
val
.
Int
()
case
uint
,
uint8
,
uint16
,
uint32
,
uint64
:
o
.
offset
=
int64
(
val
.
Uint
())
default
:
panic
(
fmt
.
Errorf
(
"<QuerySeter> offset value need numeric not `%T`"
,
num
))
}
}
func
(
o
querySet
)
Limit
(
limit
int
,
args
...
interface
{})
QuerySeter
{
o
.
limit
=
limit
if
len
(
args
)
>
0
{
o
.
offset
=
args
[
0
]
o
.
setOffset
(
args
[
0
])
}
return
&
o
}
func
(
o
querySet
)
Offset
(
offset
int
64
)
QuerySeter
{
o
.
offset
=
offset
func
(
o
querySet
)
Offset
(
offset
int
erface
{}
)
QuerySeter
{
o
.
setOffset
(
offset
)
return
&
o
}
...
...
orm/types.go
View file @
f02b286a
...
...
@@ -45,8 +45,8 @@ type QuerySeter interface {
Filter
(
string
,
...
interface
{})
QuerySeter
Exclude
(
string
,
...
interface
{})
QuerySeter
SetCond
(
*
Condition
)
QuerySeter
Limit
(
int
,
...
int
64
)
QuerySeter
Offset
(
int
64
)
QuerySeter
Limit
(
int
,
...
int
erface
{}
)
QuerySeter
Offset
(
int
erface
{}
)
QuerySeter
OrderBy
(
...
string
)
QuerySeter
RelatedSel
(
...
interface
{})
QuerySeter
Count
()
(
int64
,
error
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment