You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when instantiating a new pg.client({}) object, when using pg-connection-string version 2.5.0 or lower, if i supply a connectionString to the config object that is simply the string name of the database (See below for example), it defaults the host of the URI to be localhost (as expected). Now, in newer versions, even if i have a PGHOST env var set, even if i manually add "localhost" to the config as the value for the host property, it is reading the host as "base". There doesn't seem to be a way for me to change that, except to set the connectionString property to be the entire full postgres URI. I dont know if this is desired behavior but it definitely doesn't appear to be working as expected.
In the docs for pg, it says this about connecting:
"The default values for the environment variables used are:
The above resulting code returns the connectionString object to be, if passed a database name of "fooBar", to just be "fooBar" if there is no env var set, and if it is not a test environment.
Again, in previous versions, before pg-connection-string version 2.6.2, this worked as expected. Please also note that adding to my .env the following: PGHOST='localhost'
this does not fix the issue, nor does changing the client config to look like the folowing:
export const db = new Client({
connectionString: getDatabaseUri("workout_tracker"),
host: 'localhost'
});
Please advise on how to get the expected behavior from early versions. I can show the resulting errors upon request
The text was updated successfully, but these errors were encountered:
The above resulting code returns the connectionString object to be, if passed a database name of "fooBar", to just be "fooBar" if there is no env var set, and if it is not a test environment.
That’s not a connection string, so you shouldn’t pass it as the connectionString property.
SYSTEM:
when instantiating a new
pg.client({})
object, when usingpg-connection-string
version 2.5.0 or lower, if i supply aconnectionString
to the config object that is simply the string name of the database (See below for example), it defaults the host of the URI to be localhost (as expected). Now, in newer versions, even if i have aPGHOST
env var set, even if i manually add "localhost" to the config as the value for thehost
property, it is reading the host as "base". There doesn't seem to be a way for me to change that, except to set theconnectionString
property to be the entire full postgres URI. I dont know if this is desired behavior but it definitely doesn't appear to be working as expected.In the docs for
pg
, it says this about connecting:"The default values for the environment variables used are:
PGHOST=localhost
PGUSER=process.env.USER
PGDATABASE=process.env.USER
PGPASSWORD=null
PGPORT=5432
"
this doesn't seem to be the case however as it is defaulting to "base".
CODE EXAMPLE
The above resulting code returns the connectionString object to be, if passed a database name of "fooBar", to just be "fooBar" if there is no env var set, and if it is not a test environment.
Again, in previous versions, before
pg-connection-string
version 2.6.2, this worked as expected. Please also note that adding to my .env the following:PGHOST='localhost'
this does not fix the issue, nor does changing the client config to look like the folowing:
The text was updated successfully, but these errors were encountered: