Skip to content

Commit

Permalink
Extend access(->, ->>), addition and subtraction operators (#1258)
Browse files Browse the repository at this point in the history
Original work was done by Josh Innis for issue#282.

The changes included in this PR are as follows:

- Enable the use of access operator with agtype as the RHS operand,
  allowing this operator to be used within cypher queries
- Extend addition operator to concatenate in case any or both
  operands are non-scalar or scalar vertex/edge/path
- Extend subtract operator to delete specified keys from object or
  elements at specified indexes from array
- Add and modify regression tests relevant to the above changes
  • Loading branch information
Zainab-Saad authored and jrgemignani committed Dec 13, 2023
1 parent 4be97ab commit 7b6c108
Show file tree
Hide file tree
Showing 10 changed files with 2,230 additions and 168 deletions.
30 changes: 30 additions & 0 deletions age--1.4.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2894,6 +2894,36 @@ CREATE OPERATOR ->> (
FUNCTION = ag_catalog.agtype_object_field_text
);

CREATE FUNCTION ag_catalog.agtype_object_field_agtype(agtype, agtype)
RETURNS agtype
LANGUAGE c
IMMUTABLE
RETURNS NULL ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

-- get agtype object field or array element
CREATE OPERATOR -> (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_object_field_agtype
);

CREATE FUNCTION ag_catalog.agtype_object_field_text_agtype(agtype, agtype)
RETURNS text
LANGUAGE c
IMMUTABLE
RETURNS NULL ON NULL INPUT
PARALLEL SAFE
AS 'MODULE_PATHNAME';

-- get agtype object field or array element as text
CREATE OPERATOR ->> (
LEFTARG = agtype,
RIGHTARG = agtype,
FUNCTION = ag_catalog.agtype_object_field_text_agtype
);

CREATE FUNCTION ag_catalog.agtype_array_element(agtype, int4)
RETURNS agtype
LANGUAGE c
Expand Down
Loading

0 comments on commit 7b6c108

Please sign in to comment.