Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev make apoc version aware #728

Merged
merged 3 commits into from
Feb 17, 2025
Merged

Dev make apoc version aware #728

merged 3 commits into from
Feb 17, 2025

Conversation

gem-neo4j
Copy link
Contributor

Make APOC procedures and functions react based on used Cypher Version

@gem-neo4j gem-neo4j force-pushed the dev_make_apoc_version_aware branch 2 times, most recently from 3b3dc49 to 4449e2d Compare February 5, 2025 13:20
@gem-neo4j
Copy link
Contributor Author

@gem-neo4j gem-neo4j force-pushed the dev_make_apoc_version_aware branch 5 times, most recently from edc4600 to 97aca4d Compare February 11, 2025 08:10
@gem-neo4j gem-neo4j marked this pull request as ready for review February 11, 2025 08:35
Copy link
Contributor

@loveleif loveleif left a comment

Choose a reason for hiding this comment

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

Some of the uglier sides of cypher versions really start to show themselves (not your fault though of course!). Not much else we can do at this point I guess. Thanks for doing the work :).

Comment on lines 1374 to 1376
return procedureCallContext.calledwithQueryLanguage().equals(QueryLanguage.CYPHER_5)
? "CYPHER 5 "
: "CYPHER 25 ";
Copy link
Contributor

Choose a reason for hiding this comment

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

When we release the next cypher version we will still run queries in Cypher 25, is that intentional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True true, I can make it more future safe

}

public static String getCypherVersionString(ProcedureCallContext procedureCallContext) {
return procedureCallContext.calledwithQueryLanguage().equals(QueryLanguage.CYPHER_5) ? "5" : "25";
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, will return "25" for newer versions.

private static final Pattern CYPHER_VERSION_PATTERN =
Pattern.compile("^\\s*\\b(CYPHER)(?:\\s+(\\d+))?", Pattern.CASE_INSENSITIVE);
public static final Pattern PLANNER_PATTERN =
Pattern.compile("\\bplanner\\s*=\\s*[^\\s]*", Pattern.CASE_INSENSITIVE);
public static final Pattern RUNTIME_PATTERN = Pattern.compile("\\bruntime\\s*=", Pattern.CASE_INSENSITIVE);
Copy link
Contributor

Choose a reason for hiding this comment

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

We have access to the pre-parser, so potentially we could parse it out with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we have an example of that in APOC somewhere already?

}

private static final Pattern CYPHER_VERSION_PATTERN =
Pattern.compile("^\\s*\\b(CYPHER)(?:\\s+(\\d+))?", Pattern.CASE_INSENSITIVE);
Copy link
Contributor

Choose a reason for hiding this comment

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

What's \b in regex (I actually looked it up but still do not understand...).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It makes sure that CYPHER is a single word by itself (so a string has to start with CYPHER and CYPHERS etc won't match)

Comment on lines +73 to +74
@Context
public ProcedureCallContext procedureCallContext;
Copy link
Contributor

Choose a reason for hiding this comment

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

I forgot, do ProcedureCallContext require allow unrestricted access?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it is marked as safe or whatever the terminology is :)

@gem-neo4j gem-neo4j force-pushed the dev_make_apoc_version_aware branch from 758bf72 to 23eb6b1 Compare February 17, 2025 07:45
@gem-neo4j gem-neo4j merged commit 872c646 into dev Feb 17, 2025
11 checks passed
@gem-neo4j gem-neo4j deleted the dev_make_apoc_version_aware branch February 17, 2025 08:57
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.

2 participants