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

No way to reuse an existing named DB connection #127

Open
abramyk-mv opened this issue Apr 22, 2021 · 0 comments
Open

No way to reuse an existing named DB connection #127

abramyk-mv opened this issue Apr 22, 2021 · 0 comments

Comments

@abramyk-mv
Copy link

I try to run seed using an existing named DB connection and it does not work as expected.

To specify a connection name, I pass a connection property to configureConnection() function.
After digging in the code of the createConnection() function, I discovered that it is supposed to reuse a connection if it already exists.

if (connection === undefined) {
try {
connection = await TypeORMGetConnection(configureOption.name)
} catch (_) {}
if (connection === undefined) {
connection = await TypeORMCreateConnection(ormConfig)
}
;(global as any)[KEY].connection = connection
}
return connection

So, the last step is calling a createConnection() function with configured above options.

But the issue is that this line of code never gonna work as expected.

connection = await TypeORMGetConnection(configureOption.name)

It retrieves a connection name from the name property of a configureOption object. The property is always undefined as it does not even exist in the ConfigureOption interface.
export interface ConfigureOption {
root?: string
configName?: string
connection?: string
}

I tried to change connection = await TypeORMGetConnection(configureOption.name) to connection = await TypeORMGetConnection(configureOption.connection) and it started to work properly.

Should I submit a PR for these changes or are there any restrictions I am not aware of?

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

1 participant