aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 138 forks source link

Multiple virtual columns causes a MongoDB error #230

Open jamesabbottsmith opened 9 years ago

jamesabbottsmith commented 9 years ago

Using multiple virtual columns inside the table, causes a error

Version: aslagle:reactive-table@0.8.0

Error: BadValue cannot sort with keys that are parallel arrays

 fields: [
            ...
            {key: 'activations.active', label: 'Active', fn: function(value, object) {return value.length}},
            {key: 'activations.zombie', label: 'Zombie', fn: function(value, object) {return value.length}},
            ...
 ]

Notes:

Stack Exception from sub reactive-table-pagedCollection id p9TEGokbvBxknZTCs MongoError: Runner error: BadValue cannot sort with keys that are parallel arrays at Object.Future.wait (/Users/jwa/.meteor/packages/meteor-tool/.1.1.3.4evuty++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/nodemodules/fibers/future.js:398:15) [object Object]..extend._nextObject (packages/mongo/mongodriver.js:929:1) [object Object]..extend.forEach (packages/mongo/mongodriver.js:963:1) [object Object]..extend.map (packages/mongo/mongodriver.js:973:1) [object Object]..extend.fetch (packages/mongo/mongo_driver.js:997:1) [object Object].Cursor.(anonymous function) as fetch getRows (packages/aslagle:reactive-table/lib/server.js:40:1) [object Object]._handler (packages/aslagle:reactive-table/lib/server.js:43:1) maybeAuditArgumentChecks (packages/ddp/livedataserver.js:1617:1) [object Object]..extend._runHandler (packages/ddp/livedata_server.js:950:1)

aslagle commented 9 years ago

Ooh, that's an interesting bug. It's not related to virtual columns, it's because you have two fields that both have nested keys under activations. Version 0.8.0 introduced multi-column sorting so it's now using both of them instead of one at a time. I'm not sure how to handle this but I'll look into it. Thanks!

aslagle commented 9 years ago

In v0.8.1, I've added an option to disable multi-column sorting: set multiColumnSort: false. That will make it only use one of the keys at a time for sorting so it should fix the error.

jamesabbottsmith commented 9 years ago

Seems to working well. Thanks :smile: