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
Mongodb with replicaSet and authSource connect but fail to perform query using a connectionString #6209
Comments
I can confirm we have the same issue. |
should it be a regression introduced by #5640 ? |
More investigations: I guess the issue is here: https://github.com/typeorm/typeorm/blob/master/src/driver/DriverUtils.ts#L65 I'm not an expert with regular expressions and even less with the typeorm database urls formatting... but something like that could work (probably needs some huge improvements) : private static parseConnectionUrl(url: string) {
const regexp = '^(?<type>[a-zA-Z]+):\\/\\/' +
'((?<username>[^:@]+)(:(?<password>[^@]+))?@)?' +
'(?<host>[^:/]+)(:(?<port>[^/]+))?' +
'(\\/(?<database>[^?]+))?' +
'(\\?(?<queryParams>.+))?$'
const match = url.match(new RegExp(regexp));
if (match.groups.port != undefined) {
match.groups.port = parseInt(match.groups.port);
}
return match.groups || {};
} |
@ballinette this regex don't match my example of connectionString (which is valid). missing the options part. |
sure, the queryParams should then be parsed to get all the options. |
Any update of that point ? it make Typeorm not ready for production. |
Related to #6389 Closed by #6390 (not included in any release yet ...) Note that this just fixes the database name parsing, but does not pick up the query params as options, so As far as I can tell, this is not a problem as typeorm does not seem to expect it. Though |
I had the same issue with the latest version and |
Is this still a problem - I think we fixed a lot of the connection string problems |
Issue type:
[ ] question
[ x ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ x ]
mongodb
[ ]
mssql
[ ]
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:
Hi,
I'm running on production with a mongo cluster (4.2) on kubernetes.
I try to setup a project with typeorm and run it in production. (note : It's running fine in local env without a replicaSet)
In production, by using a connectionString as url parameters, I got the following problems :
Error : MongoError: not authorized on api-scheduler?authSource=admin&replicaSet=rs-sched to execute command { find: "jobs", filter: { status: { $in: [ "NEW", "WAITING_UPLOAD", "READY_TO_INGEST" ] }, type: "UPDATE", retryCount: { $lt: 3 } }, limit: 1, returnKey: false, showRecordId: false, lsid: { id: UUID("d9b954dc-5d37-4403-8258-2c60bc3cac9a") }, $clusterTime: { clusterTime: Timestamp(1591372379, 38), signature: { hash: BinData(0, 7145026E7D24FD4BB0E0E1EFDA889D51DF4232F4), keyId: 6797378919558283275 } }, $db: "api-scheduler?authSource=admin&replicaSet=rs-sched" }
The strange things is in the $db name at the end of the error message, right ?
Is there anyway to make it work properly with connectionString ?
The text was updated successfully, but these errors were encountered: