question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongodb always uses "test" as database name since 0.2.25

See original GitHub issue

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 (0.2.25) [ ] @next [ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

When updating to the 0.2.25 (from 0.2.24), typeorm now always uses the database named ‘test’ instead of what is passed in the options when using mongodb.

Downgrading to 0.2.24 makes it work again.

We are using "@nestjs/typeorm": "^7.0.0".

With the debugger we can see that the option is correct:

image

From what I can see, it’s simply always using the default database name, taken from node_modules\mongodb\lib\core\uri_parser.js:

line 673:

  if (result.auth && result.auth.db) {
    result.defaultDatabase = result.auth.db;
  } else {
    result.defaultDatabase = 'test';
  }

replacing test with another value will give me that value as database name.

Version 0.2.24 has no such issue.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Lectemcommented, Aug 10, 2020

Yes, I can repro when updating to 0.2.25. I wish I had a minimal repro but sadly don’t have much time right now. 😞 I’m guessing that any nestjs application using mongodb should trigger this though.

0reactions
imnotjamescommented, Sep 30, 2020

Let me know if the issue persists - however, as I can’t replicate it with 0.2.26 & 0.2.27 I think we’re good to go here!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fineone stuck on test database named - MongoDB
I have to connect like this on database name test1 : mongodb://user:pass@www.server.com:27017?authMechanism=SCRAM-SHA-1&authSource=test1 but ...
Read more >
Couldn't connect to server 127.0.0.1:27017 - Stack Overflow
I made chown and chmod to var, lib, and data/db and log mongodb. Not sure what else to do. Any suggestions? mongodb.log: *****...
Read more >
Running MongoDB as a Docker Container | Baeldung on Linux
Further, we also set the DB credentials with the container name. Let's create and start the containers using the simple up command:
Read more >
How To Use MongoDB Compass - DigitalOcean
The MongoDB shell allows you to access a database as long as you already have access to the server on which MongoDB is...
Read more >
4. Querying - MongoDB: The Definitive Guide, 2nd Edition [Book]
You can perform ad hoc queries on the database using the find or findOne ... While "$or" will always work, use "$in" whenever...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found