diff --git a/lib/active_force/active_query.rb b/lib/active_force/active_query.rb index 74d5775..458ddab 100644 --- a/lib/active_force/active_query.rb +++ b/lib/active_force/active_query.rb @@ -167,7 +167,8 @@ def raise_if_bind_arity_mismatch(expected_var_count, actual_var_count) def build_conditions_from_hash(hash) hash.map do |key, value| - applicable_predicate mappings[key], value + field = mappings.fetch(key, key&.to_s) + applicable_predicate(field, value) end end diff --git a/spec/active_force/active_query_spec.rb b/spec/active_force/active_query_spec.rb index e8d485e..361298e 100644 --- a/spec/active_force/active_query_spec.rb +++ b/spec/active_force/active_query_spec.rb @@ -296,6 +296,18 @@ end end end + + context 'when given attributes Hash with fields that do not exist on the SObject' do + it 'uses the given key in an eq condition' do + expected = 'SELECT Id FROM table_name WHERE (no_attribute = 1) AND (another_one = 2)' + expect(active_query.where(no_attribute: 1, 'another_one' => 2).to_s).to eq(expected) + end + + it 'uses the given key in an in condition' do + expected = 'SELECT Id FROM table_name WHERE (no_attribute IN (1,2))' + expect(active_query.where(no_attribute: [1, 2]).to_s).to eq(expected) + end + end end describe '#not' do