good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
U
upper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
open
upper
Commits
9c1c8675
Commit
9c1c8675
authored
May 14, 2016
by
José Carlos Nieto
Browse files
Options
Downloads
Patches
Plain Diff
Renaming Skip() and Sort() into Offset() and OrderBy().
parent
72c8b455
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
db.go
+8
-8
8 additions, 8 deletions
db.go
db_test.go
+7
-7
7 additions, 7 deletions
db_test.go
internal/sqladapter/result.go
+7
-7
7 additions, 7 deletions
internal/sqladapter/result.go
mongo/result.go
+7
-7
7 additions, 7 deletions
mongo/result.go
with
29 additions
and
29 deletions
db.go
+
8
−
8
View file @
9c1c8675
...
...
@@ -424,16 +424,16 @@ type Result interface {
// Limit defines the maximum number of results in this set. It only has
// effect on `One()`, `All()` and `Next()`.
Limit
(
u
int
)
Result
Limit
(
int
)
Result
//
Skip
ignores the first *n* results. It only has effect on `One()`, `All()`
//
Offset
ignores the first *n* results. It only has effect on `One()`, `All()`
// and `Next()`.
Skip
(
u
int
)
Result
Offset
(
int
)
Result
//
Sort
receives field names that define the order in which elements will be
//
OrderBy
receives field names that define the order in which elements will be
// returned in a query, field names may be prefixed with a minus sign (-)
// indicating descending order, ascending order will be used otherwise.
Sort
(
...
interface
{})
Result
OrderBy
(
...
interface
{})
Result
// Select defines specific columns to be returned from the elements of the
// set.
...
...
@@ -446,15 +446,15 @@ type Result interface {
// or columns.
Group
(
...
interface
{})
Result
// Remove deletes all items within the result set. `
Skip
()` and `Limit()` are
// Remove deletes all items within the result set. `
Offset
()` and `Limit()` are
// not honoured by `Remove()`.
Remove
()
error
// Update modifies all items within the result set. `
Skip
()` and `Limit()`
// Update modifies all items within the result set. `
Offset
()` and `Limit()`
// are not honoured by `Update()`.
Update
(
interface
{})
error
// Count returns the number of items that match the set conditions. `
Skip
()`
// Count returns the number of items that match the set conditions. `
Offset
()`
// and `Limit()` are not honoured by `Count()`
Count
()
(
uint64
,
error
)
...
...
This diff is collapsed.
Click to expand it.
db_test.go
+
7
−
7
View file @
9c1c8675
...
...
@@ -711,11 +711,11 @@ func TestFibonacci(t *testing.T) {
// Testing sort by function.
switch
wrapper
{
case
`postgresql`
:
res
=
res
.
Sort
(
db
.
Raw
(
`RANDOM()`
))
res
=
res
.
OrderBy
(
db
.
Raw
(
`RANDOM()`
))
case
`sqlite`
:
res
=
res
.
Sort
(
db
.
Raw
(
`RANDOM()`
))
res
=
res
.
OrderBy
(
db
.
Raw
(
`RANDOM()`
))
case
`mysql`
:
res
=
res
.
Sort
(
db
.
Raw
(
`RAND()`
))
res
=
res
.
OrderBy
(
db
.
Raw
(
`RAND()`
))
}
total
,
err
=
res
.
Count
()
...
...
@@ -729,7 +729,7 @@ func TestFibonacci(t *testing.T) {
}
// Find() with IN/$in
res
=
col
.
Find
(
db
.
Cond
{
"input IN"
:
[]
int
{
3
,
5
,
6
,
7
}})
.
Sort
(
"input"
)
res
=
col
.
Find
(
db
.
Cond
{
"input IN"
:
[]
int
{
3
,
5
,
6
,
7
}})
.
OrderBy
(
"input"
)
total
,
err
=
res
.
Count
()
...
...
@@ -741,7 +741,7 @@ func TestFibonacci(t *testing.T) {
t
.
Fatalf
(
`Expecting a count of 4.`
)
}
res
=
res
.
Skip
(
1
)
.
Limit
(
2
)
res
=
res
.
Offset
(
1
)
.
Limit
(
2
)
for
{
var
item
fibonacci
...
...
@@ -773,7 +773,7 @@ func TestFibonacci(t *testing.T) {
),
db
.
Cond
{
"input"
:
3
},
),
)
.
Sort
(
"-input"
)
)
.
OrderBy
(
"-input"
)
if
total
,
err
=
res
.
Count
();
err
!=
nil
{
t
.
Fatalf
(
`%s: %q`
,
wrapper
,
err
)
...
...
@@ -784,7 +784,7 @@ func TestFibonacci(t *testing.T) {
}
// Skipping.
res
=
res
.
Skip
(
1
)
.
Limit
(
2
)
res
=
res
.
Offset
(
1
)
.
Limit
(
2
)
for
{
var
item
fibonacci
...
...
This diff is collapsed.
Click to expand it.
internal/sqladapter/result.go
+
7
−
7
View file @
9c1c8675
...
...
@@ -61,15 +61,15 @@ func (r *Result) Where(conds ...interface{}) db.Result {
}
// Limit determines the maximum limit of Results to be returned.
func
(
r
*
Result
)
Limit
(
n
u
int
)
db
.
Result
{
r
.
limit
=
int
(
n
)
func
(
r
*
Result
)
Limit
(
n
int
)
db
.
Result
{
r
.
limit
=
n
return
r
}
//
Skip
determines how many documents will be skipped before starting to grab
//
Offset
determines how many documents will be skipped before starting to grab
// Results.
func
(
r
*
Result
)
Skip
(
n
u
int
)
db
.
Result
{
r
.
offset
=
int
(
n
)
func
(
r
*
Result
)
Offset
(
n
int
)
db
.
Result
{
r
.
offset
=
n
return
r
}
...
...
@@ -80,10 +80,10 @@ func (r *Result) Group(fields ...interface{}) db.Result {
return
r
}
//
Sort
determines sorting of Results according to the provided names. Fields
//
OrderBy
determines sorting of Results according to the provided names. Fields
// may be prefixed by - (minus) which means descending order, ascending order
// would be used otherwise.
func
(
r
*
Result
)
Sort
(
fields
...
interface
{})
db
.
Result
{
func
(
r
*
Result
)
OrderBy
(
fields
...
interface
{})
db
.
Result
{
r
.
orderBy
=
fields
return
r
}
...
...
This diff is collapsed.
Click to expand it.
mongo/result.go
+
7
−
7
View file @
9c1c8675
...
...
@@ -64,22 +64,22 @@ func (r *result) Where(terms ...interface{}) db.Result {
}
// Limit determines the maximum limit of results to be returned.
func
(
r
*
result
)
Limit
(
n
u
int
)
db
.
Result
{
r
.
queryChunks
.
Limit
=
int
(
n
)
func
(
r
*
result
)
Limit
(
n
int
)
db
.
Result
{
r
.
queryChunks
.
Limit
=
n
return
r
}
//
Skip
determines how many documents will be skipped before starting to grab
//
Offset
determines how many documents will be skipped before starting to grab
// results.
func
(
r
*
result
)
Skip
(
n
u
int
)
db
.
Result
{
r
.
queryChunks
.
Offset
=
int
(
n
)
func
(
r
*
result
)
Offset
(
n
int
)
db
.
Result
{
r
.
queryChunks
.
Offset
=
n
return
r
}
//
Sort
determines sorting of results according to the provided names. Fields
//
OrderBy
determines sorting of results according to the provided names. Fields
// may be prefixed by - (minus) which means descending order, ascending order
// would be used otherwise.
func
(
r
*
result
)
Sort
(
fields
...
interface
{})
db
.
Result
{
func
(
r
*
result
)
OrderBy
(
fields
...
interface
{})
db
.
Result
{
ss
:=
make
([]
string
,
len
(
fields
))
for
i
,
field
:=
range
fields
{
ss
[
i
]
=
fmt
.
Sprintf
(
`%v`
,
field
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment