Skip to content

Comments

Fix relation direction creation with merge and create, fixes #3326#3353

Merged
robfrank merged 1 commit intoArcadeData:mainfrom
ExtReMLapin:gerge_direction_fix
Feb 5, 2026
Merged

Fix relation direction creation with merge and create, fixes #3326#3353
robfrank merged 1 commit intoArcadeData:mainfrom
ExtReMLapin:gerge_direction_fix

Conversation

@ExtReMLapin
Copy link
Contributor

fixes #3326

All cypher tests passes, didn't write any test for them, feel free to add them

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ExtReMLapin, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request fixes a bug where relationship direction was not correctly handled during MERGE and CREATE operations in Cypher queries. The fix ensures that when an incoming relationship (IN direction) is specified, the correct vertices are assigned as the source and target of the edge, resolving issue #3326.

Highlights

  • Bug Fix: Addresses issue Cypher : relations are always created left to right even if arrow is going from right to left #3326 related to incorrect directionality when creating relationships using MERGE and CREATE statements in Cypher queries.
  • Direction Handling: The code now correctly handles the IN direction for relationships in both CreateStep and MergeStep, ensuring that the fromVertex and toVertex are assigned appropriately based on the relationship direction.
  • Code Modification: The changes involve adding a check for relPattern.getDirection() and swapping fromVertex and toVertex accordingly when the direction is IN.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/CreateStep.java
    • Imported Direction class from com.arcadedb.query.opencypher.ast.
    • Modified createPath method to handle IN direction for relationships, swapping fromVertex and toVertex accordingly.
  • engine/src/main/java/com/arcadedb/query/opencypher/executor/steps/MergeStep.java
    • Imported Direction class from com.arcadedb.query.opencypher.ast.
    • Modified mergePath method to handle IN direction for relationships, swapping fromVertex and toVertex accordingly.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly addresses issue #3326 by handling relationship direction in CREATE and MERGE operations. The logic for swapping from and to vertices for incoming relationships is correct.

However, I have two suggestions for improvement:

  • Testing: As you noted in the description, tests are missing. It is important to add regression tests to OpenCypherCreateTest.java and OpenCypherMergeTest.java to verify the fix for incoming relationship directions and prevent future regressions. A test case could involve creating/merging a pattern like (a)<-[:REL]-(b) and asserting that the edge is created from b to a.
  • Code Duplication: The logic to determine the from and to vertices is duplicated across CreateStep.java and MergeStep.java. I've left a comment with a suggestion to refactor this.

Addressing these points will make the contribution even stronger.

Comment on lines +209 to +218
final Vertex fromVertex;
final Vertex toVertex;

if (relPattern.getDirection() == Direction.IN) {
fromVertex = vertices.get(i + 1);
toVertex = vertices.get(i);
} else {
fromVertex = vertices.get(i);
toVertex = vertices.get(i + 1);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This logic for determining fromVertex and toVertex is duplicated in MergeStep.java (lines 282-291). To adhere to the DRY (Don't Repeat Yourself) principle and improve maintainability, please consider extracting this logic into a common helper method that can be used by both CreateStep and MergeStep.

@robfrank robfrank added this to the 26.2.1 milestone Feb 5, 2026
@codecov
Copy link

codecov bot commented Feb 5, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.94%. Comparing base (d6cbc10) to head (3bbc685).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...db/query/opencypher/executor/steps/CreateStep.java 40.00% 2 Missing and 1 partial ⚠️
...edb/query/opencypher/executor/steps/MergeStep.java 40.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3353      +/-   ##
==========================================
- Coverage   56.97%   56.94%   -0.03%     
==========================================
  Files        1368     1368              
  Lines      100624   100630       +6     
  Branches    20490    20492       +2     
==========================================
- Hits        57326    57303      -23     
- Misses      34205    34223      +18     
- Partials     9093     9104      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mergify
Copy link
Contributor

mergify bot commented Feb 5, 2026

🧪 CI Insights

Here's what we observed from your CI run for 3bbc685.

🟢 All jobs passed!

But CI Insights is watching 👀

Nenzyz pushed a commit to Nenzyz/arcadedb that referenced this pull request Feb 5, 2026
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 4.31.9 to 4.31.10.
Release notes

*Sourced from [github/codeql-action's releases](https://github.com/github/codeql-action/releases).*

> v4.31.10
> --------
>
> CodeQL Action Changelog
> =======================
>
> See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
>
> 4.31.10 - 12 Jan 2026
> ---------------------
>
> * Update default CodeQL bundle version to 2.23.9. [ArcadeData#3393](https://redirect.github.com/github/codeql-action/pull/3393)
>
> See the full [CHANGELOG.md](https://github.com/github/codeql-action/blob/v4.31.10/CHANGELOG.md) for more information.


Changelog

*Sourced from [github/codeql-action's changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md).*

> CodeQL Action Changelog
> =======================
>
> See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
>
> [UNRELEASED]
> ------------
>
> No user facing changes.
>
> 4.31.10 - 12 Jan 2026
> ---------------------
>
> * Update default CodeQL bundle version to 2.23.9. [ArcadeData#3393](https://redirect.github.com/github/codeql-action/pull/3393)
>
> 4.31.9 - 16 Dec 2025
> --------------------
>
> No user facing changes.
>
> 4.31.8 - 11 Dec 2025
> --------------------
>
> * Update default CodeQL bundle version to 2.23.8. [ArcadeData#3354](https://redirect.github.com/github/codeql-action/pull/3354)
>
> 4.31.7 - 05 Dec 2025
> --------------------
>
> * Update default CodeQL bundle version to 2.23.7. [ArcadeData#3343](https://redirect.github.com/github/codeql-action/pull/3343)
>
> 4.31.6 - 01 Dec 2025
> --------------------
>
> No user facing changes.
>
> 4.31.5 - 24 Nov 2025
> --------------------
>
> * Update default CodeQL bundle version to 2.23.6. [ArcadeData#3321](https://redirect.github.com/github/codeql-action/pull/3321)
>
> 4.31.4 - 18 Nov 2025
> --------------------
>
> No user facing changes.
>
> 4.31.3 - 13 Nov 2025
> --------------------
>
> * CodeQL Action v3 will be deprecated in December 2026. The Action now logs a warning for customers who are running v3 but could be running v4. For more information, see [Upcoming deprecation of CodeQL Action v3](https://github.blog/changelog/2025-10-28-upcoming-deprecation-of-codeql-action-v3/).
> * Update default CodeQL bundle version to 2.23.5. [ArcadeData#3288](https://redirect.github.com/github/codeql-action/pull/3288)
>
> 4.31.2 - 30 Oct 2025
> --------------------
>
> No user facing changes.
>
> 4.31.1 - 30 Oct 2025
> --------------------
>
> * The `add-snippets` input has been removed from the `analyze` action. This input has been deprecated since CodeQL Action 3.26.4 in August 2024 when this removal was announced.
>
> 4.31.0 - 24 Oct 2025
> --------------------

... (truncated)


Commits

* [`cdefb33`](github/codeql-action@cdefb33) Merge pull request [ArcadeData#3394](https://redirect.github.com/github/codeql-action/issues/3394) from github/update-v4.31.10-0fa411efd
* [`cfa77c6`](github/codeql-action@cfa77c6) Update changelog for v4.31.10
* [`0fa411e`](github/codeql-action@0fa411e) Merge pull request [ArcadeData#3393](https://redirect.github.com/github/codeql-action/issues/3393) from github/update-bundle/codeql-bundle-v2.23.9
* [`c284324`](github/codeql-action@c284324) Add changelog note
* [`83e7d00`](github/codeql-action@83e7d00) Update default bundle to codeql-bundle-v2.23.9
* [`f6a16be`](github/codeql-action@f6a16be) Merge pull request [ArcadeData#3391](https://redirect.github.com/github/codeql-action/issues/3391) from github/dependabot/npm\_and\_yarn/npm-minor-f1cdf5...
* [`c1f5f1a`](github/codeql-action@c1f5f1a) Rebuild
* [`1805d8d`](github/codeql-action@1805d8d) Bump the npm-minor group with 2 updates
* [`b2951d2`](github/codeql-action@b2951d2) Merge pull request [ArcadeData#3353](https://redirect.github.com/github/codeql-action/issues/3353) from github/kaspersv/bump-min-cli-v-for-overlay
* [`41448d9`](github/codeql-action@41448d9) Merge pull request [ArcadeData#3287](https://redirect.github.com/github/codeql-action/issues/3287) from github/henrymercer/generate-mergeback-last
* Additional commits viewable in [compare view](github/codeql-action@5d4e8d1...cdefb33)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=github/codeql-action&package-manager=github\_actions&previous-version=4.31.9&new-version=4.31.10)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
@robfrank robfrank merged commit 0fd7142 into ArcadeData:main Feb 5, 2026
15 of 20 checks passed
robfrank pushed a commit that referenced this pull request Feb 17, 2026
…3353)

Co-authored-by: CNE Pierre FICHEPOIL <pierre-1.fichepoil@gendarmerie.interieur.gouv.fr>
(cherry picked from commit 0fd7142)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cypher : relations are always created left to right even if arrow is going from right to left

2 participants