title: Use or clause within where.not
body: <p>I'm stuck trying to upgrade a Rails 5 application to Rails 6 and remove some raw SQL in the process.</p>
  <p>I have already managed to convert the raw SQL LEFT JOINs into ActiveRecord notation. Unfortunately, I am just failing with the OR-conditions within the where-clauses.</p>
  <p>Old Code:</p>
  <pre><code>::Tyre::Entry.joins(&quot; LEFT JOIN `core_manufacturers` ON `core_manufacturers`.`id` = `tyre_entries`.`core_manufacturer_id`
                        LEFT JOIN `tyre_designs` ON `tyre_designs`.`id` = `tyre_entries`.`tyre_design_id`
                        LEFT JOIN `tyre_dimensions` ON `tyre_dimensions`.`id` = `tyre_entries`.`tyre_dimension_id`
                        LEFT JOIN `tyre_seasons` ON `tyre_seasons`.`id` = `tyre_entries`.`tyre_season_id`
                        LEFT JOIN `tyre_usages` ON `tyre_usages`.`id` = `tyre_entries`.`tyre_usage_id`
                        LEFT JOIN `tyre_market_segments` ON `tyre_market_segments`.`id` = `tyre_entries`.`tyre_market_segment_id`&quot;)
                     .where(&quot;core_manufacturers.id IS NULL OR
                            tyre_designs.id IS NULL OR
                            tyre_dimensions.id IS NULL OR
                            tyre_seasons.id IS NULL OR
                            tyre_usages.id IS NULL OR
                            tyre_market_segments.id IS NULL &quot;)
  
  </code></pre>
  <p>Code I created so far:</p>
  <pre><code>::Tyre::Entry.left_outer_joins(:manufacturer, :design, :dimension, :season, :usage, :market_segment)
               .where.not(core_manufacturers: { id: nil },
                                tyre_designs: { id: nil },
                                tyre_dimensions: { id: nil },
                                tyre_seasons: { id: nil },
                                tyre_usages: { id: nil },
                                tyre_market_segments: { id: nil })
  </code></pre>
  <p>The problem is that in this way where-conditions are linked with AND, which should actually be OR.</p>
  <p>I know the following code snippet does not work but is there a way to make it work in this short notation?</p>
  <pre><code>::Tyre::Entry.left_outer_joins(:manufacturer, :design, :dimension, :season, :usage, :market_segment)
               .where.not(core_manufacturers: { id: nil }, or
                                tyre_designs: { id: nil }, or
                                tyre_dimensions: { id: nil }, or
                                tyre_seasons: { id: nil }, or
                                tyre_usages: { id: nil }, or
                                tyre_market_segments: { id: nil })
  </code></pre>