diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel.rb | 2 | ||||
-rw-r--r-- | lib/arel/table.rb | 12 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 49 |
3 files changed, 6 insertions, 57 deletions
diff --git a/lib/arel.rb b/lib/arel.rb index 2069cec7ce..e04999ed92 100644 --- a/lib/arel.rb +++ b/lib/arel.rb @@ -21,7 +21,7 @@ require 'arel/delete_manager' require 'arel/nodes' module Arel - VERSION = '7.2.0' + VERSION = '8.0.0' def self.sql raw_sql Arel::Nodes::SqlLiteral.new raw_sql diff --git a/lib/arel/table.rb b/lib/arel/table.rb index 0e7214f269..3e06f94272 100644 --- a/lib/arel/table.rb +++ b/lib/arel/table.rb @@ -13,7 +13,6 @@ module Arel def initialize(name, as: nil, type_caster: nil) @name = name.to_s - @columns = nil @type_caster = type_caster # Sometime AR sends an :as parameter to table, to let the table know @@ -106,16 +105,5 @@ module Arel protected attr_reader :type_caster - - private - - def attributes_for columns - return nil unless columns - - columns.map do |column| - Attributes.for(column).new self, column.name.to_sym - end - end - end end diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 506b33f4b6..ad2666fb10 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -76,10 +76,6 @@ module Arel private - def schema_cache - @connection.schema_cache - end - def visit_Arel_Nodes_DeleteStatement o, collector collector << 'DELETE FROM ' collector = visit o.relation, collector @@ -170,24 +166,6 @@ module Arel collector << "FALSE" end - def table_exists? name - schema_cache.data_source_exists?(name) - end - - def column_for attr - return unless attr - name = attr.name.to_s - table = attr.relation.table_name - - return nil unless table_exists? table - - column_cache(table)[name] - end - - def column_cache(table) - schema_cache.columns_hash(table) - end - def visit_Arel_Nodes_Values o, collector collector << "VALUES (" @@ -197,7 +175,7 @@ module Arel when Nodes::SqlLiteral, Nodes::BindParam collector = visit value, collector else - collector << quote(value, attr && column_for(attr)).to_s + collector << quote(value).to_s end unless i == len collector << COMMA @@ -653,7 +631,7 @@ module Arel else collector = visit o.left, collector collector << " = " - collector << quote(o.right, column_for(o.left)).to_s + collector << quote(o.right).to_s end end @@ -749,7 +727,7 @@ module Arel if a && a.able_to_type_cast? quote(a.type_cast_for_database(o)) else - quote(o, column_for(a)) + quote(o) end end @@ -793,12 +771,9 @@ module Arel end alias :visit_Set :visit_Array - def quote value, column = nil + def quote value return value if Arel::Nodes::SqlLiteral === value - if column - print_type_cast_deprecation - end - @connection.quote value, column + @connection.quote value end def quote_table_name name @@ -847,20 +822,6 @@ module Arel collector end end - - def print_type_cast_deprecation - unless defined?($arel_silence_type_casting_deprecation) && $arel_silence_type_casting_deprecation - warn <<-eowarn -Arel performing automatic type casting is deprecated, and will be removed in Arel 8.0. If you are seeing this, it is because you are manually passing a value to an Arel predicate, and the `Arel::Table` object was constructed manually. The easiest way to remove this warning is to use an `Arel::Table` object returned from calling `arel_table` on an ActiveRecord::Base subclass. - -If you're certain the value is already of the right type, change `attribute.eq(value)` to `attribute.eq(Arel::Nodes::Quoted.new(value))` (you will be able to remove that in Arel 8.0, it is only required to silence this deprecation warning). - -You can also silence this warning globally by setting `$arel_silence_type_casting_deprecation` to `true`. (Do NOT do this if you are a library author) - -If you are passing user input to a predicate, you must either give an appropriate type caster object to the `Arel::Table`, or manually cast the value before passing it to Arel. - eowarn - end - end end end end |