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

Feature request: Return same ID type for node and relationship #318

Open
Joshfindit opened this issue May 22, 2018 · 3 comments
Open

Feature request: Return same ID type for node and relationship #318

Joshfindit opened this issue May 22, 2018 · 3 comments

Comments

@Joshfindit
Copy link

Joshfindit commented May 22, 2018

When querying directly with CYPHER, on a node type with an alternate ID (such as UUID) the node returns uuid by default, but the relationship returns the internal Neo4j ID.

The request is: either have the node include the Neo4j ID, or (the better solution if we are looking to avoid referencing transient Neo4j IDs) have the relationship include the node's config-specified ID

Code example (inline, gist, or repo)

results = Neo4j::ActiveBase.current_session.query("MATCH (n)-[r]-() RETURN n, r LIMIT 3")

Runtime information:

Neo4j database version: 3.1.1
neo4j gem version: 8.0.9
neo4j-core gem version: 7.0.6

@cheerfulstoic
Copy link
Contributor

I would love to be able to use the built-in Neo4j ID for the id_property. It would save a lot of code, but unfortunately the ID can be recycled and thus would cause problems for users of the gem.

We specifically avoided using something like a uuid on relationships because Neo4j (the company via the design of the database) strongly discourages queries which start with relationships. All queries should start with nodes and use relationships to traverse to other nodes.

Does that make sense? I'm open to other suggestions

@Joshfindit
Copy link
Author

No, that definitely makes sense; the Neo4j ID is best considered transient.
I'd much rather see the results with whatever permanent ID is used on the nodes.

The main problem this request is trying to solve is that the nodes do not return the Neo4j ID, and the relationships don't return any other ID. This means that the output of a raw query cannot be used to reconstruct the relationships.

@Joshfindit
Copy link
Author

Essentially;

This is not great but ok:

[{
	"index": 0,
	"n": {
		"identity": {
			"username": "Admin",
			"public_name": null,
			"staged": null,
			"id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd",
                        "neo_id": "0"
		}
	},
	"r": {
		"id": 0,
		"type": "AUTHORIZES_WEBSESSION",
		"properties": {},
		"start_node_id": 0,
		"end_node_id": 2
	},
	"m": {
		"web_session": {
			"date_created": null,
			"username": "Admin",
			"id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
                        "neo_id": "2"
		}
	}
}]

This is better:

[{
	"index": 0,
	"n": {
		"identity": {
			"username": "Admin",
			"public_name": null,
			"staged": null,
			"id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd"
		}
	},
	"r": {
		"id": 0,
		"type": "AUTHORIZES_WEBSESSION",
		"properties": {},
		"start_node_id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd",
		"end_node_id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
	},
	"m": {
		"web_session": {
			"date_created": null,
			"username": "Admin",
			"id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
		}
	}
}]

And this is no good:

[{
	"index": 0,
	"n": {
		"identity": {
			"username": "Admin",
			"public_name": null,
			"staged": null,
			"id": "31c7b21c-d0c0-44e4-bb52-73b4c75647bd"
		}
	},
	"r": {
		"id": 0,
		"type": "AUTHORIZES_WEBSESSION",
		"properties": {},
		"start_node_id": 0,
		"end_node_id": 2
	},
	"m": {
		"web_session": {
			"date_created": null,
			"username": "Admin",
			"id": "edc4d3ec-e005-44c2-8072-2aedfeaa0dcc"
		}
	}
}]

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

No branches or pull requests

2 participants