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

Creating a Postgres database fails since 5.5.3 #3769

Closed
briandiephuis opened this issue Nov 17, 2022 · 7 comments
Closed

Creating a Postgres database fails since 5.5.3 #3769

briandiephuis opened this issue Nov 17, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@briandiephuis
Copy link

Describe the bug
Creating a Postgres database fails since 5.5.3. Since this change our tests no longer run. In our integration tests we create a new database for just those tests, unfortunately automatically creating the database no longer works.

If we revert this method (manually in node_modules/@mikro-orm/postgresql/PostgreSqlSchemaHelper.js), everything works as expected:

  getManagementDbName(): string {
    return undefined; // instead of ''
  }

Not sure why though 🤔

Stack trace

DriverException: database "{ database username }" does not exist

*note that it logs the database username instead of the dbName 🤷

To Reproduce
Steps to reproduce the behavior:

  1. Set config to a non-existing dbName
  2. Start app
  3. Unable to create dbName

Expected behavior
Mikro-ORM should correctly create the desired database and connect to it.

Additional context
Connecting to an existing database works just fine.

Versions

Dependency Version
node 18.12.1
typescript 4.8.4
mikro-orm 5.5.3
@mikro-orm/postgresql 5.5.3
@B4nan
Copy link
Member

B4nan commented Nov 17, 2022

I've been fixing this 3 times already, I can't help without a complete reproduction, as I would almost certainly break something else (not to mention I have no idea how I would reproduce this).

Closing before you provide one.

@B4nan B4nan closed this as completed Nov 17, 2022
@B4nan
Copy link
Member

B4nan commented Nov 17, 2022

Start with providing complete ORM config - and I really mean complete, no blank spaces and variables, I need all the actual values (mangled of course, I dont care about your user/pass/host, but I need to see exact values that reproduce this).

@B4nan
Copy link
Member

B4nan commented Nov 17, 2022

Also, are you using env vars? Client URL (connection string)? Any special characters (namely :) in your username/password?

@briandiephuis
Copy link
Author

Ok, thanks for the quick reply! I'll provide more info soon.

@briandiephuis
Copy link
Author

@B4nan I've created this repo with a minimal setup -that represents what we use as much without too much bloat- to reproduce the bug. Let me know if this is too much or if you need anything else! The readme shows how to reproduce it in 5.5.2 and 5.5.3.

https://github.com/briandiephuis/nestjs-mikro-orm-example

@B4nan B4nan reopened this Nov 17, 2022
@briandiephuis
Copy link
Author

briandiephuis commented Nov 17, 2022

+any feedback on our test-setup is much appreciated ;)

@B4nan
Copy link
Member

B4nan commented Nov 17, 2022

Hmmm looks like postgres requires the database name, and defaults to the user name when it is not present. Will need to revert the changes and allow overriding the management db name for those who dont have the postgres database.

@B4nan B4nan added the bug Something isn't working label Nov 17, 2022
@B4nan B4nan closed this as completed in eab1668 Nov 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants