提交 aff73e09 编写于 作者: S Sean Griffin

Remove AR Properties from the public API

Making this part of the public API was premature, let's make it private
again while I continue to work on the surrounding code.
上级 52434e9a
...@@ -6,12 +6,6 @@ ...@@ -6,12 +6,6 @@
*arthurnn* *arthurnn*
* Add a properties API to allow custom types and type casting behavior
to be specified. Will enable many edge cases to be deprecated, and
allow for additional interesting features in the future.
*Sean Griffin*
* Fix has_and_belongs_to_many public reflection. * Fix has_and_belongs_to_many public reflection.
When defining a has_and_belongs_to_many, internally we convert that to two has_many. When defining a has_and_belongs_to_many, internally we convert that to two has_many.
But as `reflections` is a public API, people expect to see the right macro. But as `reflections` is a public API, people expect to see the right macro.
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Binary < Value class Binary < Value # :nodoc:
def type def type
:binary :binary
end end
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Boolean < Value class Boolean < Value # :nodoc:
def type def type
:boolean :boolean
end end
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Date < Value class Date < Value # :nodoc:
def type def type
:date :date
end end
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class DateTime < Value class DateTime < Value # :nodoc:
include TimeValue include TimeValue
def type def type
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Decimal < Value class Decimal < Value # :nodoc:
include Numeric include Numeric
def type def type
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Float < Value class Float < Value # :nodoc:
include Numeric include Numeric
def type def type
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Integer < Value class Integer < Value # :nodoc:
include Numeric include Numeric
def type def type
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class String < Value class String < Value # :nodoc:
def type def type
:string :string
end end
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Text < String class Text < String # :nodoc:
def type def type
:text :text
end end
......
module ActiveRecord module ActiveRecord
module ConnectionAdapters module ConnectionAdapters
module Type module Type
class Value class Value # :nodoc:
attr_reader :precision, :scale, :limit attr_reader :precision, :scale, :limit
# Valid options are +precision+, +scale+, and +limit+. # Valid options are +precision+, +scale+, and +limit+.
......
module ActiveRecord module ActiveRecord
module Properties module Properties # :nodoc:
extend ActiveSupport::Concern extend ActiveSupport::Concern
Type = ConnectionAdapters::Type Type = ConnectionAdapters::Type
...@@ -64,19 +64,7 @@ def property(name, cast_type) ...@@ -64,19 +64,7 @@ def property(name, cast_type)
# Returns an array of column objects for the table associated with this class. # Returns an array of column objects for the table associated with this class.
def columns def columns
@columns ||= add_user_provided_columns(connection.schema_cache.columns(table_name)).each do |column| @columns ||= add_user_provided_columns(connection.schema_cache.columns(table_name))
if Type::DecimalWithoutScale === column.cast_type
ActiveSupport::Deprecation.warn <<-MESSAGE.strip_heredoc
Decimal columns with 0 scale being automatically treated as integers
is deprecated, and will be removed in a future version of Rails. If
you'd like to keep this behavior, add
property :#{column.name}, Type::Integer.new
to your #{name} model.
MESSAGE
end
end
end end
# Returns a hash of column objects for the table associated with this class. # Returns a hash of column objects for the table associated with this class.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册