Closed flashspys closed 4 years ago
Sorry for slow reply - I just saw your issue.
This looks like a problem with Sequelize rather than sequelize-hierarchy. To find out, just remove the hierarchy: true
option and try running the query. If it still fails, it's Sequelize causing the problem.
Please let me know...
Did you have any luck discovering if this is a problem with sequelize-hierarchy or Sequelize itself? If it turned out to be Sequelize, could you close this issue please?
Our code evolved around this problem, I don't have any oppertunities to test this, sorry.
No problem. Thanks for letting me know.
We have the following layout:
Category.hasMany(Datapoint)
,Datapoint.belongsTo(User)
. Hierarchy is enabled onCategory
. I want to query now a Category, with all their subcategories, and with all Datapoints assigned to this category and its subcategories and with all Users assigned to the Datapoints. The js looks like the following:The SQL generated is the following:
The problem happens in the last
LEFT OUTER JOIN
so the join where the user information is appended to the datapoints. There are two problems:ON
condition is"datapoints"."creatorId" = "datapoints->creator"."id"
. Unfortunately"datapoints"
is not a valid table. The correct aliasdescendents->datapoints
from theLEFT OUTER JOIN
above was not used in thisON
condition.datapoints->creator
itself is wrong. It should bedescendents->datapoints->creator
, as the field selection above is suggesting.Is there a hotfix available? Is this a problem in this repo or from sequelize?