Skip to content

Commit f025834

Browse files
committed
test: add arrow operator metadata field verification
Adds Rust test equivalent for src/operators/->_test.sql lines 106-118. Verifies that e -> 'selector' returns JSONB with 'i' (index) and 'v' (version) fields. Part of legacy SQL test migration to Rust/SQLx framework.
1 parent f242670 commit f025834

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/sqlx/tests/jsonb_path_operators_tests.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
use anyhow::Result;
66
use eql_tests::{QueryAssertion, Selectors};
7+
use serde_json;
78
use sqlx::{PgPool, Row};
89

910
#[sqlx::test(fixtures(path = "../fixtures", scripts("encrypted_json")))]
@@ -93,3 +94,32 @@ async fn double_arrow_in_where_clause(pool: PgPool) -> Result<()> {
9394

9495
Ok(())
9596
}
97+
98+
#[sqlx::test(fixtures(path = "../fixtures", scripts("encrypted_json")))]
99+
async fn arrow_operator_returns_metadata_fields(pool: PgPool) -> Result<()> {
100+
// Test: e -> 'selector' returns JSONB with 'i' (index) and 'v' (version) fields
101+
// SQL equivalent: src/operators/->_test.sql lines 106-118
102+
103+
let sql = format!(
104+
"SELECT (e -> '{}'::text)::jsonb FROM encrypted LIMIT 1",
105+
Selectors::N
106+
);
107+
108+
let result: serde_json::Value = sqlx::query_scalar(&sql).fetch_one(&pool).await?;
109+
110+
assert!(
111+
result.is_object(),
112+
"-> operator should return JSONB object"
113+
);
114+
let obj = result.as_object().unwrap();
115+
assert!(
116+
obj.contains_key("i"),
117+
"Result should contain 'i' (index metadata) field"
118+
);
119+
assert!(
120+
obj.contains_key("v"),
121+
"Result should contain 'v' (version) field"
122+
);
123+
124+
Ok(())
125+
}

0 commit comments

Comments
 (0)