-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
many to many through association on through table model return array instead of single object #5288
Comments
Anyone have time to look into this? Failing tests are here #1134. This will be required for proper through association support. |
@devinivy that's strange, if I had to guess I would say it must have something to do with Waterline Schema flagging the |
@particlebanana one more time you were right ! i corrected if in two PR. could you have a look? |
Safe to use in production? |
@weyert in fact i think that waterline' actual manytomany through association is really buggy and should not be used in production...my PR correct some bugs... |
Thanks for the head ups. You are managing it manually now then? |
@weyert for simple case use manytomany association |
@atiertant I think I tracked this down even further. So first some background, when you have two collections pointing at each other (many-to-many) waterline-sequel generates a join table for you and flags it as a So what was happening was basically because it's tagged as a What the proposed patch here does is attempt to fight the incorrect mapping by adding some additional metadata to the table. Unfortunately from my tests, this seems to fix the populates on the join table (Drive) and break the populates on either side (User, Car). I'm working on a patch to Waterline-schema that adds a I did have a question about your models above and want to make sure I am on the same page as far as the issue is concerned. In your So just to clear up how that should work you can think of it as: "This population will return the This would make the collections look like so: collections.user = Waterline.Collection.extend({
identity: 'user',
connection: 'foo',
attributes: {
id: {
type: 'integer',
primaryKey: true
},
cars: {
collection: 'car',
through: 'drive',
via: 'user'
}
}
});
collections.drive = Waterline.Collection.extend({
identity: 'drive',
connection: 'foo',
attributes: {
id: {
type: 'integer',
primaryKey: true
},
car: {
model: 'car'
},
user: {
model: 'user'
}
}
});
collections.car = Waterline.Collection.extend({
identity: 'car',
connection: 'foo',
attributes: {
id: {
type: 'integer',
primaryKey: true
},
drivers: {
collection: 'user',
through: 'drive',
via: 'car',
dominant: true
}
}
}); I'll tag you in the patches I am submitting so you can make sure they pass. I'll cherry pick in fc0c671a98acfa997461533f9e34a812ddcd65dc so we have it tested and fix up the via's as well. |
@particlebanana you are right my |
Manytomanythrough fix and failling test for #1133
Thanks for posting, @atiertant. I'm a repo bot-- nice to meet you! It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message. On the other hand, if you are still waiting on a patch, please:
Thanks so much for your help! |
@atiertant @particlebanana should this be reopened? |
many to many through association on through table model return array instead of single object :
return
istead of
The text was updated successfully, but these errors were encountered: