stijnsanders / TMongoWire

Delphi MongoDB driver
MIT License
102 stars 37 forks source link

Sorting of keys in TBSONDocument invalidated certain commands #9

Closed smokingdev closed 12 years ago

smokingdev commented 12 years ago

Hi,

I was writing a map/reduce function which wouldn't function because TMongoWire was sending the 'map' key before the 'mapreduce' key. I found that the origin of this problem lies within the TBSONDocument which sorts the keys (I guess for speed reasons).

I've added a piece of code which maintains an array of the original insertion order. This array is used in the Save function to write the keys in their original order.

This solves the problem I was having and should keep the speed advantage of sorting.

Kind regards,

Fred Oranje

stijnsanders commented 12 years ago

I've had a close look and I changed the existing arrays around instead of adding yet another array for the sort order. please view my latest commit: https://github.com/stijnsanders/TMongoWire/commit/f8bb5a1ad77a6724eb3d3921ff191ebed707f61d

smokingdev commented 12 years ago

I found a small bug and created a pull request with a fix: https://github.com/stijnsanders/TMongoWire/pull/11