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

fixing rethinkdb library #1113

Merged
merged 1 commit into from
May 28, 2024
Merged

fixing rethinkdb library #1113

merged 1 commit into from
May 28, 2024

Conversation

phenobarbital
Copy link
Owner

No description provided.

@phenobarbital phenobarbital merged commit 1380b5a into master May 28, 2024
2 checks passed
@phenobarbital phenobarbital deleted the refactor-2.7-scylladb branch May 28, 2024 23:30
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @phenobarbital - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Potential issue with accessing row elements. (link)
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue, 5 other issues
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

idx = []
for f in fields:
idx.append(self._engine.row(f))
idx.append(self._engine.row[f])
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Potential issue with accessing row elements.

Using self._engine.row[f] instead of self._engine.row(f) might cause issues if self._engine.row is not subscriptable. Ensure that self._engine.row supports this operation.

Comment on lines +359 to +360
except rethinkdb.errors.ReqlQueryLogicError:
self._columns = []
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Handling specific exceptions.

Catching rethinkdb.errors.ReqlQueryLogicError is good, but consider logging the error for better debugging and traceability.

Suggested change
except rethinkdb.errors.ReqlQueryLogicError:
self._columns = []
except rethinkdb.errors.ReqlQueryLogicError as e:
logging.error(f"ReQL query logic error: {e}")
self._columns = []

Comment on lines +386 to +387
except NoDataFound:
raise
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: Redundant exception handling.

The except NoDataFound: raise block is redundant as it simply re-raises the exception. Consider removing it.

except rethinkdb.errors.ReqlPermissionError as err:
raise DataError(f"Permission error over {table}: {err}") from err
except ReqlRuntimeError as err:
raise DriverError(f"Runtime Error: {err}") from err
except Exception as err: # pylint: disable=W0703
raise DriverError(f"Unknown RT error: {err}") from err


fetch_row = fetch_one
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Alias creation for fetch_one.

Creating an alias fetch_row for fetch_one is fine, but ensure this alias is documented and used consistently throughout the codebase.

Suggested change
fetch_row = fetch_one
# Alias for fetch_one to improve code readability
fetch_row = fetch_one

Comment on lines +570 to +571
if _filter:
data = await self._engine.table(table).get_all(_filter).get(idx).run(self._connection)
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): Potential misuse of get_all with filter.

Using get_all with _filter and then get(idx) might not work as expected. Ensure that _filter is a valid argument for get_all and that chaining get(idx) is correct.

@@ -254,11 +254,29 @@ async def test_connect(event_loop):
await conn.drop_database('testing')


async def create_rethink_table(event_loop):
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Missing docstring for new function.

Consider adding a docstring to the create_rethink_table function to describe its purpose and parameters.

Suggested change
async def create_rethink_table(event_loop):
async def create_rethink_table(event_loop):
"""
Create a RethinkDB table using the provided event loop.
Args:
event_loop: The event loop to use for asynchronous operations.
"""

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.

1 participant