Closed jhomarolo closed 2 years ago
It might not be the case, but scenarios like this happens when the require('@herbsjs/herbs')
for each entity is loading it from different node_modules
. Ex: One is loading from the project's node_modules
and the other is loading from herbs2knex's node_modules
. So when comparing, it is not the same class/object
@dalssoft it seems you're right!
After changing the reference inside herbs2knes to node_modules from todo-list the insert method returned to work.
Any ideas about how to solve this?
Whats is the risks using this validation inside gotu? new String(instance.__proto__).valueOf() === new String(BaseEntity).valueOf()
entity.isEntity = (instance) => {
return (
instance instanceof BaseEntity ||
instance.prototype instanceof BaseEntity ||
new String(instance.__proto__).valueOf() === new String(BaseEntity).valueOf())
}
After changing the reference inside herbs2knes to node_modules from todo-list the insert method returned to work.
We need to find a way to fix this. It might be the peerDependency
. Or if you are in dev mode, @herbsjs/herbs
might be installed using devDependency
Whats is the risks using this validation inside gotu? new String(instance.proto).valueOf() === new String(BaseEntity).valueOf()
We should avoid. It can masquerade real dependencies problems
Describe the bug After updating the project with a new version inside herbs (which had nothing to do with the gotu), the
isEntity
method simply stopped returning true for fields that are entities of other entities.And so the insert method also stopped working, because herbs2knex does a filter of fields that are entities before inserting.
But after doing that check here:
new String(instance.__proto__).valueOf() === new String(BaseEntity).valueOf()
the return is true.I'm having a hard time figuring out why.
To Reproduce To reproduce, just download the whole project and update herbs to the latest version 1.6.1
Expected behavior
Additional context I don't know if it's a problem with herbs2knex, but it hasn't been updated either.