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

fix: resolve entities correctly in datasource when globs are specified #8769

Closed
wants to merge 1 commit into from
Closed

fix: resolve entities correctly in datasource when globs are specified #8769

wants to merge 1 commit into from

Conversation

niranjan94
Copy link

@niranjan94 niranjan94 commented Mar 21, 2022

Closes: #8768

Description of change

In the 0.3 release, DataSource stopped resolving entities correctly when specified as Globs. This results in the data source information not being set correctly into the entities. This PR fixes it by correctly importing the classes when globs are specified.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change - N/A
  • The new commits follow conventions explained in CONTRIBUTING.md

@niranjan94
Copy link
Author

@pleerock please review this when possible. Unfortunately, I'm unable to run the TypeORM tests locally due some issue on my end. So, I was unable to add unit tests to cover this failure.

But I did test a build of TypeORM containing this change against my applications and can confirm that #8768 is indeed resolved.

@@ -645,6 +646,17 @@ export class DataSource {
const flattenedEntities = ObjectUtils.mixedListToArray(
this.options.entities || [],
)

// resolve globs to the respective entity classes
flattenedEntities.push(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't look like a proper solution. We already do import classes from directories above by calling buildEntityMetadatas method.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah okay! Thanks for the clarification 😄
Probably need to look through the codebase more.

@pleerock
Copy link
Member

Closing in favor of #8778

@pleerock pleerock closed this Mar 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0.3] Datasource not set on entities when using path in entities datasource options
2 participants