-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Description
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql
/ mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x
(or put your version here)
Steps to reproduce or a small repository showing the problem:
From the docs:
url - Connection url where perform connection to. Please note that other connection options will override parameters set from url.
In my particular situation, I pass url
for host, port, database, etc in the TypeORM options but supply username and password directly.
TypeOrmModule.forRoot({
type: 'mysql',
url: DB_CONNECTION, // CONNECTION STRING
// for example: mysql://localhost:3306/dev
username: DB_USERNAME, // abc
password: DB_PASSWORD, // abc
database: 'dev',
entities: ['src/**/**.entity{.ts,.js}'],
}),
The username and password are not set in the given connection string, and based on the documentation, the two values should have priority from the options vs the unspecified values in the connection string url.
It seems like this could be reversed and this would work as documented.
return Object.assign({}, options, urlDriverOptions);
// before
{
type: 'mysql',
url: 'mysql://localhost:3306/dev',
username: '',
password: '',
database: 'dev',
entities: [ 'src/**/**.entity{.ts,.js}' ],
host: 'localhost',
port: 3306
}
// after
{
type: 'mysql',
url: 'mysql://localhost:3306/dev',
username: 'abc',
password: 'abc',
database: 'dev',
entities: [ 'src/**/**.entity{.ts,.js}' ],
host: 'localhost',
port: 3306
}
Another solution I think, may be to enhance the current parsing and switching the order of the order object assign.
Thanks for the consideration.