You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I am trying to initialize orm, this error appears
Stack trace
[discovery] ORM entity discovery started, using ReflectMetadataProvider
[discovery] - processing entity User
error - TypeError: Cannot read properties of undefined (reading 'toLowerCase')
at ReflectMetadataProvider.initPropertyType (/usr/src/app/node_modules/@mikro-orm/core/metadata/ReflectMetadataProvider.js:17:83)
at /usr/src/app/node_modules/@mikro-orm/core/metadata/ReflectMetadataProvider.js:9:54
at ReflectMetadataProvider.initProperties (/usr/src/app/node_modules/@mikro-orm/core/metadata/MetadataProvider.js:26:23)
at async ReflectMetadataProvider.loadEntityMetadata (/usr/src/app/node_modules/@mikro-orm/core/metadata/ReflectMetadataProvider.js:9:9)
at async MetadataDiscovery.discoverEntity (/usr/src/app/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:182:13)
at async MetadataDiscovery.discoverReferences (/usr/src/app/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:131:13)
at async MetadataDiscovery.findEntities (/usr/src/app/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:71:9)
at async MetadataDiscovery.discover (/usr/src/app/node_modules/@mikro-orm/core/metadata/MetadataDiscovery.js:34:9)
at async Function.init (/usr/src/app/node_modules/@mikro-orm/core/MikroORM.js:42:24)
at async handler (webpack-internal:///./src/api/useCases/articles/getAll/handler.ts:20:7) {
page: '/articles'
}
I fixed this issue by adding type: 'string' to all enum properties
It's strange, because documentation doesn't mention it
I think I should close this issue
Thank you @Arslanoov! I lost many hours trying to figure out if it was a TypeScript or SWC or Babel decorators issue, or something automatic that Next.js was doing. It was working without Next.js but when loading in an API route the "toLowerCase" error started happening.
after debug, i found there's no type prop for Enum properties.
so i have to add a type ( tinnyint /smallint/string is ok) for all enum properties. but it would be better to add a default type for it by mikroorm.
Hello. Thank you for the library
Describe the bug
When I am trying to initialize orm, this error appears
Stack trace
To Reproduce
Steps to reproduce the behavior:
make build
make up
make migrate
Expected behavior
Page should open
Additional context
Api files: https://github.com/Arslanoov/red/tree/main/app/src/api
Models folder: https://github.com/Arslanoov/red/tree/main/app/src/api/model
ORM config: https://github.com/Arslanoov/red/blob/main/app/src/api/config/mikroOrm.ts
Database init: https://github.com/Arslanoov/red/blob/main/app/src/api/utils/database/init.ts
Versions
The text was updated successfully, but these errors were encountered: