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
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
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
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
665dde14
Commit
665dde14
authored
9 years ago
by
Peter Kieltyka
Browse files
Options
Downloads
Plain Diff
Merge pull request #121 from pxue/issue-120
Issue 120
parents
95d3d3d5
df1d2682
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mongo/collection.go
+8
-4
8 additions, 4 deletions
mongo/collection.go
mongo/database.go
+5
-0
5 additions, 0 deletions
mongo/database.go
with
13 additions
and
4 deletions
mongo/collection.go
+
8
−
4
View file @
665dde14
...
@@ -240,9 +240,11 @@ func (col *Collection) Append(item interface{}) (interface{}, error) {
...
@@ -240,9 +240,11 @@ func (col *Collection) Append(item interface{}) (interface{}, error) {
}
}
// And other interfaces?
// And other interfaces?
if
setter
,
ok
:=
item
.
(
ObjectIdIDSetter
);
ok
{
if
_
,
ok
:=
id
.
(
bson
.
ObjectId
);
ok
{
if
err
:=
setter
.
SetID
(
id
);
err
!=
nil
{
if
setter
,
ok
:=
item
.
(
ObjectIdIDSetter
);
ok
{
return
nil
,
err
if
err
:=
setter
.
SetID
(
id
.
(
bson
.
ObjectId
));
err
!=
nil
{
return
nil
,
err
}
}
}
}
}
...
@@ -260,7 +262,7 @@ func (col *Collection) Exists() bool {
...
@@ -260,7 +262,7 @@ func (col *Collection) Exists() bool {
}
}
// Fetches object _id or generates a new one if object doesn't have one or the one it has is invalid
// Fetches object _id or generates a new one if object doesn't have one or the one it has is invalid
func
getID
(
item
interface
{})
bson
.
ObjectId
{
func
getID
(
item
interface
{})
interface
{}
{
v
:=
reflect
.
ValueOf
(
item
)
v
:=
reflect
.
ValueOf
(
item
)
switch
v
.
Kind
()
{
switch
v
.
Kind
()
{
...
@@ -312,6 +314,8 @@ func getID(item interface{}) bson.ObjectId {
...
@@ -312,6 +314,8 @@ func getID(item interface{}) bson.ObjectId {
if
bsonID
.
Valid
()
{
if
bsonID
.
Valid
()
{
return
bsonID
return
bsonID
}
}
}
else
{
return
v
.
FieldByName
(
fieldName
)
.
Interface
()
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
mongo/database.go
+
5
−
0
View file @
665dde14
...
@@ -249,6 +249,11 @@ func (s *Source) versionAtLeast(version ...int) bool {
...
@@ -249,6 +249,11 @@ func (s *Source) versionAtLeast(version ...int) bool {
s
.
version
=
buildInfo
.
VersionArray
s
.
version
=
buildInfo
.
VersionArray
}
}
// Check major version first
if
s
.
version
[
0
]
>
version
[
0
]
{
return
true
}
for
i
:=
range
version
{
for
i
:=
range
version
{
if
i
==
len
(
s
.
version
)
{
if
i
==
len
(
s
.
version
)
{
return
false
return
false
...
...
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