Skip to content

Commit c6b1927

Browse files
committed
fix(docs): address verified documentation gaps and lint errors
Documentation fixes (from cross-checked verification): - E1-1: Add integer -> operator documentation for array indexing - E1-2: Clarify sv/ste_vec is a storage field, not an index term type - E1-3: Correct ->> return type from "ciphertext" to "encrypted value as text" - E1-4: Document ste_vec(jsonb) overload alongside ste_vec(eql_v2_encrypted) - E1-5: Add note about -> vs ->> operator asymmetry (integer index support) Rust lint fixes: - Apply cargo fmt formatting to lib.rs and containment_with_index_tests.rs
1 parent abd8418 commit c6b1927

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

docs/reference/database-indexes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ B-tree indexes **only work** with:
218218

219219
They **do not work** with:
220220
- `bf` (bloom_filter) - pattern matching
221-
- `sv` (ste_vec) - JSONB containment (use [GIN indexes](#gin-indexes-for-jsonb-containment) instead)
221+
- Data with `sv` field (ste_vec) - JSONB containment uses GIN indexes instead (see [GIN Indexes](#gin-indexes-for-jsonb-containment))
222222
- Data without any index terms
223223

224224
### 2. Index Creation Timing

docs/reference/json-support.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,15 @@ Use standard PostgreSQL JSON operators on encrypted columns:
156156
-- Extract field by selector (returns eql_v2_encrypted)
157157
SELECT encrypted_json->'selector_hash' FROM examples;
158158

159-
-- Extract field as text (returns ciphertext)
159+
-- Extract field as text (returns encrypted value as text)
160160
SELECT encrypted_json->>'selector_hash' FROM examples;
161+
162+
-- Extract array element by index (0-based, returns eql_v2_encrypted)
163+
SELECT encrypted_array->0 FROM examples;
161164
```
162165

166+
**Note:** The `->` operator supports integer array indexing (e.g., `encrypted_array->0`), but the `->>` operator does not. Use `->` to access array elements by index.
167+
163168
### Array operations
164169

165170
EQL supports array operations on encrypted JSONB arrays:
@@ -218,6 +223,9 @@ GROUP BY eql_v2.jsonb_path_query_first(encrypted_json, 'color_selector');
218223

219224
### Core Functions
220225

226+
- **`eql_v2.ste_vec(val jsonb) RETURNS eql_v2_encrypted[]`**
227+
- Extracts the ste_vec index array from a JSONB payload
228+
221229
- **`eql_v2.ste_vec(val eql_v2_encrypted) RETURNS eql_v2_encrypted[]`**
222230
- Extracts the ste_vec index array from an encrypted value
223231

tests/sqlx/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub mod selectors;
1111

1212
pub use assertions::QueryAssertion;
1313
pub use helpers::{
14-
analyze_table, assert_uses_index, assert_uses_seq_scan, create_jsonb_gin_index,
15-
explain_query, get_encrypted_term, get_ore_encrypted, get_ore_encrypted_as_jsonb,
16-
get_ste_vec_encrypted, get_ste_vec_selector_term, get_ste_vec_term_by_id,
14+
analyze_table, assert_uses_index, assert_uses_seq_scan, create_jsonb_gin_index, explain_query,
15+
get_encrypted_term, get_ore_encrypted, get_ore_encrypted_as_jsonb, get_ste_vec_encrypted,
16+
get_ste_vec_selector_term, get_ste_vec_term_by_id,
1717
};
1818
pub use index_types as IndexTypes;
1919
pub use selectors::Selectors;

tests/sqlx/tests/containment_with_index_tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
1111
use anyhow::Result;
1212
use eql_tests::{
13-
analyze_table, assert_uses_index, assert_uses_seq_scan, create_jsonb_gin_index,
14-
explain_query, get_ste_vec_encrypted,
13+
analyze_table, assert_uses_index, assert_uses_seq_scan, create_jsonb_gin_index, explain_query,
14+
get_ste_vec_encrypted,
1515
};
1616
use sqlx::PgPool;
1717

@@ -185,7 +185,6 @@ async fn jsonb_array_count_with_index(pool: PgPool) -> Result<()> {
185185
Ok(())
186186
}
187187

188-
189188
#[sqlx::test]
190189
async fn jsonb_containment_uses_seq_scan_without_index(pool: PgPool) -> Result<()> {
191190
// Test: Verify sequential scan is used BEFORE GIN index is created

0 commit comments

Comments
 (0)