In regards to orderability between different agtypes: –
https://age.apache.org/age-manual/master/intro/comparability.html
I was testing the orderability between path and an edge, and I found this odd behavior: –
Comparing a path with an edge with p > e
inequality: –
test=# SELECT *
FROM cypher('test', $$
WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
{id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
{id: 1, label: "label_name_2", properties: {}}::vertex
]::path as p
MATCH (n)-[e]-(m) RETURN p>e
$$) AS (e agtype);
e
------
true
true
true
true
(4 rows)
Fair enough, same result holds when we compare it with p < e
inequality
test=# SELECT *
FROM cypher('test', $$
WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
{id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
{id: 1, label: "label_name_2", properties: {}}::vertex
]::path as p
MATCH (n)-[e]-(m) RETURN p<e
$$) AS (e agtype);
e
-------
false
false
false
false
(4 rows)
But look, when we change the inequality to e > p
test=# SELECT *
FROM cypher('test', $$
WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
{id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
{id: 1, label: "label_name_2", properties: {}}::vertex
]::path as p
MATCH (n)-[e]-(m) RETURN e>p
$$) AS (e agtype);
e
------
true
true
true
true
(4 rows)
We get true again, which is in direct contradiction to p > e
inequality
And when we check for e < p
, we get false again
test=# SELECT *
FROM cypher('test', $$
WITH [{id: 0, label: "label_name_1", properties: {i: 0}}::vertex,
{id: 2, start_id: 0, end_id: 1, label: "edge_label", properties: {i: 0}}::edge,
{id: 1, label: "label_name_2", properties: {}}::vertex
]::path as p
MATCH (n)-[e]-(m) RETURN e<p
$$) AS (e agtype);
e
-------
false
false
false
false
(4 rows)
Again, in direct contradiction to the first 2 results.
It seems that in the case of edge and path, irrespective of which is which ‘>’ inequality yields true, while ‘<‘ inequality yields false.
Is this the intended behavior or a bug?
And if this is the intended behavior then why?
2
Answers
So far, it does appear to be unintended behavior, and hence, a bug indeed. It arises from lack of clear assignment of priority to both path and edge in the code.
I have created an issue for this behavior https://github.com/apache/age/issues/870
And have also suggested ways of correcting it there.
The documentation is ambiguous, and it has been flagged as an issue in the repository. For now, I suggest programming defensively to protect against bugs due to this behaviour.