Fix: scope to_arrow / each_record_batch to ADBC connections - #21
Conversation
`ActiveRecord::Relation` and called `ActiveRecordADBCAdapter::Result#attach_model` on whatever the query returned. For a model backed by Postgres, MySQL, or SQLite3 that result is a vanilla `ActiveRecord::Result`, which has no `attach_model`, so `to_arrow` blew up: NoMethodError: undefined method `attach_model' for an instance of ActiveRecord::Result Both methods now check the model's connection. ADBC keeps the fast path. Anything else calls `super`, so `red-arrow-activerecord` can take over if it's loaded; otherwise you get a `NoMethodError` that actually names the problem. Module is `prepend`ed instead of `include`d so the guard wins method lookup whichever order the gems get required in. Signed-off-by: Dmytro Piliugin <dmytro.piliugin@gmail.com>
|
I can understand your concern but when/why do you call |
|
From there, So any code that checks Once delegated globally, the gem owns the behavior on models it doesn't. |
Fix GH-21 Reported by Dmytro Piliugin. Thanks!!!
Summary
to_arrowandeach_record_batchwere leaking onto everyActiveRecord::Relation. Any model not backed by ADBC crashed withNoMethodError: undefined method 'attach_model' for an instance of ActiveRecord::Result. That made this gem unsafe to drop into a RailsBoth methods now check the model's connection. ADBC keeps the fast
path. Anything else calls
super, sored-arrow-activerecordcantake over if it's loaded; otherwise you get a
NoMethodErrorthatactually names the problem instead of an
attach_modeltraceback.The module is
prepended instead ofincluded, so the guard winsmethod lookup whichever order the gems get required in.