diff --git a/lib/query_helper/sql_parser.rb b/lib/query_helper/sql_parser.rb index bd8bbde..48142dc 100644 --- a/lib/query_helper/sql_parser.rb +++ b/lib/query_helper/sql_parser.rb @@ -18,8 +18,9 @@ def update(sql) def remove_comments # Remove SQL inline comments (/* */) and line comments (--) - @sql = @sql.gsub(%r{/\*.*?\*/}m, '') # Removes multi-line comments (/* ... */) - .gsub(/--[^\n]*$/, '') # Removes single-line comments (-- ... until end of line) + @sql = @sql.gsub(%r{/\*[^/]*?\*/}m, '') # Removes multi-line comments (/* ... */) + .gsub(/--[^\n]*/, '') # Removes single-line comments (--) + @sql.squish! end