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

Resolve circular dependency #787

Merged
merged 6 commits into from
Aug 28, 2023
Merged

Resolve circular dependency #787

merged 6 commits into from
Aug 28, 2023

Conversation

neelasha23
Copy link

@neelasha23 neelasha23 commented Aug 9, 2023

Describe your changes

  1. Moved the store utility functions like getting all saved snippets, finding dependents of key, etc to store_utils.py, and corresponding tests moved to test_store.py.
  2. All util functions that access current connection moved from util.py to inspect.py, and corresponding tests moved to test_inspect.py
  3. Renamed error_messages.py to error_handler.py and structured the code by adding more internal functions.
  4. Moved logic of extracting table names from query to util.py.
  5. Added functions to check if error is sqlalchemy error or not, and substring check in util.py. this is needed for the detailed error message logic.
  6. Handling of DuckDB Parser error and pyodbc.ProgrammingError added. so some of the integration tests failing previously have now been fixed.

Issue number

Closes #749 #545

Checklist before requesting a review


📚 Documentation preview 📚: https://jupysql--787.org.readthedocs.build/en/787/

@neelasha23 neelasha23 marked this pull request as ready for review August 10, 2023 17:23
@neelasha23
Copy link
Author

Please review @edublancas

@edublancas
Copy link

@neelasha23 I was about to review this but now I see that the tests are failing. what's the status? I guess there are merge conflicts due to recent changes in master?

@neelasha23
Copy link
Author

@neelasha23 I was about to review this but now I see that the tests are failing. what's the status? I guess there are merge conflicts due to recent changes in master?

Yes the snippets related tests started failing after I rebased. Fixed now. Please review.
@edublancas

@neelasha23
Copy link
Author

Please review @edublancas

Copy link

@edublancas edublancas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized that I had reviewed this before but never submitted my observations (they still appeared as "pending" but I think that means you'll never saw them), so I'm submitting them now.

there's a lot of changes in this PR so please write a brief description so I know what to expect. e.g., "moved functions from a.py, b.py, moved functions from c.py into a separate module"

i guess this is mostly moving stuff around and not adding any new stuff so please explain

CHANGELOG.md Outdated
@@ -12,6 +12,8 @@
* [Fix] `ResultSet` footer only displayed when `feedback=2`
* [Fix] Current connection and switching connections message only displayed when `feedback>=1`
* [Fix] `--persist/--persist-replace` perform `ROLLBACK` automatically when needed
* [Fix] Resolve circular dependency issue occurring due to multiple imports in `util.py`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are internal changes, we don't put those in the changelog

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CHANGELOG.md Outdated
@@ -12,6 +12,8 @@
* [Fix] `ResultSet` footer only displayed when `feedback=2`
* [Fix] Current connection and switching connections message only displayed when `feedback>=1`
* [Fix] `--persist/--persist-replace` perform `ROLLBACK` automatically when needed
* [Fix] Resolve circular dependency issue occurring due to multiple imports in `util.py`
* [Fix] Handling of DuckDB `Parser Error` and `pyodbc.ProgrammingError`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changelog is intended for end-users, please rephrase it so it's more readable for them. as they likely don't know what a parser or programming error is

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raise exceptions.UsageError(detailed_msg)
else:
print(e)
ErrorHandler(e).handle_exception()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the implementation and I don't see a need for this to be a class. lets turn this into a function (the function can internally call other functions to break the logic)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/sql/store_utils.py Show resolved Hide resolved
@@ -11,6 +11,13 @@
from sql import inspect, connection


EXPECTED_SUGGESTIONS_MESSAGE = "Did you mean :"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have an extra space before the :

Suggested change
EXPECTED_SUGGESTIONS_MESSAGE = "Did you mean :"
EXPECTED_SUGGESTIONS_MESSAGE = "Did you mean:"

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/tests/test_inspect.py Show resolved Hide resolved
src/tests/test_magic_cte.py Show resolved Hide resolved
changelog

fix

moved store

lint

added fixture

error handler

typo test

import fix

import fix

return fixed

docstrings

util test

Minor

import fix

rebase

added store_util

test

modified import
@neelasha23
Copy link
Author

Addressed your comments and updated the PR description @edublancas

@edublancas edublancas merged commit 0e9d363 into ploomber:master Aug 28, 2023
22 checks passed
@edublancas
Copy link

@neelasha23 good work!

when writing your initial comment, write each issue on a separate line:

closes #X
closes #Y

because if you do

closes #X #Y

github won't close both issues

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.

unclear logic when handling errors
2 participants