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
Skipped posting 4 draft comments that were valid but scored below your review threshold (>13/15). Feel free to update them here.
mindsdb_sql_parser/lexer.py (1)
335-345: t.raw_value is set for QUOTE_STRING and DQUOTE_STRING tokens, but not for ID, FLOAT, or INTEGER, causing inconsistent token attributes and potential runtime errors if downstream code expects raw_value on all tokens.
📊 Impact Scores:
Production Impact: 3/5
Fix Specificity: 5/5
Urgency Impact: 3/5
Total Score: 11/15
🤖 AI Agent Prompt (Copy & Paste Ready):
In mindsdb_sql_parser/lexer.py, lines 335-345, the token methods for ID, FLOAT, and INTEGER do not set t.raw_value, while QUOTE_STRING and DQUOTE_STRING do. This inconsistency can cause runtime errors if downstream code expects t.raw_value on all tokens. Please update the ID, FLOAT, and INTEGER methods to set t.raw_value = t.value before returning the token, matching the behavior of the string token methods.
mindsdb_sql_parser/utils.py (2)
65-66: tokens_to_string will raise an exception if tokens is empty, as it accesses tokens[0] without checking; this causes a crash for empty input.
📊 Impact Scores:
Production Impact: 4/5
Fix Specificity: 5/5
Urgency Impact: 3/5
Total Score: 12/15
🤖 AI Agent Prompt (Copy & Paste Ready):
In mindsdb_sql_parser/utils.py, lines 65-66, the function `tokens_to_string` assumes `tokens` is non-empty and accesses `tokens[0]` without checking. This will cause an exception if an empty list is passed. Add a check at the start of the function to return an empty string if `tokens` is empty.
70-95: tokens_to_string reconstructs lines by concatenating strings in a loop, which is inefficient for large token lists due to repeated string allocations (O(n^2) time complexity for long lines).
📊 Impact Scores:
Production Impact: 2/5
Fix Specificity: 5/5
Urgency Impact: 2/5
Total Score: 9/15
🤖 AI Agent Prompt (Copy & Paste Ready):
In mindsdb_sql_parser/utils.py, lines 70-95, the function `tokens_to_string` reconstructs lines by concatenating strings in a loop, which is inefficient for large token lists due to repeated string allocations (O(n^2) time complexity for long lines). Refactor this section to use a list to accumulate lines and join them at the end, minimizing string concatenation overhead. Preserve all logic and formatting.
sly/lex.py (1)
416-444: Lexer.tokenize creates a new Token object for every token, even for ignored tokens and literals, causing unnecessary object allocations and memory churn when processing large texts.
📊 Impact Scores:
Production Impact: 3/5
Fix Specificity: 4/5
Urgency Impact: 2/5
Total Score: 9/15
🤖 AI Agent Prompt (Copy & Paste Ready):
In sly/lex.py, lines 416-444, the `Lexer.tokenize` method creates a new `Token` object for every match, including ignored tokens and literals, which leads to unnecessary object allocations and memory churn when processing large texts. Refactor the code so that `Token` objects are only created for tokens that are actually yielded, skipping object creation for ignored tokens and literals. Ensure the logic and indentation remain consistent with the original code.
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
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.
There is an issue with escaping native queries. For example:
in this case query
select 'a'b'will be executed in the db.This PR keep original text for native queries
Fix CONN-1354