theseus-rs / postgresql-embedded

Embed PostgreSQL database
Apache License 2.0
68 stars 11 forks source link

Should `create_database` override the `Settings` username? #55

Closed jcrossley3 closed 5 months ago

jcrossley3 commented 5 months ago

https://github.com/theseus-rs/postgresql-embedded/blob/9ef5d215f592aa1a30cb0f87351e029d332f14fd/postgresql_embedded/src/postgresql.rs#L311

If I set a username in the Settings used to construct a PostgreSQL instance, then create_database is going to fail without setting the db name to postgres.

What's The Right Way to both create a superuser and create a database via the PostgreSQL instance? Thanks!

brianheineman commented 5 months ago

@jcrossley3 thanks for the issue. I opened #57 and added an integration test to define the expected behavior for using the bootstrap superuser (which is currently hard-coded to postgres). If you need additional (super)users, you can use PsqlBuilder to create them as needed. Let me know if this addresses your question, or if you have any thoughts on how the behavior might be changed/improved for your use-cases.

jcrossley3 commented 5 months ago

@brianheineman that test appears to duplicate my use case exactly. thanks for the quick fix!

brianheineman commented 5 months ago

@jcrossley3 I just released v0.9.0 with this fix.