geddy / model

Datastore-agnostic ORM in JavaScript
265 stars 55 forks source link

Queries using 'includes array', returns duplicates #90

Closed admc closed 11 years ago

admc commented 11 years ago

The more items in the includes array, the more duplicates of all types included in the query. If I have 4 elements in this array, I get 8 comments, when there should only be 2. If I use 1 type in includes, then I get the correct number. Looks like a bug in the loop.

Example

~ geddy.model.Event.first(params.id, {includes: includes}, function(err, event) {

mde commented 11 years ago

So, Comments, Photos, Participants, Admins are all associations on Event, correct?

mde commented 11 years ago

Fixed in master in b098764ee0a41dca60a49506bc47aff151313eec.

admc commented 11 years ago

Yes, sorry about the delay, they are all associations, looks like you have it under control!

admc commented 11 years ago

This bug appears to be back, running geddy 0.11.8 and model 0.4.5, same repro - thoughts?

mde commented 11 years ago

I thought we had added a test specifically for this scenario. I'll have a look at our tests and make sure what we have covered.

mde commented 11 years ago

We do have a test for this, that passes in all the SQL adapters: https://github.com/mde/model/blob/master/test/integration/adapters/sql/eager_assn.js#L52

Could you give some more specifics that will help us narrow this down?

mde commented 11 years ago

Yep, this was broken by the refactor for streaming and MySQL. Fixed (again) in c6946335b6cfbde72891ead2438018eb8d6cbb1b, pushed to NPM, v0.4.6..

admc commented 11 years ago

Thanks dude!