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

[Zl3h9sM8] apoc.schema.relationships return wrong output for relationship indexes #247

Merged
merged 3 commits into from
Nov 24, 2022

Conversation

vga91
Copy link
Collaborator

@vga91 vga91 commented Nov 18, 2022

For consistency with the apoc. schema.nodes, I put "INDEX" instead of relType.

I've put the old "type" in a new field "relationshipType", in order not to lose output info and to be consistent with "label" in schema.nodes proc (I don't know if it can be considered an additional feature).

To discuss:
In any case, maybe, in both nodes and relationships procedure, instead of get only "INDEX" we could use IndexDescriptor.getIndexType() to get a more comprehensive "FULLTEXT"/"LOOKUP"/"TEXT"/"RANGE" or "POINT".
Most likely, since it's a feature, this change could be done in another card, in case.

@vga91 vga91 added the dev label Nov 18, 2022
@vga91 vga91 force-pushed the fix_apoc.schema.rels_wrong_type_output branch from 62aa17a to 9b4b7bf Compare November 18, 2022 16:35

public IndexConstraintRelationshipInfo(String name, Object type, List<String> properties, String status) {
public IndexConstraintRelationshipInfo(String name, String type, List<String> properties, String status, Object relationshipType) {
Copy link
Contributor

Choose a reason for hiding this comment

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

can we call this constraintType then it is even less confusing, if you agree, change the one in Nodes as well :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, changing the name is a good idea, but maybe I would change the name to schemaType,
because constraintType = INDEX is personally confusing anyway.

It would seem clearer to me even if this change will be made: #247 (review)

Copy link
Contributor

Choose a reason for hiding this comment

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

ah fair enough, schemaType works better :) just internally anyway


public final List<String> properties;

public final String status;

public final Object relationshipType;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this an Object? (I see it was before as well), but is it not just a string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Because relationshipType can also be a List<String>, in case of composite indexes, e.g. in testIndexesWithMultipleLabelsAndRelTypes https://github.com/neo4j/apoc/pull/247/files/9b4b7bf4448cf27d6daff1f1bc9a9d44e23aa11e#diff-231d1cab850aaf45247b0fd9e1a64e18a8002685841df498e2098c38bedf6fb3R758

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah makes sense, thanks :)

} catch (IndexNotFoundKernelException e) {
return new IndexConstraintRelationshipInfo(
// Pretty print for index name
getSchemaInfoName(relName, properties),
relName,
"INDEX",
Copy link
Contributor

Choose a reason for hiding this comment

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

above we check: !indexDescriptor.isUnique() ? "INDEX" : "UNIQUENESS", coming very soon is new relationship constraints that allow this, does this check work here too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh you're right, I didn't remember about your card, I was referring to the current version. Updated :)

Copy link
Contributor

@gem-neo4j gem-neo4j left a comment

Choose a reason for hiding this comment

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

This looks nice overall, just a few comments! About the index type, I agree that this would be a new feature, and potentially even a breaking change, if you make a card for it, we can discuss it in refinement :)

@@ -34,18 +34,18 @@ public class IndexConstraintNodeInfo {
* @param label
* @param properties
* @param status status of the index, if it's a constraint it will be empty
* @param type if it is an index type will be "INDEX" otherwise it will be the type of constraint
* @param schemaType if it is an index type will be "INDEX" otherwise it will be the type of constraint
Copy link
Contributor

Choose a reason for hiding this comment

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

I realise now this probably changes the actual output? because we probably don't want to do that 🙈

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually not, because the output in handled by the field, so public final String type; in this case.
Now I have a doubt, is this what you meant by "internally"?
If not, I can reset it :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, you're correct! This is good then :)

@vga91 vga91 merged commit 1751fe1 into dev Nov 24, 2022
@vga91 vga91 deleted the fix_apoc.schema.rels_wrong_type_output branch November 24, 2022 18:33
vga91 added a commit to neo4j-contrib/neo4j-apoc-procedures that referenced this pull request Jan 10, 2023
…ship indexes (neo4j/apoc#247)

* [Zl3h9sM8] apoc.schema.relationships return wrong output for relationship indexes

* added getIndexType(indexDescriptor) method

* changed attr names
vga91 added a commit to neo4j-contrib/neo4j-apoc-procedures that referenced this pull request Jan 10, 2023
…ship indexes (neo4j/apoc#247) (#3395)

* [Zl3h9sM8] apoc.schema.relationships return wrong output for relationship indexes

* added getIndexType(indexDescriptor) method

* changed attr names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants