Table field name ambiguous error
In a simple hasMany association, when using get[As] method, can we add table name or alias when specifying the foreign key?
For e.g.
User.hasMany(Products);
user.getProducts() generates following query
select Product.* from Product
where UserId = [x]
I want to add table name 'Product' when specifying the UserId, something like
select Product.* from Product
where Product.UserId = [x]
Because, when trying to include another model which associates with User, I get field name ambiguous error for UserId
Hmm odd, that should really happens on it own when using includes since it uses find internally.
Can you post a small reproduceable set of models association and calls that show this bug?
@mickhansen
User.hasMany(Products)
User.hasMany(Comments)
Products.hasMany(Comments)
Comment.belongsTo(User)
Comment.belongsTo(Product)
user.getProducts({
include: [
{ model: Comment, include: [ User ] }
]
});
@mickhansen Any thought?
Haven't had a time to look at it. It should just work with that configuration.
Can't reproduce this with latest master