nestjs / typeorm

TypeORM module for Nest framework (node.js) 🍇
https://nestjs.com
MIT License
1.9k stars 206 forks source link

Validating data sources configurations #2017

Open Motii1 opened 2 months ago

Motii1 commented 2 months ago

Is there an existing issue that is already proposing this?

Is your feature request related to a problem? Please describe it

The application is allowed to have multiple data sources with the same name

Describe the solution you'd like

In the documentation there is a warning:

If you don't set the name for a data source, its name is set to default.
Please note that you shouldn't have multiple connections without a name, 
or with the same name, otherwise they will get overridden.

Since it is not recommended it would be nice to fail the application startup if more than one data source with the same name is detected

Teachability, documentation, adoption, migration strategy

The warning in the documentation could be adjusted

What is the motivation / use case for changing the behavior?

At my company, we are creating multiple data sources. We encountered an issue where we inadvertently created several data sources with identical names, which is something we should avoid. This oversight led to numerous problems and required significant time to debug. While my preferred solution is outlined above, I understand it would involve a breaking change. Therefore, I would be satisfied with at least a warning log message to prevent this issue in the future.