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

Support literal repository change in TypeORM@next #45

Open
matomesc opened this issue Feb 15, 2020 · 6 comments
Open

Support literal repository change in TypeORM@next #45

matomesc opened this issue Feb 15, 2020 · 6 comments

Comments

@matomesc
Copy link
Contributor

Repository is no longer a class but an object literal since typeorm/typeorm@ba4bebe and this breaks BaseRepository.

@odavid
Copy link
Owner

odavid commented Feb 15, 2020

Wow... on the surface this seems like a real deal breaker ): Do you have any ideas how to tackle this one?

The whole idea in this library is to always get the right entityManager from the context, by overriding the getter method... now when it is a literal member and not a function, it seems a bit hard.

Will be glad to hear ideas...

@matomesc
Copy link
Contributor Author

Perhaps we can patch the create() method in EntityManagerFactory. Then, for each manager instance created, override the manager's getRepository() method and add getter/setter to the repository's manager property to return the manager from the cls context.

@matomesc matomesc changed the title Support repository change in TypeORM@next Support literal repository change in TypeORM@next Mar 15, 2020
@buxel
Copy link

buxel commented Mar 24, 2020

Is this something I should worry about when evaluating this library for a new project? I appreciate your work, but i don't want to create technical debt right from the start. 🤔

@odavid
Copy link
Owner

odavid commented Mar 24, 2020

@matomesc I think the solution is the correct one. I was looking at the code before you mentioned it, but did not have the chance to write a comment.
@buxel - This library was implemented for personal usage and was published as a contribution for the community.
I am a bit off now for personal reasons. Will appreciate PRs...
Cheers

@buxel
Copy link

buxel commented Mar 27, 2020

Your contribution is much appreciated. I've put this issue into our project backlog, but also had to put transactions on hold because i'll have to focus on a different project starting next week.

@subvertallchris
Copy link

subvertallchris commented May 19, 2020

Any chance someone's started working on this? I'm not sure when TypeORM@next will land but it'd be great to have this worked out by then.

@buxel we had this discussion at work and ultimately decided to move ahead with using this library. While we are concerned about incompatibility with TypeORM@next, the value that it provides now (we're using this for transaction rollbacks in tests ala Database Cleaner) outweigh the risks of difficulty migrating in the future, so we're just taking on that debt. It looks like the next version of TypeORM contains some serious breaking changes so I don't think that incompatibility with this library will be the deciding factor in when or whether we upgrade, anyway.

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

No branches or pull requests

4 participants