<commit_before>require 'helper'

class WhereClauseTest < TestCase
  WhereClause = Riak::YzQuery::WhereClause

  context 'a WhereClause' do
    should 'merge a hash and a hash' do
      c = WhereClause.new asdf: 'jkl'
      c_merge = c.consume qwe: 'rty'
      assert_equal 'asdf:"jkl" AND qwe:"rty"', c_merge.to_yz_query
    end

    should 'merge a hash and a string' do
      c = WhereClause.new asdf: 'jkl'
      c_merge = c.consume 'qwe:rty'
      assert_equal '(asdf:"jkl") AND qwe:rty', c_merge.to_yz_query
    end

    should 'merge a string and a string' do
      c = WhereClause.new "bryce:hello"
      c_merge = c.consume "hello:to_u"
      assert_equal '(bryce:hello) AND hello:to_u', c_merge.to_yz_query
    end

    should 'escape an array into a string' do
      c = WhereClause.new ["bryce:? OR bryce:?", 'hi', 'hello']
      assert_equal 'bryce:"hi" OR bryce:"hello"', c.to_yz_query
    end
  end
end
<commit_msg>test where clause merging in reverse<commit_after>require 'helper'

class WhereClauseTest < TestCase
  WhereClause = Riak::YzQuery::WhereClause

  context 'a WhereClause' do
    should 'merge a hash and a hash' do
      c = WhereClause.new asdf: 'jkl'
      c_merge = c.consume qwe: 'rty'
      assert_equal 'asdf:"jkl" AND qwe:"rty"', c_merge.to_yz_query
    end

    should 'merge a hash and a string' do
      c = WhereClause.new asdf: 'jkl'
      c_merge = c.consume 'qwe:rty'
      assert_equal '(asdf:"jkl") AND qwe:rty', c_merge.to_yz_query
    end

    should 'merge a string and a hash' do
      c = WhereClause.new 'qwe:rty'
      c_merge = c.consume asdf: 'jkl'
      assert_equal '(qwe:rty) AND asdf:"jkl"', c_merge.to_yz_query
    end

    should 'merge a string and a string' do
      c = WhereClause.new "bryce:hello"
      c_merge = c.consume "hello:to_u"
      assert_equal '(bryce:hello) AND hello:to_u', c_merge.to_yz_query
    end

    should 'escape an array into a string' do
      c = WhereClause.new ["bryce:? OR bryce:?", 'hi', 'hello']
      assert_equal 'bryce:"hi" OR bryce:"hello"', c.to_yz_query
    end
  end
end

{'fraction_non_alphanumeric': 0.11191509889049686, 'fraction_numerical': 0.0, 'mean_word_length': 3.0587084148727985, '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': '4195800', 'n_tokens_mistral': 800, 'n_tokens_neox': 791, 'n_words': 220}