-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
It's unclear what connectionOptions is for #267
Comments
It is not a bug but that does not mean it is well designed. It should be at a minimum better documented. The tension is that there are connection parameters which are generated based on other configuration, such as the port and there is configuration that is "free" like the Database creation is a little more complex than one might at first imagine. If you want to create another database you have to use
I think it is possible that I could look to the If this was how As it stands with the current approach, I think Long story short, this is not a bug AFAICT but the types allow one to use the API incorrect ways so it is not an ideal situation either. |
rather than changing the connectionOptions field of Config. Partially addresses #267
…268) rather than changing the connectionOptions field of Config. Partially addresses #267 Co-authored-by: Tom Ellis <[email protected]>
Thanks for the PR to document this better. For a longer term fix do you have any thoughts? I think I am move towards having a special client options type that is missing the |
Personally I'd like to see a
In summary I would describe it as having a "low-level configuration datatype" that makes it clear precisely how tmp-postgres sets up the database, and having the convenient default values/ Regarding "exactly where each parameter is taken from", consider the example of Regarding "no defaults", consider |
This is what the However isn't some of the value of tmp-postgres is that it has defaults? It picks a free port and uses a temporary directory for the data. That's definitely part of the value from my perspective. The other bits are about caching and various speed improvements. Otherwise why not just call initdb and postgres yourself?
I can see how that is not clear.
I would not say tmp-postgres is communicating with Postgres via these environment variables.
It is pretty common for configuration to use a monoid for combination. I suppose another method could be used to combine default values. Without seeing the alternative method of combination it is hard for me to say if it is better or worse than what is there now. |
Thanks, I will have a look.
Yes, absolutely, the defaults are very convenient and I think the monoid API makes a great sugary front end. I think there should also be a plain, no sugar intermediate API too though. I'll have to think more about how to describe what I am imagining. |
Config
contains a field calledconnectionOptions
but it's unclear it is for, or at least I can't see how to use it successfully. For example, I thought that I could setconnectionOptions
to choose adbname
:Although that appears to work no such database called
mydbname
exists:It seems that the right way to choose a
dbname
is to useoptionsToConfig
.Then
psql
shows that the database calledmydbname
does indeed exist.(
optionsToDefaultConfig
also works in place ofoptionsToConfig
)Is it supposed to be possible to set a
dbname
by modifying theconnectionOptions
of aConfig
? I spent about an hour trying to do so unsuccessfully. The fact thattoConnectionString
returned a string containing the correctdbname
, but thatdbname
didn't actually exist, sent me down the wrong track. Does my inability to get this to work indicate a bug or have I failed to conjure up the right recipe? I tried to understand the intention of the API by looking at the implementation but I got bamboozled by theLast
Monoid
stuff.(Tangentially, even with
dbname
set a database calledpostgres
still gets created. I don't much care about that, but does it indicate that something has gone wrong somewhere internally?)The text was updated successfully, but these errors were encountered: