-
Notifications
You must be signed in to change notification settings - Fork 215
track mongodb _id field so we can attempt to reissue queries #213
Conversation
func rawDataFromString(s string) interface{} { | ||
if bson.IsObjectIdHex(s) { | ||
return bson.ObjectIdHex(s) | ||
} | ||
if i, err := strconv.Atoi(s); err != nil { | ||
if i, err := strconv.Atoi(s); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was just bad logic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much LGTM, would love to get in the habit of having tests for the helper functions. Would have caught that terrible parse bug from before.
func rawDataFromString(s string) interface{} { | ||
if bson.IsObjectIdHex(s) { | ||
return bson.ObjectIdHex(s) | ||
} | ||
if i, err := strconv.Atoi(s); err != nil { | ||
if i, err := strconv.Atoi(s); err == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤦
|
||
func sortable(id interface{}) bool { | ||
switch id.(type) { | ||
case bson.ObjectId, string, float64, time.Time: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, all there any other sortable types _id can be? maybe int family?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from the testing I did, int's seem to always come back as float64 but I'll throw int64
in there just to be safe
@@ -359,35 +359,36 @@ func (m *MongoDB) catData() error { | |||
} else if match := m.collectionMatch.MatchString(collection); !match { | |||
continue | |||
} | |||
query := bson.M{} | |||
// lastID := "" | |||
canReissueQuery := m.requeryable(collection) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, this should be okay to cache. Hopefully people aren't messing with their indices while transporter is running :scary:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, I wouldn't expect people to be messing with the primary _id
index much to begin with much less while trying to perform a data transfer .
@trinchan good point on incremental addition of tests for the helper function. I plan on getting another PR in soon to lay a foundation for good e2e tests for adaptors. |
f03d3ac
to
03ab954
Compare
This change brings back the ability to re-issue a query after an err has been encountered while iterating a collection. For now, we will only attempt to perform the retry if the
_id
field is properly indexed is one ofbson.ObjectId, string, float64, time.Time
.