Skip to content

Commit 3d4231d

Browse files
committed
docs: fix inaccuracies in EQL function reference
- Fix check_encrypted() description to reflect actual validation (v,c,i fields not v,k,i) - Update check_encrypted() behavior: raises exceptions instead of returning false - Fix version() example to not show hardcoded version string - Enhance JSON path operator examples with specific selector types (text, encrypted, integer) - Add array index access example for -> operator
1 parent 869e90b commit 3d4231d

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

docs/reference/eql-functions.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,16 @@ SELECT * FROM users WHERE encrypted_data <@ $1::eql_v2_encrypted;
265265
#### JSON Path Access
266266

267267
```sql
268-
-- Extract field by selector (returns eql_v2_encrypted)
269-
SELECT encrypted_json->'selector_hash' FROM users;
268+
-- Extract field by selector hash (returns eql_v2_encrypted)
269+
SELECT encrypted_json->'abc123...' FROM users;
270+
SELECT encrypted_json->encrypted_selector FROM users;
271+
272+
-- Extract field by array index (returns eql_v2_encrypted)
273+
SELECT encrypted_json->0 FROM users;
270274

271275
-- Extract field as ciphertext (returns text)
272-
SELECT encrypted_json->>'selector_hash' FROM users;
276+
SELECT encrypted_json->>'abc123...' FROM users;
277+
SELECT encrypted_json->>encrypted_selector FROM users;
273278
```
274279

275280
### Function Equivalents
@@ -679,7 +684,7 @@ eql_v2.version() RETURNS text
679684
**Example:**
680685
```sql
681686
SELECT eql_v2.version();
682-
-- Returns: '2.1.8'
687+
-- Returns version string (e.g., '2.1.8')
683688
```
684689

685690
### `eql_v2.to_encrypted()`
@@ -723,17 +728,18 @@ eql_v2.check_encrypted(val eql_v2_encrypted) RETURNS boolean
723728
```
724729

725730
**Description:**
726-
- Validates that encrypted value has required fields (`v`, `k`, `i`)
727-
- Returns true if valid, false otherwise
731+
- Validates that encrypted value has required fields (`v`, `c`, `i`)
732+
- Checks that version is `2` and identifier contains table (`t`) and column (`c`) fields
733+
- Returns true if valid, raises exception if invalid
728734
- Automatically added as constraint when using `eql_v2.add_column()`
729735

730736
**Example:**
731737
```sql
732-
SELECT eql_v2.check_encrypted('{"v":2,"k":"pt","p":"test","i":{"t":"users","c":"email"}}'::jsonb);
738+
SELECT eql_v2.check_encrypted('{"v":2,"c":"ciphertext","i":{"t":"users","c":"email"}}'::jsonb);
733739
-- Returns: true
734740

735741
SELECT eql_v2.check_encrypted('{"invalid":"structure"}'::jsonb);
736-
-- Returns: false
742+
-- Raises exception: 'Encrypted column missing version (v) field'
737743
```
738744

739745
---

0 commit comments

Comments
 (0)