good morning!!!!

Skip to content
Snippets Groups Projects
Commit 665dde14 authored by Peter Kieltyka's avatar Peter Kieltyka
Browse files

Merge pull request #121 from pxue/issue-120

Issue 120
parents 95d3d3d5 df1d2682
No related branches found
No related tags found
No related merge requests found
...@@ -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()
} }
} }
} }
......
...@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment