mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Use the model's adapter for the attribute type lookup
This commit is contained in:
parent
7da834fdda
commit
3b600a3fb6
2 changed files with 8 additions and 2 deletions
|
@ -247,7 +247,8 @@ module ActiveRecord
|
|||
super
|
||||
attributes_to_define_after_schema_loads.each do |name, (type, options)|
|
||||
if type.is_a?(Symbol)
|
||||
type = ActiveRecord::Type.lookup(type, **options.except(:default))
|
||||
adapter_name = ActiveRecord::Type.adapter_name_from(self)
|
||||
type = ActiveRecord::Type.lookup(type, **options.except(:default), adapter: adapter_name)
|
||||
end
|
||||
|
||||
define_attribute(name, type, **options.slice(:default))
|
||||
|
|
|
@ -46,9 +46,14 @@ module ActiveRecord
|
|||
@default_value ||= Value.new
|
||||
end
|
||||
|
||||
def adapter_name_from(model) # :nodoc:
|
||||
# TODO: this shouldn't depend on a connection to the database
|
||||
model.connection.adapter_name.downcase.to_sym
|
||||
end
|
||||
|
||||
private
|
||||
def current_adapter_name
|
||||
ActiveRecord::Base.connection.adapter_name.downcase.to_sym
|
||||
adapter_name_from(ActiveRecord::Base)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue