mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #15374 from sgrif/sg-private-properties
Remove AR Properties from the public API
This commit is contained in:
commit
7f73b9152c
12 changed files with 12 additions and 30 deletions
|
@ -10,12 +10,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.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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 @@ require 'active_record/connection_adapters/type/string'
|
||||||
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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
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+.
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
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 @@ module ActiveRecord
|
||||||
|
|
||||||
# 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.
|
||||||
|
|
Loading…
Reference in a new issue