Skip to content

Commit

Permalink
Merge pull request #508 from Shopify/shanempope-patch-1
Browse files Browse the repository at this point in the history
Create a more efficient regex
  • Loading branch information
shanempope authored Oct 26, 2023
2 parents 7f19857 + 37c01ec commit ad1515c
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/semian/activerecord_trilogy_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,7 @@ def resource_exceptions
end

# TODO: share this with Mysql2
QUERY_ALLOWLIST = Regexp.union(
%r{\A(?:/\*.*?\*/)?\s*ROLLBACK}i,
%r{\A(?:/\*.*?\*/)?\s*COMMIT}i,
%r{\A(?:/\*.*?\*/)?\s*RELEASE\s+SAVEPOINT}i,
)
QUERY_ALLOWLIST = %r{\A(?:/\*.*?\*/)?\s*(ROLLBACK|COMMIT|RELEASE\s+SAVEPOINT)}i

def query_allowlisted?(sql, *)
QUERY_ALLOWLIST.match?(sql)
Expand Down

0 comments on commit ad1515c

Please sign in to comment.