Open bravo-kernel opened 5 years ago
Hi @bravo-kernel.
I can look into this.
Can you please post your code for:
sequelize = new Sequelize( ... )
)Ofcourse, highly appreciated.
folder.js
model does not contain any information for the parent_id
and hierarchy_level
fieldsAh thanks. So are you saying underscored: true
should mean the model attributes should be called parentId
and hierarchyLevel
, but the fields in database table should be parent_id
and hierarchy_level
?
The brief mention of underscored
option in Sequelize docs here, this seem to suggest that.
In which case, yes, this is a bug.
Would you be willing to submit a PR to fix this? NB this plugin supports Sequelize v2-v5, so a fix would need to selectively change the behavior only for Sequelize v5+, and include tests for all Sequelize versions.
Exactly, that's how the v5 underscored
behavior works (even though I had to re-read it a 1000 times and had to sanity-check using code).
To be honest, a PR is a bit out of my skill league at this point, I just started pounding away at sequelize/js yesterday and don't even have a frontend yet so perhaps better to label this as a bug in case somebody else wants to pick up the challenge. I will keep using the underscored properties for now. When time comes (and this starts blocking me) I might give it a shot.
OK cool. I've labelled it as a bug.
But I don't use underscored
myself, so I'm not going to fix it.
Sorry if this seems like rather careless maintenance, but I am busy with other projects and this module has become a bit of a burden. So I'm open to receiving PRs, but I'm not able to put a lot of work in myself.
To get what you need in the meantime, you can always define the parentId
and hierarchyLevel
attributes yourself in the model definition, and then use the levelFieldName
and foreignKey
hierarchy options to point sequelize-hierarchy to use them rather than make its own.
Totally understandable and you are absolutely right. If you ask me... we should all be glad that you are still willing to review and comment. Take it easy.
I can confirm the attribute mapping works perfectly (as a workaround until the bug gets fixed).
folders.isHierarchy({
foreignKey: 'parentId',
levelFieldName: 'hierarchyLevel'
});
Related: sequelize#11225
I hope this is not another silly configuration error on my behalf but it looks like the Sequelize 5
underscored mode
I am using is not respected for the virtual fields.All pointer appreciated