stripe-archive / mosql

MongoDB → PostgreSQL streaming replication
MIT License
1.63k stars 225 forks source link

Extract ObjectId from DBRef arrays #52

Closed gferon closed 10 years ago

gferon commented 10 years ago

Since issue #50 was closed with commit 8043b96, I'd like to try contributing.

When an Array contains DBRef objects, it's best to use the $oid BSON::ObjectId string value instead of the default string representation of DBRef which is not a valid hash. This is consistent with the conversion made for single DBRef values. This has been tested with both JSON and TEXT ARRAY columns types.

nelhage commented 10 years ago

Hm. We should probably be doing this transformation for other types, too -- e.g. I bet we don't handle an array of BSON::ObjectId, either. Probably transform needs to walk the structure recursively.

But this patch should be an incremental improvement, so I'm happy to take this for now. Thanks for submitting it!