Add MySQL and Postgres port precedence tests; refactor environment variable checks#1872
Open
shaunagm wants to merge 5 commits into
Open
Add MySQL and Postgres port precedence tests; refactor environment variable checks#1872shaunagm wants to merge 5 commits into
shaunagm wants to merge 5 commits into
Conversation
…riable checks - Introduced tests for MySQL and Postgres to verify that the MYSQL_PORT and PGPORT environment variables correctly override default and explicit port settings. - Refactored database connection classes to utilize a new `check_env` utility for environment variable retrieval, enhancing error handling and code clarity. - Updated relevant imports across multiple files to support the new environment variable checking mechanism.
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Collaborator
|
Feel free to merge before #1826, any conflicts should be minimal. |
Collaborator
|
Import sorting is a |
Collaborator
Author
|
Updated my approach. It bothered me that someone passing in the default port would have it overridden, so I set the default port to None and put the default in the init code itself. So now:
Still technically a breaking change but it's so hard to imagine why someone would have their system set up in a way that this would break it so. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this change?
check_envutility for environment variable retrieval, enhancing error handling and code clarity.Considerations for discussion
Likely some merge conflicts with #1826. I can wait for that PR to merge and resolve conflicts before merging.
Breaking Changes
Details (if needed)
Technically the change in how port defaults/parameters is resolved is a breaking change. Previously, PGPORT/MYSQL_PORT env variables were effectively ignored when port wasn’t passed, because the port parameter defaults to an integer which evaluates as truthy. So
port or os.environ.get("PGPORT")always used5432even when no parameter was passed and a PG_PORT env variable was set.If anyone was relying on the default port number passed into the mysql or postgres connectors overriding an environmental variable, then they would experience a breaking change. Although it seems pretty odd that someone would set an environmental variable but rely on it being overridden? So I'm not too concerned.
But will ship this with other breaking changes and name it in the release notes just to be cautious.
EDIT: I changed my approach to be less of a breaking change. But it is still a very very slight breaking change.