<commit_before># frozen_string_literal: true

require "cases/helper"
require "models/author"
require "models/categorization"
require "models/post"

module ActiveRecord
  class OrTest < ActiveRecord::TestCase
    fixtures :posts
    fixtures :authors, :author_addresses

    def test_or_with_relation
      expected = Post.where("id = 1 or id = 2").to_a
      assert_equal expected, Post.where("id = 1").or(Post.where("id = 2")).to_a
    end

    def test_or_identity
      expected = Post.where("id = 1").to_a
      assert_equal expected, Post.where("id = 1").or(Post.where("id = 1")).to_a
    end

    def test_or_with_null_left
      expected = Post.where("id = 1").to_a
      assert_equal expected, Post.none.or(Post.where("id = 1")).to_a
    end

    def test_or_with_null_right
      expected = Post.where("id = 1").to_a
      assert_equal expected, Post.where("id = 1").or(Post.none).to_a
    end

    def test_or_with_bind_params
      assert_equal Post.find([1, 2]), Post.where(id: 1).or(Post.where(id: 2)).to_a
    end

    def test_or_with_null_both<commit_msg>Address random `test_or_with_bind_params` failures<commit_after># frozen_string_literal: true

require "cases/helper"
require "models/author"
require "models/categorization"
require "models/post"

module ActiveRecord
  class OrTest < ActiveRecord::TestCase
    fixtures :posts
    fixtures :authors, :author_addresses

    def test_or_with_relation
      expected = Post.where("id = 1 or id = 2").to_a
      assert_equal expected, Post.where("id = 1").or(Post.where("id = 2")).to_a
    end

    def test_or_identity
      expected = Post.where("id = 1").to_a
      assert_equal expected, Post.where("id = 1").or(Post.where("id = 1")).to_a
    end

    def test_or_with_null_left
      expected = Post.where("id = 1").to_a
      assert_equal expected, Post.none.or(Post.where("id = 1")).to_a
    end

    def test_or_with_null_right
      expected = Post.where("id = 1").to_a
      assert_equal expected, Post.where("id = 1").or(Post.none).to_a
    end

    def test_or_with_bind_params
      assert_equal Post.find([1, 2]).sort_by(&:id), Post.where(id: 1).or(Post.where(id: 2)).sort_by(&:id)
    end

    def test_or_with_null_both
{'fraction_non_alphanumeric': 0.12670299727520437, 'fraction_numerical': 0.013623978201634877, 'mean_word_length': 3.5236139630390144, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6529700', 'n_tokens_mistral': 799, 'n_tokens_neox': 758, 'n_words': 156}