-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
feat: add support for PostgreSQL application_name in DSN #8852
Conversation
You can configure it as: public array $default = [
'DSN'=> "host=localhost port=5432 user=postgres password='postgres' dbname=test options='--application_name=CI4'",
// ...
]; So this is an enhancement. So you should send this PR to |
@@ -43,6 +43,7 @@ class Database extends Config | |||
'failover' => [], | |||
'port' => 3306, | |||
'numberNative' => false, | |||
'application_name' => '', //supported only in 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.
This array is settings for MySQLi. So do not add unrelated config item.
Add in
CodeIgniter4/app/Config/Database.php
Lines 75 to 100 in 902ec98
// /** | |
// * Sample database connection for Postgre. | |
// * | |
// * @var array<string, mixed> | |
// */ | |
// public array $default = [ | |
// 'DSN' => '', | |
// 'hostname' => 'localhost', | |
// 'username' => 'root', | |
// 'password' => 'root', | |
// 'database' => 'ci4', | |
// 'schema' => 'public', | |
// 'DBDriver' => 'Postgre', | |
// 'DBPrefix' => '', | |
// 'pConnect' => false, | |
// 'DBDebug' => true, | |
// 'charset' => 'utf8', | |
// 'swapPre' => '', | |
// 'failover' => [], | |
// 'port' => 5432, | |
// 'dateFormat' => [ | |
// 'date' => 'Y-m-d', | |
// 'datetime' => 'Y-m-d H:i:s', | |
// 'time' => 'H:i:s', | |
// ], | |
// ]; |
* | ||
* @var array | ||
*/ | ||
protected $application_name = []; |
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.
This property is only for Postgre.
Don't add unrelated property in BaseConnection.
Move it to the Postgre class.
* | ||
* @var array | ||
*/ | ||
protected $application_name = []; |
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.
Why is this an array? It seems to be a string.
In any case, add the type for new properties.
Thank you for sending this PR! We expect the following in all Pull Requests (PRs).
Important We expect all code changes or bug-fixes to be accompanied by one or more tests added to our test suite to prove the code works. If pull requests do not comply with the above, they will likely be closed. Since we are a team of volunteers, we don't have any more time to work on the framework than you do. Please make it as painless for your contributions to be included as possible. See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/pull_request.md |
Important We expect all code changes or bug-fixes to be accompanied by one or more tests This PR does not have the necessary test code. If you want this PR to be reviewed, please add the test code. If the test is not added, this PR will be closed. |
Description
PostgreSQL has application_name support and its implemented.
Checklist: