diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-19 02:12:44 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2019-03-19 04:15:52 +0900 |
commit | 8072d8653a32e7719342df25eecab688ac9e39cc (patch) | |
tree | b2ee162819fc85b9bd4b2b5f16395e4a1a66c244 /activerecord/lib/arel/visitors/to_sql.rb | |
parent | 98d0f93506b0b97804d0d510ffcc435af9b2a2d5 (diff) | |
download | rails-8072d8653a32e7719342df25eecab688ac9e39cc.tar.gz rails-8072d8653a32e7719342df25eecab688ac9e39cc.tar.bz2 rails-8072d8653a32e7719342df25eecab688ac9e39cc.zip |
Extract `sanitize_as_sql_comment` from SQL visitor into connection
Probably that is useful for any other feature as well.
Diffstat (limited to 'activerecord/lib/arel/visitors/to_sql.rb')
-rw-r--r-- | activerecord/lib/arel/visitors/to_sql.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/arel/visitors/to_sql.rb b/activerecord/lib/arel/visitors/to_sql.rb index 583f920290..e44dacd0ff 100644 --- a/activerecord/lib/arel/visitors/to_sql.rb +++ b/activerecord/lib/arel/visitors/to_sql.rb @@ -219,7 +219,8 @@ module Arel # :nodoc: all end def visit_Arel_Nodes_OptimizerHints(o, collector) - collector << "/*+ #{sanitize_as_sql_comment(o).join(" ")} */" + hints = o.expr.map { |v| sanitize_as_sql_comment(v) }.join(" ") + collector << "/*+ #{hints} */" end def collect_nodes_for(nodes, collector, spacer, connector = COMMA) @@ -785,10 +786,9 @@ module Arel # :nodoc: all @connection.quote_column_name(name) end - def sanitize_as_sql_comment(o) - o.expr.map { |v| - v.gsub(%r{ (/ (?: | \g<1>) \*) \+? \s* | \s* (\* (?: | \g<2>) /) }x, "") - } + def sanitize_as_sql_comment(value) + return value if Arel::Nodes::SqlLiteral === value + @connection.sanitize_as_sql_comment(value) end def collect_optimizer_hints(o, collector) |