Skip to content
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

"Cannot read properties of undefined" error when entity has functions #73

Open
vitorgamer58 opened this issue Jan 1, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@vitorgamer58
Copy link
Contributor

Describe the bug
When an entity has functions, a TypeError: Cannot read properties of undefined (reading 'isId') occurs.

I verified that this occurs in the getEntityIds function, as the entity fields are obtained through entity.prototype.meta.schema, but before filtering the id fields, you must go through this list again to filter the functions, as functions do not have the options field, resulting in an attempt to read the property of an undefined.

To Reproduce
Create a project with Herbs2Knex, whose entity has functions, then try to run the project, making insertions and searches in the database.

Expected behavior
The behavior is that this exception is not thrown.

Screenshots
Screenshot_1600
Screenshot_1601

Additional context
I believe this can be resolved by adding a .filter((field) => typeof field != 'function') in the idFields constant.

@vitorgamer58 vitorgamer58 added the bug Something isn't working label Jan 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant