You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Previously columns parameter of def _cleaned_columns was typed as "str", but actually tuple of strings was passed from def pre_upsert.
The logic inside the function was also made for one string rather than for tuple of strings.
What is the new behavior?
The typing is changed to columns: Tuple[str, ...]
Logic inside the function is fixed. Now each column-string is cleaned out of whitespaces.
This is marked as a bug fix, which bug is this fixing? I haven't seen any issues opened about this bug. Also you would need to include tests in the PR that show the previous behavior still working while the new behavior is working too.
So after a while a discovered that multiline string are treated incorrectly due to incorrect behavior of _cleaned_columns - it treated tuple of strings as one string.
Result of running tests with new code:
(igralino/fix__cleaned_columns_func)> poetry run pytest
The "poetry.dev-dependencies" section is deprecated and will be removed in a future version. Use "poetry.group.dev.dependencies" instead.
/Users/igralino/Library/Caches/pypoetry/virtualenvs/postgrest-cqWbsz8Z-py3.12/lib/python3.12/site-packages/pytest_asyncio/plugin.py:207: PytestDeprecationWarning: The configuration option "asyncio_default_fixture_loop_scope" is unset.
The event loop scope for asynchronous fixtures will default to the fixture caching scope. Future versions of pytest-asyncio will default the loop scope for asynchronous fixtures to function scope. Set the default fixture loop scope explicitly in order to avoid unexpected behavior in the future. Valid fixture loop scopes are: "function", "class", "module", "package", "session"
warnings.warn(PytestDeprecationWarning(_DEFAULT_FIXTURE_LOOP_SCOPE_UNSET))
========================================================================================== test session starts ==========================================================================================
platform darwin -- Python 3.12.2, pytest-8.3.4, pluggy-1.5.0
rootdir: /Users/igralino/Documents/Programming/postgrest-py
configfile: pyproject.toml
plugins: cov-6.0.0, asyncio-0.25.0, anyio-4.7.0, depends-1.0.1
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=None
collected 239 items
tests/_async/test_client.py ........ [ 3%]
tests/_async/test_filter_request_builder.py ................................. [ 17%]
tests/_async/test_filter_request_builder_integration.py ..................................... [ 32%]
tests/_async/test_query_request_builder.py . [ 33%]
tests/_async/test_request_builder.py ..................................... [ 48%]
tests/_sync/test_client.py ........ [ 51%]
tests/_sync/test_filter_request_builder.py ................................. [ 65%]
tests/_sync/test_filter_request_builder_integration.py ..................................... [ 81%]
tests/_sync/test_query_request_builder.py . [ 81%]
tests/_sync/test_request_builder.py ..................................... [ 97%]
tests/test_utils.py ....... [100%]
========================================================================================== 239 passed in 3.85s ==========================================================================================
silentworks
changed the title
fix: fix _cleaned_columns function logic and typings
fix: _cleaned_columns function now works with python multiline and typings
Jan 8, 2025
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 kind of change does this PR introduce?
Bug fix
What is the current behavior?
Previously
columns
parameter ofdef _cleaned_columns
was typed as "str", but actually tuple of strings was passed fromdef pre_upsert
.The logic inside the function was also made for one string rather than for tuple of strings.
What is the new behavior?
columns: Tuple[str, ...]
Additional context
My custom made test ran without errors: