-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Added parameter default_dbname
to pdo_pgsql driver, used to override the default database
#2284
Changes from all commits
2ceadc0
c31de12
d7bbd30
f471a0f
253b602
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,10 +88,12 @@ private function _constructPdoDsn(array $params) | |
|
||
if (isset($params['dbname'])) { | ||
$dsn .= 'dbname=' . $params['dbname'] . ' '; | ||
} elseif (isset($params['default_dbname'])) { | ||
$dsn .= 'dbname=' . $params['default_dbname'] . ' '; | ||
} else { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd say remove this else block entirely, as postgresql has a default behavior, which is to connect to the database matching the username. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I rather want to remove the "else", that way we get the default behaviour (username) but people can still override it something like template1 if they want to live on the edge. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree - I meant remove L91-96. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strongly disagree. As already said this is basically what it's all about. Defining |
||
// Used for temporary connections to allow operations like dropping the database currently connected to. | ||
// Connecting without an explicit database does not work, therefore "postgres" database is used | ||
// as it is certainly present in every server setup. | ||
// as it is mostly present in every server setup. | ||
$dsn .= 'dbname=postgres' . ' '; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should still connect to
postgres
if the parameter is not set as we will have errors again otherwise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, postgres is the default if dont provide one. Ive tested it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kimhemsoe that is not true. It defaults to a database that is named equally to the connection user. This is what originally caused trouble. See PHP issue and doctrine/DoctrineBundle#402
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deeky666 @kimhemsoe Ah yes, I was wrong - you can verify this using:
PDO
If no db matching your username exists, you get:
pgsql
If no db matching your username exists, you get: