Hello, it looks like the relation #to_a returns an empty array when you try to wrap an association with nil…
> conditions
=> {:schedule_id=>nil}
> schedule_elements.where(conditions).to_a
=> [{:created_at=>2022-08-08 12:17:41 -0400, :updated_at=>2022-08-08 12:17:41 -0400, :id=>35, :schedule_id=>nil, :event_id=>8, :temporal_expression_id=>11, :temporal_expression_type=>"RangeEachYear"}]
Here event gets wrapped correctly:
> schedule_elements.wrap(:event).by_pk(35).to_a
=> [{:created_at=>2022-08-08 12:17:41 -0400,
:updated_at=>2022-08-08 12:17:41 -0400,
:id=>35,
:schedule_id=>nil,
:event_id=>8,
:temporal_expression_id=>11,
:temporal_expression_type=>"RangeEachYear",
:event=>
{:effective_at=>#<DateTime: 2022-08-08T08:17:41-04:00 ((2459800j,44261s,0n),-14400s,2299161j)>,
:effective_until=>#<DateTime: 2022-08-08T08:17:41-04:00 ((2459800j,44261s,0n),-14400s,2299161j)>,
:created_at=>2022-08-08 12:17:41 -0400,
:updated_at=>2022-08-08 12:17:41 -0400,
:id=>8,
:name=>"event"}}]
Here schedule causes empty array to be returned:
> schedule_elements.wrap(:schedule).by_pk(35).to_a
=> []
I expect an array with one element in it which has a schedule key with a value of nil.
Please advise. (ROM::SQL::Wrap)
Many Thanks!