-
Notifications
You must be signed in to change notification settings - Fork 6
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
fixing rethinkdb library #1113
Conversation
There was a problem hiding this 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
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]) |
There was a problem hiding this comment.
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.
except rethinkdb.errors.ReqlQueryLogicError: | ||
self._columns = [] |
There was a problem hiding this comment.
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.
except rethinkdb.errors.ReqlQueryLogicError: | |
self._columns = [] | |
except rethinkdb.errors.ReqlQueryLogicError as e: | |
logging.error(f"ReQL query logic error: {e}") | |
self._columns = [] |
except NoDataFound: | ||
raise |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
fetch_row = fetch_one | |
# Alias for fetch_one to improve code readability | |
fetch_row = fetch_one |
if _filter: | ||
data = await self._engine.table(table).get_all(_filter).get(idx).run(self._connection) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
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. | |
""" |
No description provided.