Open mepatterson opened 5 years ago
Narrowed the source of the issue down to result.rb initialize call.
When building the map ActiveRecord::Type.registry.lookup(x.type) fails and returns ArgumentError: Unknown type :uuid.
def initialize(model, results, options = {})
@model = model
@results = results
@column_types = Hash[@model.columns.map { |x| [x.name, x] }]
# For AR 5.x capture the types from registry to use for conversion
@ar_types = defined?(ActiveRecord::Type.registry.lookup) ? Hash[@model.columns.map { |x|
[x.name, (x.type.is_a?(::Symbol) ? ActiveRecord::Type.registry.lookup(x.type) : x.type)]
}] : nil
It appears that the registry needs the adapter to find the type correctly. For postgres: Tried this directly in console and worked:
ActiveRecord::Type.registry.lookup(:uuid, adapter: :postgresql)
Possible Fix could be:
ActiveRecord::Type.registry.lookup(x.type, adapter: @model.connection_config[:adapter].to_sym)
On postgres, we use UUIDs as our primary keys. When I try to use any of the ar-ondemand methods...