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

change Math operator to support unary operations, move outside string… #2971

Closed

Conversation

MacondoExpress
Copy link
Contributor

Add Math operators, separate string concat

Add other operators to the Math operators and separate the string.concat implementation from the math.plus.
This is a breaking change as the plus and minus are now treated as unary plus and unary minus and while the previous behavior is moved to add/subtract respectively.

Complexity

Complexity: Low

Checklist

The following requirements should have been met (depending on the changes in the branch):

  • Documentation has been updated
  • TCK tests have been updated
  • Integration tests have been updated
  • Example applications have been updated
  • New files have copyright header
  • CLA (https://neo4j.com/developer/cla/) has been signed

@changeset-bot
Copy link

changeset-bot bot commented Mar 3, 2023

🦋 Changeset detected

Latest commit: 52cfd1e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@neo4j/cypher-builder Minor
@neo4j/graphql Patch
@neo4j/graphql-toolbox Patch
@neo4j/graphql-ogm Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Mar 3, 2023

Thanks for the UI updates.

The UI has now been torn down - reopening this PR will republish it.

@neo4j-team-graphql
Copy link
Collaborator

neo4j-team-graphql commented Mar 3, 2023

Performance Report

name dbHits old dbHits time (ms) old time (ms) maxRows
🟥 query.QueryWithNestedIn 13501 12131 58 62 1602

🟥 - Performance worsened (dbHits)
🟩 - Performance improved (dbHits)
🟦 - New test

Show Full Table
name dbHits old dbHits time (ms) old time (ms) maxRows
aggregations.TopLevelAggregate 3403 3403 35 56 1134
aggregations.NestedAggregation 13514 13514 111 135 2174
aggregations.AggregationWithWhere 10942 10942 58 81 2174
aggregations.AggregationWhereWithinNestedRelationships 20101954 20101954 2528 3186 2008534
aggregations.AggregationWhereWithinNestedConnections 20101954 20101954 2497 2970 2008534
aggregations.NestedCountFromMovieToActors 8694 8694 75 115 2174
aggregations.NestedCountFromActorsToMovie 8900 8900 54 65 2174
aggregations.DeeplyNestedCount 12062294 12062298 3947 4472 2008534
batch-create.BatchCreate 3600 3600 106 115 600
connect.createAndConnect 12419 12419 259 279 3003
connections.Connection 13042 13042 278 271 2174
connections.NestedConnection 38231 38231 146 138 4516
connections.ConnectionWithSort 2277 2277 58 91 1040
connections.ConnectionWithSortAndCypher 2277 2277 152 296 1040
create.SimpleMutation 6 6 27 40 1
cypher-directive.TopLevelCypherDirective 99525 99525 660 804 10168
cypher-directive.TopLevelCypherDirectiveWithColumnName 127992 127994 215 359 10168
delete.SimpleDelete 18361 18361 245 331 1040
delete.NestedDeleteInUpdate 17123 17123 124 167 2040
query.SimpleQuery 14120 14120 132 233 2174
query.QueryWhere 8668 8675 31 55 2164
query.SimpleQueryWithNestedWhere 8839 8846 52 79 2164
query.Nested 10084290 10084290 10922 10957 2008534
query.NestedWithFilter 37172 37172 103 179 4511
query.OrFilterOnRelationships 37733 36588 146 169 2092
query.OrFilterOnRelationshipsAndNested 31666 30647 177 240 2092
🟥 query.QueryWithNestedIn 13501 12131 58 62 1602
query.NestedConnectionWhere 8794 8794 58 66 2174
query.DeeplyNestedConnectionWhere 8984 9004 71 99 2174
query.DeeplyNestedWithRelationshipFilters 6251 6251 128 208 1134
query.NestedWithRelationshipSingleFilters 3021189 3021189 576 629 1003942
query.Fulltext 96 96 25 28 16
query.FulltextWithNestedQuery 571 571 40 76 84
sorting.SortMultipleTypes 2493 2493 59 67 1040
sorting.SortMultipleTypesWithCypherWithCypher 1460 1439 149 347 1040
sorting.SortOnNestedFields 13042 13042 57 121 2174
sorting.SortDeeplyNestedFields 38965 38965 99 135 4516
sorting.SortWithTopLevelCypher 2119 2119 95 149 1040
unions.SimpleUnionQuery 321 321 78 85 35
unions.SimpleUnionQueryWithMissingFields 293 293 71 68 35
unions.NestedUnion 398553 398553 488 312 33033
unions.NestedUnionWithMissingFields 372527 372527 337 361 33033
update.NestedUpdate 2119 2119 40 47 1040

Old Schema Generation: 29.024s
Schema Generation: 29.082s

Copy link
Contributor

@darrellwarde darrellwarde left a comment

Choose a reason for hiding this comment

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

The changes look good, I just wonder whether or not this functionality should be available in the root!

@@ -71,7 +71,7 @@ describe("CypherBuilder With", () => {
});

test("With expression aliased", () => {
const expr = Cypher.plus(new Cypher.Param("The "), new Cypher.Param("Matrix"));
const expr = Cypher.append(new Cypher.Param("The "), new Cypher.Param("Matrix"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on the comment above the export, do we want to consider exporting these functions under their namespace?

Suggested change
const expr = Cypher.append(new Cypher.Param("The "), new Cypher.Param("Matrix"));
const expr = Cypher.string.concat(new Cypher.Param("The "), new Cypher.Param("Matrix"));

This would also apply to math operators:

Cypher.math.multiply(literal1, literal2);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking something the same, but I was not sure what should be exported under a different namespace and what to export from the root namespace!

Copy link
Contributor

Choose a reason for hiding this comment

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

@angrykoala, any thoughts on the above?

Copy link
Member

Choose a reason for hiding this comment

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

As discussed with @MacondoExpress

I'm quite heavily opinionated in keeping this as plain operators, we do not really have the semantic knowledge to know if a certain expression is a string or a number, meaning that we cannot really ensure that we are concatenating strings or adding numbers, which could lead to errors on the users

@angrykoala
Copy link
Member

Is this still relevant @MacondoExpress ?

@MacondoExpress
Copy link
Contributor Author

No, I'll close it in favor of this PR: #3153

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.

4 participants