Skip to content

Commit

Permalink
Revert changes to regex.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksandr Movchan committed Dec 20, 2024
1 parent 922c6a2 commit 3c4cbc0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion aana/storage/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def compile_insert(insert_stmt, compiler, **kwargs):
# Locate the VALUES clause and replace it
def replace_values_with_select(sql):
# Regex to find `VALUES (...)` ensuring balanced parentheses
pattern = r"VALUES\s*\(((?:[^()]+|\([^()]*\))*)\)"
pattern = r"VALUES\s*(\((?:[^)(]+|\((?:[^)(]+|\([^)(]*\))*\))*\))"

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with 'VALUES(' and containing many repetitions of '''.

Check failure

Code scanning / CodeQL

Inefficient regular expression High

This part of the regular expression may cause exponential backtracking on strings starting with 'VALUES((' and containing many repetitions of '''.
match = re.search(pattern, sql)
if match:
values_clause = match.group(1) # Captures the `(...)` after VALUES
Expand Down

0 comments on commit 3c4cbc0

Please sign in to comment.