Faveod / arel-extensions

Extending Arel
MIT License
142 stars 24 forks source link

ActiveRecord `or` broken #42

Closed fdutey closed 3 years ago

fdutey commented 3 years ago

Adding this gem breaks ActiveRelation or method. Scopes are evaluated too early

Example

table = Model.arel_table
col_a = table[:col_a]
col_b = table[:col_b]

Model.where(
  col_a.eq(1)
).or(
  Model.where(
    col_b.eq(1)
  )
)

Before: the request is triggered after the or (so SQL is col_a = 1 OR col_b = 1) Now: the request is triggered before the or (so SQL is col_a = 1)

jdelporte commented 3 years ago

Hi Florian, Thanks for your contribution. The gem 2.0.22 should fix this issue.

fdutey commented 3 years ago

Works like a charm.

Thank you so much! ;)