From d53b259a29e77a60a02e9c219661e19ef62ef9aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20B=C3=BChmann?= Date: Thu, 22 Feb 2018 14:26:42 +0100 Subject: Properly escape column name embedded into regexp SQLServerAdapter (gem `activerecord-sqlserver-adapter`) uses square brackets for quoting column names (e.g. `[id]`). Those brackets must not be misinterpreted in regular expressions. Failure: Expected /SELECT [developers].[id].* FROM developers/ to match "SELECT [developers].[id], [developers].[name], [developers].[salary], [developers].[firm_id], [developers].[mentor_id], [developers].[created_at], [developers].[updated_at], [developers].[created_on], [developers].[updated_on] FROM developers". --- activerecord/test/cases/base_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord') diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 983a3d366a..7dfb05a6a5 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -1501,7 +1501,7 @@ class BasicsTest < ActiveRecord::TestCase query = Developer.from("developers").to_sql quoted_id = "#{Developer.quoted_table_name}.#{Developer.quoted_primary_key}" - assert_match(/SELECT #{quoted_id}.* FROM developers/, query) + assert_match(/SELECT #{Regexp.escape(quoted_id)}.* FROM developers/, query) end test "using table name qualified column names unless having SELECT list explicitly" do -- cgit v1.2.3