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

GH845 part 2: Ordering of entities matters in configuration #909

Closed
thatsnotright opened this issue Oct 8, 2020 · 2 comments
Closed

GH845 part 2: Ordering of entities matters in configuration #909

thatsnotright opened this issue Oct 8, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@thatsnotright
Copy link

Describe the bug
The entities must be provided to the config 'entities' field in hierarchical order. I don't think this is specified anywhere, and it results in very odd behavior.

Stack trace
ValidationError: Entity 'Parent' does not have property 'rel'

  51 | 
  52 |   static invalidPropertyName(entityName: string, invalid: string): ValidationError {
> 53 |     return new ValidationError(`Entity '${entityName}' does not have property '${invalid}'`);
     |            ^
  54 |   }
  55 | 
  56 |   static invalidType(type: Constructor<any>, value: any, mode: string): ValidationError {

  at Function.invalidPropertyName (packages/core/src/errors.ts:53:12)
  at EntityLoader.populate (packages/core/src/entity/EntityLoader.ts:43:29)
  at SqlEntityManager.find (packages/core/src/EntityManager.ts:111:29)
  at Object.<anonymous> (tests/issues/GH845.test.ts:83:21)

To Reproduce

  1. Edit GH845.test.ts and change the entities array to: entities: [Base, Relation1, Child1Specific, Child1, Child2, Parent],

Expected behavior
I expect that the order of this list doesn't matter. I can fully understand why it does, and there is an obvious workaround. I think this restriction should, at the least, be documented.

@B4nan
Copy link
Member

B4nan commented Oct 8, 2020

Weird, the order should not matter in general (there are some cases when it does because of circular dependencies, but your error runtime one, so discovery finished).

@B4nan B4nan added the bug Something isn't working label Oct 8, 2020
@thatsnotright
Copy link
Author

The reason we discovered this was because the properties we expected to be in the table were not, based on our STI domain classes. This resulted in the MySQL schema missing many of the fields.

@B4nan B4nan closed this as completed in f477a48 Oct 8, 2020
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