Skip to content
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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

myalcin81
Copy link

Description
PostgreSQL has application_name support and its implemented.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

@myalcin81 myalcin81 changed the title PostgreSQL application_name support in DSN feat: PostgreSQL application_name support in DSN May 4, 2024
@myalcin81 myalcin81 changed the title feat: PostgreSQL application_name support in DSN feat: add support for PostgreSQL application_name in DSN May 4, 2024
@ddevsr ddevsr added tests needed Pull requests that need tests docs needed Pull requests needing documentation write-ups and/or revisions. wrong branch PRs sent to wrong branch labels May 5, 2024
@kenjis kenjis added the database Issues or pull requests that affect the database layer label May 5, 2024
@kenjis
Copy link
Member

kenjis commented May 5, 2024

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 4.6 branch.
See https://github.com/codeigniter4/CodeIgniter4/blob/develop/contributing/workflow.md#if-you-sent-to-the-wrong-branch

@@ -43,6 +43,7 @@ class Database extends Config
'failover' => [],
'port' => 3306,
'numberNative' => false,
'application_name' => '', //supported only in Postgres
Copy link
Member

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

// /**
// * 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 = [];
Copy link
Member

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 = [];
Copy link
Member

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.

@kenjis
Copy link
Member

kenjis commented May 5, 2024

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

@kenjis kenjis added the enhancement PRs that improve existing functionalities label May 5, 2024
@kenjis kenjis added the waiting for info Issues or pull requests that need further clarification from the author label Jun 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Issues or pull requests that affect the database layer docs needed Pull requests needing documentation write-ups and/or revisions. enhancement PRs that improve existing functionalities tests needed Pull requests that need tests waiting for info Issues or pull requests that need further clarification from the author wrong branch PRs sent to wrong branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants