1-
21-- REQUIRE: src/schema.sql
32-- REQUIRE: src/encrypted/types.sql
43-- REQUIRE: src/encrypted/functions.sql
54
6-
7- --
8- -- The -> operator returns an encrypted matching the provided selector
9- --
10- -- Encyprted JSON is represented as an array of `eql_v2_encrypted`.
11- -- Each `eql_v2_encrypted` value has a selector, ciphertext, and an index term
12- --
13- -- {
14- -- "sv": [ {"c": "", "s": "", "b3": "" } ]
15- -- }
16- --
17- -- Note on oeprator resolution:
18- -- Assignment casts are considered for operator resolution (see PostgreSQL docs),
19- -- the system may pick the "more specific" one, which is the one with both arguments of the same type.
20- --
21- -- This means that to use the text operator, the parameter will need to be cast to text
22- --
5+ -- ! @brief JSONB field accessor operator for encrypted values (->)
6+ -- !
7+ -- ! Implements the -> operator to access fields/elements from encrypted JSONB data.
8+ -- ! Returns encrypted value matching the provided selector without decryption.
9+ -- !
10+ -- ! Encrypted JSON is represented as an array of eql_v2_encrypted values in the ste_vec format.
11+ -- ! Each element has a selector, ciphertext, and index terms:
12+ -- ! {"sv": [{"c": "", "s": "", "b3": ""}]}
13+ -- !
14+ -- ! Provides three overloads:
15+ -- ! - (eql_v2_encrypted, text) - Field name selector
16+ -- ! - (eql_v2_encrypted, eql_v2_encrypted) - Encrypted selector
17+ -- ! - (eql_v2_encrypted, integer) - Array index selector (0-based)
18+ -- !
19+ -- ! @note Operator resolution: Assignment casts are considered (PostgreSQL standard behavior).
20+ -- ! To use text selector, parameter may need explicit cast to text.
21+ -- !
22+ -- ! @see eql_v2.ste_vec
23+ -- ! @see eql_v2.selector
24+ -- ! @see eql_v2."->>"
25+
26+ -- ! @brief -> operator with text selector
27+ -- ! @param e eql_v2_encrypted Encrypted JSONB data
28+ -- ! @param selector text Field name to extract
29+ -- ! @return eql_v2_encrypted Encrypted value at selector
30+ -- ! @example
31+ -- ! SELECT encrypted_json -> 'field_name' FROM table;
2332CREATE FUNCTION eql_v2 ." ->" (e eql_v2_encrypted, selector text )
2433 RETURNS eql_v2_encrypted
2534 IMMUTABLE STRICT PARALLEL SAFE
@@ -58,7 +67,11 @@ CREATE OPERATOR ->(
5867
5968-- -------------------------------------------------
6069
61-
70+ -- ! @brief -> operator with encrypted selector
71+ -- ! @param e eql_v2_encrypted Encrypted JSONB data
72+ -- ! @param selector eql_v2_encrypted Encrypted field selector
73+ -- ! @return eql_v2_encrypted Encrypted value at selector
74+ -- ! @see eql_v2."->"(eql_v2_encrypted, text)
6275CREATE FUNCTION eql_v2 ." ->" (e eql_v2_encrypted, selector eql_v2_encrypted)
6376 RETURNS eql_v2_encrypted
6477 IMMUTABLE STRICT PARALLEL SAFE
@@ -79,7 +92,14 @@ CREATE OPERATOR ->(
7992
8093-- -------------------------------------------------
8194
82-
95+ -- ! @brief -> operator with integer array index
96+ -- ! @param e eql_v2_encrypted Encrypted array data
97+ -- ! @param selector integer Array index (0-based, JSONB convention)
98+ -- ! @return eql_v2_encrypted Encrypted value at array index
99+ -- ! @note Array index is 0-based (JSONB standard) despite PostgreSQL arrays being 1-based
100+ -- ! @example
101+ -- ! SELECT encrypted_array -> 0 FROM table;
102+ -- ! @see eql_v2.is_ste_vec_array
83103CREATE FUNCTION eql_v2 ." ->" (e eql_v2_encrypted, selector integer )
84104 RETURNS eql_v2_encrypted
85105 IMMUTABLE STRICT PARALLEL SAFE
0 commit comments