Skip to content

Conversation

@aidanharan
Copy link
Contributor

@aidanharan aidanharan commented Mar 24, 2020

Fixes the failing activerecord/test/cases/relations_test.rb tests. The tests were failing because table names in the SQL Server adapter use square brackets. The table names were then being used in a regular expression without first being regex escaped causing the regex not to work as expected. This PR escapes the table name in the regex.

Table name not suitable for regex:

connection.quote_table_name(table.name) 
=> "[comments]"

Table name suitable for regex:

Regexp.escape(connection.quote_table_name(table.name))
=> "\\[comments\\]"

@aidanharan
Copy link
Contributor Author

Just found that @lcreid has already fixed this issue in Rails #722

In this PR I've taken the method from Rails master and patched the adapter so that the relations tests pass for Rails 5.2.4.x

@lcreid
Copy link
Contributor

lcreid commented Mar 26, 2020

Thanks, @aidanharan . I was going to ask that the Rails fix be back-ported, but this is much faster.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants