Giter VIP home page Giter VIP logo

Comments (4)

kamilmysliwiec avatar kamilmysliwiec commented on May 16, 2024

There are some problems with circular dependencies and decorators, but as far as I know, in this case @InjectRepository(class) will be fine even if class has circular deps inside. I actually tested this against hundred of repositories already.

from typeorm.

Sturgelose avatar Sturgelose commented on May 16, 2024

Thanks for the answer. In fact, I did some tests wrong and it seems that this wasn't faulty in my code. Mostly the issue I had is that my NestJS service used some TypeORM repository and the same TypeORM entity was doing a call back (through some other files/logic) to the same service.

In sum, I had a circular dependency, which typescript didn't report and the only message I got was that the class was undefined inside the @Injectrepository(class). And this class wasn't even the one having the issue of the circular dependency.

I guess this is something in a higher level, in TypeScript, that is not detected there... But also could be good to warn the user that if this class passed in @Injectrepository(class) is undefined, there is a high possibility that there is a circular dependency somehow!

from typeorm.

kamilmysliwiec avatar kamilmysliwiec commented on May 16, 2024

I added an additional check in 6.1.0 :)

from typeorm.

alex88 avatar alex88 commented on May 16, 2024

@kamilmysliwiec is it possible to know what's involved in the circular dependency? I had the problem that InjectRepository was trying to inject a null entity, now it seems that the code checks if it's null but I don't see how my code is circularly dependent as I've just added an entity custom validation constraint the injects the above class repository in its constructor

from typeorm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.