Skip to content

Commit a676717

Browse files
committed
fix(test): update operator_class_tests to use encrypted_json fixture
Replace raw ORE-only test data with create_encrypted_json() which includes hmac/blake3 index terms required for hash-based GROUP BY aggregation now that the hash operator class is registered.
1 parent d0d3885 commit a676717

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

tests/sqlx/tests/operator_class_tests.rs

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,26 @@ async fn create_table_with_encrypted(pool: &PgPool) -> Result<()> {
2424
Ok(())
2525
}
2626

27-
#[sqlx::test]
27+
#[sqlx::test(fixtures(path = "../fixtures", scripts("encrypted_json")))]
2828
async fn group_by_encrypted_column(pool: PgPool) -> Result<()> {
2929
// Test: GROUP BY works with eql_v2_encrypted type (1 assertion)
30+
// Uses create_encrypted_json which includes hmac/blake3 terms required for hash aggregation
3031

3132
create_table_with_encrypted(&pool).await?;
3233

33-
// Copy ORE data into encrypted table
34-
let ore_42 = get_ore_encrypted(&pool, 42).await?;
35-
let ore_99 = get_ore_encrypted(&pool, 99).await?;
36-
37-
sqlx::query(&format!(
38-
"INSERT INTO encrypted(e) VALUES
39-
('{}'::eql_v2_encrypted),
40-
('{}'::eql_v2_encrypted),
41-
('{}'::eql_v2_encrypted),
42-
('{}'::eql_v2_encrypted),
43-
('{}'::eql_v2_encrypted),
44-
('{}'::eql_v2_encrypted)",
45-
ore_42, ore_42, ore_42, ore_42, ore_99, ore_99
46-
))
47-
.execute(&pool)
48-
.await?;
49-
50-
// GROUP BY should work - most common value is 42 (4 occurrences)
34+
// Insert values with hmac/blake3 terms: 4x id=1, 2x id=2
35+
for _ in 0..4 {
36+
sqlx::query("INSERT INTO encrypted(e) VALUES (create_encrypted_json(1))")
37+
.execute(&pool)
38+
.await?;
39+
}
40+
for _ in 0..2 {
41+
sqlx::query("INSERT INTO encrypted(e) VALUES (create_encrypted_json(2))")
42+
.execute(&pool)
43+
.await?;
44+
}
45+
46+
// GROUP BY should work - most common value is id=1 (4 occurrences)
5147
let count: i64 = sqlx::query_scalar(
5248
"SELECT count(id) FROM encrypted GROUP BY e ORDER BY count(id) DESC LIMIT 1",
5349
)

0 commit comments

Comments
 (0)