Skip to content

Conversation

@mabar
Copy link
Contributor

@mabar mabar commented Aug 17, 2022

When entity is created before MetadataStorage is instantiated, an exception is thrown. It happens when ORM classes are loaded lazily (e.g. via nette/di accessor). This PR fixes the issue.

@hrach hrach enabled auto-merge (squash) August 17, 2022 09:56
@hrach hrach disabled auto-merge August 17, 2022 09:56
@hrach
Copy link
Member

hrach commented Feb 5, 2023

Hi, thanks for this contribution. It seems that it is a nice solution to the problem, but I don't think it's a generally applicable solution for everybody as Orm may not be used in the whole nette application. So maybe creating a "configuration" option that would enable this if wanted? Wdyt?

@mabar
Copy link
Contributor Author

mabar commented Feb 6, 2023

I don't think it's a generally applicable solution

Yeah, it's not. I don't think any better way exists because ORM initialization depends on static class. Each DI integration has to implement this itself.

creating a "configuration" option that would enable this if wanted

Yeah, I could change it to something like that. Any opinion on how should the option be named?

nextras.orm:
	preloadMeta: true

@hrach
Copy link
Member

hrach commented Feb 6, 2023

preloadMetadata seems good :) (let's not use shortcut)

@mabar mabar force-pushed the initialize-metadata branch from e69313b to 4d289ec Compare February 7, 2023 15:02
@mabar mabar changed the base branch from main to v4.0 February 7, 2023 15:02
@mabar
Copy link
Contributor Author

mabar commented Feb 7, 2023

Okay, done. Is it okay that I retargeted to v4.0? Since it is opt-in feature.

@hrach
Copy link
Member

hrach commented Feb 7, 2023

Please open a separate PR for the other branch.

@mabar mabar changed the title [Nette] Initialize metadata on DIC startup [Nette] Initialize metadata on DIC startup - v4.0 Feb 7, 2023
@hrach hrach merged commit b8e87d4 into nextras:v4.0 Feb 8, 2023
@hrach
Copy link
Member

hrach commented Feb 8, 2023

Thank you!

@mabar mabar deleted the initialize-metadata branch July 1, 2023 10:38
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.

2 participants