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

MongoQueryRunner.databaseConnection is declared with a wrong type #6453

Closed
justin-lau opened this issue Jul 23, 2020 · 1 comment · Fixed by #6906
Closed

MongoQueryRunner.databaseConnection is declared with a wrong type #6453

justin-lau opened this issue Jul 23, 2020 · 1 comment · Fixed by #6906

Comments

@justin-lau
Copy link

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:

MongoQueryRunner.databaseConnection has the type Db while it should actually be MongoClient.

Where databaseConnection is defined in src/driver/mongodb/MongoQueryRunner.ts:

    /**
     * Real database connection from a connection pool used to perform queries.
     */
    databaseConnection: Db;

    // -------------------------------------------------------------------------
    // Constructor
    // -------------------------------------------------------------------------

    constructor(connection: Connection, databaseConnection: Db) {
        this.connection = connection;
        this.databaseConnection = databaseConnection;
        this.broadcaster = new Broadcaster(this);
    }

Where it is created in src/driver/mongodb/MongoDriver.ts:

    connect(): Promise<void> {
        return new Promise<void>((ok, fail) => {
            this.mongodb.MongoClient.connect(
                this.buildConnectionUrl(),
                this.buildConnectionOptions(),
                (err: any, client: any) => {
                    if (err) return fail(err);

                    this.queryRunner = new MongoQueryRunner(this.connection, client);
                    ObjectUtils.assign(this.queryRunner, { manager: this.connection.manager });
                    ok();
                });
        });
    }

Reference to mongodb.MongoClient.connect:
https://mongodb.github.io/node-mongodb-native/3.1/api/MongoClient.html#~connectCallback

@imnotjames
Copy link
Contributor

imnotjames commented Oct 14, 2020

I noticed this too! Very frustrating for typing. I'll take a crack at a quick PR if you can confirm it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants