Skip to content

Use IN rather than = for queries using arrays - #85

Merged
seuros merged 3 commits into
seuros:masterfrom
metkat:main
Jun 25, 2026
Merged

seuros merged 3 commits into
seuros:masterfrom
metkat:main

Conversation

@metkat

@metkat metkat commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

To match Rails behavior, Model.where(key: ['a', 'b', 'c']) should look for n.key IN ['a', 'b', 'c'] rather than n.key = ['a', 'b', 'c'].

@seuros
seuros requested a review from Copilot June 25, 2026 09:26
@seuros
seuros merged commit e6a8eb6 into seuros:master Jun 25, 2026
3 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates ActiveCypher’s Relation#where behavior so Model.where(key: ['a', 'b']) generates a Cypher IN comparison (aligning with Rails-style semantics) instead of comparing a property to an array via =.

Changes:

  • Update ActiveCypher::Relation#where to emit IN when a hash condition value is an Array.
  • Add a regression test covering both scalar equality (=) and array membership (IN) query generation.
  • Add a commented-out note in ActiveCypher::Relationship (currently unrelated to the PR’s purpose).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
test/active_cypher/comparison_arrays_should_in_test.rb Adds coverage asserting where(name: [...]) renders IN and scalar where(name: ...) renders =.
lib/active_cypher/relation.rb Implements Array values in where(Hash) as IN comparisons.
lib/active_cypher/relationship.rb Adds a commented-out note/code snippet about connects_to_mappings (unrelated to query behavior).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

require 'cyrel'

module Cyrel
class ComparisonArraysShouldIn < ActiveSupport::TestCase
Comment on lines +9 to +11
alice = PersonNode.create(name: 'Alice')
bob = PersonNode.create(name: 'Bob')
charlie = PersonNode.create(name: 'Charlie')
Comment on lines +23 to +25
alice = PersonNode.create(name: 'Alice')
bob = PersonNode.create(name: 'Bob')
charlie = PersonNode.create(name: 'Charlie')
Comment on lines +32 to +33
# Define connects_to_mappings as a class attribute to match ActiveCypher::Base ?
# class_attribute :connects_to_mappings, default: { reading: :primary, writing: :primary }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants