Faveod/arel-extensions

Format method breaks in Rails 7.1

Closed this issue · 1 comments

When upgrading to Rails 7.1 we started getting this error:

/usr/local/bundle/gems/arel_extensions-2.1.7/lib/arel_extensions/nodes/function.rb:54:in `type_of_attribute': undefined method `table_name' for #<Arel::Table:0x00007fb66f24fa68 @name="model_table_name", @klass=ModelName (call 'ModelName.connection' to establish a connection), @type_caster=#<ActiveRecord::TypeCaster::Map:0x00007fb6740ff168 @klass=ModelName (call 'ModelName.connection' to establish a connection)>, @table_alias=nil> (NoMethodError)

          Arel.column_of(att.relation.table_name, att.name.to_s)&.type || att
                                     ^^^^^^^^^^^
Did you mean?  table_alias

It happens for the format method on Postgres, this is the exact query:

ModelName.arel_table['timestamp'].format('%H', { 'UTC' => 'Europe/Oslo'})

#102 fixes this for me. Thank you