Skip to content

Support PGAPPNAME - #1444

Merged
j-bennet merged 1 commit into
dbcli:mainfrom
crazybolillo:i1421-crazybolillo
Dec 9, 2023
Merged

j-bennet merged 1 commit into
dbcli:mainfrom
crazybolillo:i1421-crazybolillo

Conversation

@crazybolillo

@crazybolillo crazybolillo commented Dec 6, 2023 •

Copy link
Copy Markdown
Contributor

The application_name to be used when connecting to a database can now be specified as a command line argument (--application-name) or be taken directly from environment variables (PGAPPNAME). It still defaults to 'pgcli' when not specified.

Closes #1421.

Description

I added a new click option to support PGAPPNAME and created a new class member for PGCli which stores the set value. This value is then used during the connect method unless a different value was stated in **kwargs.

Checklist

  • I've added this contribution to the changelog.rst.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

@crazybolillo
crazybolillo marked this pull request as draft December 6, 2023 23:35
@crazybolillo
crazybolillo marked this pull request as draft December 6, 2023 23:35
@crazybolillo

Copy link
Copy Markdown
Contributor Author

Set as draft because I want to get some unittests in

@crazybolillo
crazybolillo marked this pull request as ready for review December 6, 2023 23:54
@crazybolillo

Copy link
Copy Markdown
Contributor Author

Added one unit test setting PGAPPNAME in the environment variables. Did not add one using the command line argument since click will treat them both the same (in theory). Let me know if there is any corrections I need to make, thanks.

@j-bennet

j-bennet commented Dec 7, 2023

Copy link
Copy Markdown
Contributor

Very nice @crazybolillo , thank you for the PR!

@j-bennet

j-bennet commented Dec 7, 2023

Copy link
Copy Markdown
Contributor

I see one of the integration tests failed:

def step_check_application_name(context):

@crazybolillo

Copy link
Copy Markdown
Contributor Author

I see one of the integration tests failed:

def step_check_application_name(context):

Yes, it seems like the default None value from click was overriding the default value for application_name on the PGCli constructor. There are other ways but I have fixed it by setting the default as 'pgcli' directly from click. Is that ok?

The application_name to be used when connecting to a database can now be
specified as a command line argument (--application-name) or be taken
directly from environment variables (PGAPPNAME). It still defaults to
'pgcli' when not specified.

Closes #1421.
@codecov-commenter

codecov-commenter commented Dec 9, 2023 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (f2156b3) 79.67% compared to head (b6cb3c1) 79.88%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1444      +/-   ##
==========================================
+ Coverage   79.67%   79.88%   +0.21%     
==========================================
  Files          25       25              
  Lines        3041     3043       +2     
==========================================
+ Hits         2423     2431       +8     
+ Misses        618      612       -6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@j-bennet

j-bennet commented Dec 9, 2023

Copy link
Copy Markdown
Contributor

Looks good now! Merging. 🍒

@j-bennet
j-bennet merged commit e2ff38d into dbcli:main Dec 9, 2023
@dhermes

dhermes commented Dec 9, 2023 •

Copy link
Copy Markdown

Amazing! Thanks @crazybolillo and @j-bennet!! 🚀

DiegoDAF added a commit to DiegoDAF/pgcli.daf that referenced this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support PGAPPNAME for setting application_name

4 participants