mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #38338 from lcreid/fix-tablename-detection-for-mssql
Regexp-escape table name for MS SQL
This commit is contained in:
commit
53d94ddef2
2 changed files with 9 additions and 1 deletions
|
@ -1,3 +1,9 @@
|
|||
* Regexp-escape table name for MS SQL
|
||||
|
||||
Add `Regexp.escape` to one method in ActiveRecord, so that table names with regular expression characters in them work as expected. Since MS SQL Server uses "[" and "]" to quote table and column names, and those characters are regular expression characters, methods like `pluck` and `select` fail in certain cases when used with the MS SQL Server adapter.
|
||||
|
||||
*Larry Reid*
|
||||
|
||||
* Store advisory locks on their own named connection.
|
||||
|
||||
Previously advisory locks were taken out against a connection when a migration started. This works fine in single database applications but doesn't work well when migrations need to open new connections which results in the lock getting dropped.
|
||||
|
|
|
@ -1253,7 +1253,9 @@ module ActiveRecord
|
|||
end
|
||||
|
||||
def table_name_matches?(from)
|
||||
/(?:\A|(?<!FROM)\s)(?:\b#{table.name}\b|#{connection.quote_table_name(table.name)})(?!\.)/i.match?(from.to_s)
|
||||
table_name = Regexp.escape(table.name)
|
||||
quoted_table_name = Regexp.escape(connection.quote_table_name(table.name))
|
||||
/(?:\A|(?<!FROM)\s)(?:\b#{table_name}\b|#{quoted_table_name})(?!\.)/i.match?(from.to_s)
|
||||
end
|
||||
|
||||
def reverse_sql_order(order_query)
|
||||
|
|
Loading…
Reference in a new issue