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

Embeddables that are nullable but not object result in error #3772

Closed
Langstra opened this issue Nov 17, 2022 · 0 comments
Closed

Embeddables that are nullable but not object result in error #3772

Langstra opened this issue Nov 17, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@Langstra
Copy link
Collaborator

Langstra commented Nov 17, 2022

Describe the bug
Having an embeddable defined like this @Embedded(() => Profile, { nullable: true }) and then assigning is null results in an error. This behaviour seems to be since v5.5, before this went fine.

Stack trace

Cannot read property 'replace' of undefined
TypeError: Cannot read property 'replace' of undefined
  at BetterSqlitePlatform.quoteIdentifier (/mikro-orm/packages/core/src/platforms/Platform.ts:347:26)
  at /mikro-orm/packages/knex/src/AbstractSqlDriver.ts:329:68
  at Array.map (<anonymous>)
  at BetterSqliteDriver.nativeInsertMany (/mikro-orm/packages/knex/src/AbstractSqlDriver.ts:329:45)
  at ChangeSetPersister.persistNewEntity (/mikro-orm/packages/core/src/unit-of-work/ChangeSetPersister.ts:107:35)
  at ChangeSetPersister.executeInserts (/mikro-orm/packages/core/src/unit-of-work/ChangeSetPersister.ts:38:18)
  at ChangeSetPersister.runForEachSchema (/mikro-orm/packages/core/src/unit-of-work/ChangeSetPersister.ts:86:42)
  at ChangeSetPersister.executeInserts (/mikro-orm/packages/core/src/unit-of-work/ChangeSetPersister.ts:27:19)
  at UnitOfWork.commitCreateChangeSets (/mikro-orm/packages/core/src/unit-of-work/UnitOfWork.ts:881:35)
  at UnitOfWork.persistToDatabase (/mikro-orm/packages/core/src/unit-of-work/UnitOfWork.ts:819:7)
  at BetterSqliteConnection.transactional (/mikro-orm/packages/knex/src/AbstractSqlConnection.ts:51:19)
  at UnitOfWork.doCommit (/mikro-orm/packages/core/src/unit-of-work/UnitOfWork.ts:362:9)
  at UnitOfWork.commit (/mikro-orm/packages/core/src/unit-of-work/UnitOfWork.ts:330:7)
  at SqlEntityManager.flush (/mikro-orm/packages/core/src/EntityManager.ts:981:5)
  at Object.<anonymous> (/mikro-orm/tests/issues/GH9999.test.ts:50:3)

To Reproduce
Steps to reproduce the behavior:

  1. Checkout the PR #3771
  2. Run the test
  3. When adding {object: true} to the Embedded it would work

Expected behavior
All columns in the table belonging to the Embeddable should get the null value. Or if you'd consider this the correct behaviour a better error message should be displayed indicating the problem.

Additional context
In v5.4.2 (bf35754) this did work

Versions

Dependency Version
node ?
typescript ?
mikro-orm 5.5.x
your-driver ?
@B4nan B4nan added the bug Something isn't working label Nov 17, 2022
@B4nan B4nan closed this as completed in 6e0bedf Nov 17, 2022
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

2 participants