Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dcda823
chore: add .worktrees/ to .gitignore
tobyhede Oct 29, 2025
8eb3c3e
test(sqlx): add comparison and inequality operator tests
tobyhede Oct 28, 2025
12cab28
test(sqlx): add <= and >= comparison operator tests
tobyhede Oct 28, 2025
289ee11
test(sqlx): add ORDER BY tests with ORE encryption
tobyhede Oct 28, 2025
2d9729f
refactor(tests): address code review suggestions
tobyhede Oct 28, 2025
23f8d3d
test(sqlx): add JSONB path operator tests (-> and ->>)
tobyhede Oct 28, 2025
5de49a8
test(sqlx): add ORE equality/inequality variant tests
tobyhede Oct 28, 2025
88e1e59
refactor(tests): improve ORE variant test coverage and consistency
tobyhede Oct 28, 2025
856ec42
test(sqlx): add containment operator tests (@> and <@)
tobyhede Oct 28, 2025
34e98d2
refactor(tests): address code review feedback for containment tests
tobyhede Oct 28, 2025
6006809
feat(test): create comprehensive test:all task combining legacy SQL a…
tobyhede Oct 28, 2025
73a4584
refactor(tasks): restructure test tasks for CI compatibility
tobyhede Oct 29, 2025
bdc2019
refactor(tasks): flatten test tasks into mise.toml with inline usage
tobyhede Oct 29, 2025
c0f77fc
fix(tasks): correct usage syntax for --postgres flag in test task
tobyhede Oct 29, 2025
c85e47f
fix(tasks): revert to using main repo's test.sh which was already wor…
tobyhede Oct 29, 2025
66328ea
fix(tasks): restore test.sh in worktree with SQLx support
tobyhede Oct 29, 2025
198ab7b
chore: ignore SQLx target directory (using sccache)
tobyhede Oct 29, 2025
ba5c140
ci: install rust
tobyhede Oct 29, 2025
b678c88
ci: making rust work
tobyhede Oct 29, 2025
53da200
fix(tests): add missing selector constants and fix operator type disa…
tobyhede Oct 29, 2025
603c4d0
test(sqlx): add config management tests (41 assertions)
tobyhede Oct 29, 2025
351845c
test(sqlx): add operator class tests (41 assertions)
tobyhede Oct 29, 2025
9f48201
fix(tests): address code review recommendations from Phase 1
tobyhede Oct 29, 2025
bcdd938
test(sqlx): add aggregate function tests (6 assertions)
tobyhede Oct 29, 2025
c764be3
test(sqlx): add constraint tests (10 assertions)
tobyhede Oct 29, 2025
1de42cf
test(sqlx): add ORE CLLW comparison tests (12 assertions)
tobyhede Oct 29, 2025
33d5c24
test(sqlx): add LIKE operator tests (10 assertions)
tobyhede Oct 29, 2025
7fa5a00
test(sqlx): add operator compare tests (63 assertions)
tobyhede Oct 29, 2025
07a12fc
test(sqlx): add specialized function tests (33 assertions)
tobyhede Oct 29, 2025
296fd2d
test(sqlx): add index comparison tests (45 assertions)
tobyhede Oct 29, 2025
083bf9a
refactor(tests): consolidate duplicate helper functions
tobyhede Oct 29, 2025
a085f81
test(sqlx): add ILIKE operator tests for case-insensitive matching
tobyhede Oct 29, 2025
fab6a39
test(sqlx): strengthen GROUP BY assertion with specific count
tobyhede Oct 29, 2025
1be11a3
test(sqlx): add FK enforcement behavior tests
tobyhede Oct 29, 2025
5cfa159
docs(tests): document inline SQL pattern rationale
tobyhede Oct 29, 2025
6e9ff4a
docs(tests): standardize assertion count comment style
tobyhede Oct 30, 2025
67497fa
docs: update SQLx test documentation with complete coverage
tobyhede Oct 30, 2025
8601b8c
docs: add comprehensive SQLx migration completion report
tobyhede Oct 30, 2025
c685a72
chore: remove comments not useful outside the context of this PR
auxesis Oct 31, 2025
8e655be
test: add lint checks for sqlx
auxesis Oct 31, 2025
532922b
chore: `cargo fmt` fixes
auxesis Oct 31, 2025
ef858d2
fix: ensure rustfmt is available in CI
auxesis Oct 31, 2025
120fe2d
ci: use setup-rust-toolchain, as it works reliably
auxesis Oct 31, 2025
ffaeefa
test: disable for now, so CI is still green
auxesis Oct 31, 2025
76f55c1
refactor: address code review feedback
tobyhede Nov 2, 2025
697a570
refactor: convert eql_v2_encrypted from composite to domain type
tobyhede Nov 3, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/test-eql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
components: rustfmt
cache: true
cache-all-crates: true

- uses: jdx/mise-action@v2
with:
version: 2025.1.6 # [default: latest] mise version to install
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

.DS_Store
.mise.*
.worktrees/

deps.txt
deps-ordered.txt
Expand Down Expand Up @@ -210,3 +211,6 @@ eql--*.sql

# Generated SQLx migration (built from src/, never commit)
tests/sqlx/migrations/001_install_eql.sql

# Rust build artifacts (using sccache)
tests/sqlx/target/
34 changes: 33 additions & 1 deletion mise.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,23 @@
# "./tests/mise.tcp.toml",
# "./tests/mise.tls.toml",
# ]

[tools]
rust = "latest"
"cargo:cargo-binstall" = "latest"
"cargo:sqlx-cli" = "latest"


[task_config]
includes = ["tasks", "tasks/postgres.toml", "tasks/rust.toml"]
includes = ["tasks", "tasks/postgres.toml"]

[env]
POSTGRES_DB = "cipherstash"
POSTGRES_USER = "cipherstash"
POSTGRES_PASSWORD = "password"
POSTGRES_HOST = "localhost"
POSTGRES_PORT = "7432"
DATABASE_URL = "postgresql://cipherstash:password@localhost:7432/cipherstash"

[tasks."clean"]
alias = 'k'
Expand All @@ -23,3 +31,27 @@ run = """
rm -f release/cipherstash-encrypt-uninstall.sql
rm -f release/cipherstash-encrypt.sql
"""

[tasks."test:sqlx"]
description = "Run SQLx tests with hybrid migration approach"
dir = "{{config_root}}"
run = """
# Copy built SQL to SQLx migrations (EQL install is generated, not static)
echo "Updating SQLx migrations with built EQL..."
cp release/cipherstash-encrypt.sql tests/sqlx/migrations/001_install_eql.sql

# Run SQLx migrations and tests
echo "Running SQLx migrations..."
cd tests/sqlx
sqlx migrate run

echo "Running Rust tests..."
cargo test
"""

[tasks."test:sqlx:watch"]
description = "Run SQLx tests in watch mode (rebuild EQL on changes)"
dir = "{{config_root}}/tests/sqlx"
run = """
cargo watch -x test
"""
4 changes: 2 additions & 2 deletions src/blake3/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ CREATE FUNCTION eql_v2.blake3(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.blake3(val.data));
RETURN (SELECT eql_v2.blake3($1));
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -85,7 +85,7 @@ CREATE FUNCTION eql_v2.has_blake3(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.has_blake3(val.data);
RETURN eql_v2.has_blake3($1);
END;
$$ LANGUAGE plpgsql;

4 changes: 2 additions & 2 deletions src/bloom_filter/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ CREATE FUNCTION eql_v2.bloom_filter(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.bloom_filter(val.data));
RETURN (SELECT eql_v2.bloom_filter($1));
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -82,6 +82,6 @@ CREATE FUNCTION eql_v2.has_bloom_filter(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.has_bloom_filter(val.data);
RETURN eql_v2.has_bloom_filter($1);
END;
$$ LANGUAGE plpgsql;
2 changes: 1 addition & 1 deletion src/config/constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ AS $$
BEGIN
-- If there are cast_as fields, validate them
IF EXISTS (SELECT jsonb_array_elements_text(jsonb_path_query_array(val, '$.tables.*.*.cast_as'))) THEN
IF (SELECT bool_and(cast_as = ANY('{text, int, small_int, big_int, real, double, boolean, date, jsonb}'))
IF (SELECT bool_and(cast_as = ANY('{text, int, small_int, big_int, real, double, boolean, date, jsonb}'))
FROM (SELECT jsonb_array_elements_text(jsonb_path_query_array(val, '$.tables.*.*.cast_as')) AS cast_as) casts) THEN
RETURN true;
END IF;
Expand Down
2 changes: 1 addition & 1 deletion src/config/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ BEGIN
WITH tables AS (
SELECT config.state, tables.key AS table, tables.value AS config
FROM public.eql_v2_configuration config, jsonb_each(data->'tables') tables
WHERE config.data->>'v' = '1'
WHERE $1->>'v' = '1'
)
SELECT
tables.state,
Expand Down
4 changes: 2 additions & 2 deletions src/encrypted/casts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ BEGIN
RETURN NULL;
END IF;

RETURN ROW(data)::public.eql_v2_encrypted;
RETURN data;
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -68,7 +68,7 @@ BEGIN
RETURN NULL;
END IF;

RETURN e.data;
RETURN e;
END;
$$ LANGUAGE plpgsql;

Expand Down
4 changes: 2 additions & 2 deletions src/encrypted/compare.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ AS $$
RETURN 1;
END IF;

a_data := a.data;
b_data := b.data;
a_data := a;
b_data := b;

IF a_data < b_data THEN
RETURN -1;
Expand Down
2 changes: 1 addition & 1 deletion src/encrypted/constraints.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ CREATE FUNCTION eql_v2.check_encrypted(val eql_v2_encrypted)
RETURNS BOOLEAN
LANGUAGE sql IMMUTABLE STRICT PARALLEL SAFE
BEGIN ATOMIC
RETURN eql_v2.check_encrypted(val.data);
RETURN eql_v2.check_encrypted(val);
END;

4 changes: 2 additions & 2 deletions src/encrypted/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ CREATE FUNCTION eql_v2.ciphertext(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.ciphertext(val.data);
RETURN eql_v2.ciphertext(val);
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -202,7 +202,7 @@ CREATE FUNCTION eql_v2.meta_data(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.meta_data(val.data);
RETURN eql_v2.meta_data(val);
END;
$$ LANGUAGE plpgsql;

4 changes: 1 addition & 3 deletions src/encrypted/types.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'eql_v2_encrypted') THEN
CREATE TYPE public.eql_v2_encrypted AS (
data jsonb
);
CREATE DOMAIN public.eql_v2_encrypted AS jsonb;
END IF;
END
$$;
Expand Down
4 changes: 2 additions & 2 deletions src/hmac_256/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CREATE FUNCTION eql_v2.has_hmac_256(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.has_hmac_256(val.data);
RETURN eql_v2.has_hmac_256($1);
END;
$$ LANGUAGE plpgsql;

Expand All @@ -82,7 +82,7 @@ CREATE FUNCTION eql_v2.hmac_256(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.hmac_256(val.data));
RETURN (SELECT eql_v2.hmac_256($1));
END;
$$ LANGUAGE plpgsql;

Expand Down
16 changes: 8 additions & 8 deletions src/jsonb/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CREATE FUNCTION eql_v2.jsonb_path_query(val eql_v2_encrypted, selector eql_v2_en
AS $$
BEGIN
RETURN QUERY
SELECT * FROM eql_v2.jsonb_path_query(val.data, eql_v2.selector(selector));
SELECT * FROM eql_v2.jsonb_path_query($1, eql_v2.selector(selector));
END;
$$ LANGUAGE plpgsql;

Expand All @@ -93,7 +93,7 @@ CREATE FUNCTION eql_v2.jsonb_path_query(val eql_v2_encrypted, selector text)
AS $$
BEGIN
RETURN QUERY
SELECT * FROM eql_v2.jsonb_path_query(val.data, selector);
SELECT * FROM eql_v2.jsonb_path_query($1, selector);
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -148,7 +148,7 @@ AS $$
RETURN (
SELECT (
SELECT e
FROM eql_v2.jsonb_path_query(val.data, selector) AS e
FROM eql_v2.jsonb_path_query($1, selector) AS e
LIMIT 1
)
);
Expand All @@ -163,7 +163,7 @@ AS $$
BEGIN
RETURN (
SELECT e
FROM eql_v2.jsonb_path_query(val.data, eql_v2.selector(selector)) as e
FROM eql_v2.jsonb_path_query($1, eql_v2.selector(selector)) as e
LIMIT 1
);
END;
Expand All @@ -177,7 +177,7 @@ AS $$
BEGIN
RETURN (
SELECT e
FROM eql_v2.jsonb_path_query(val.data, selector) as e
FROM eql_v2.jsonb_path_query($1, selector) as e
LIMIT 1
);
END;
Expand Down Expand Up @@ -225,7 +225,7 @@ CREATE FUNCTION eql_v2.jsonb_array_length(val eql_v2_encrypted)
AS $$
BEGIN
RETURN (
SELECT eql_v2.jsonb_array_length(val.data)
SELECT eql_v2.jsonb_array_length($1)
);
END;
$$ LANGUAGE plpgsql;
Expand Down Expand Up @@ -276,7 +276,7 @@ CREATE FUNCTION eql_v2.jsonb_array_elements(val eql_v2_encrypted)
AS $$
BEGIN
RETURN QUERY
SELECT * FROM eql_v2.jsonb_array_elements(val.data);
SELECT * FROM eql_v2.jsonb_array_elements($1);
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -319,6 +319,6 @@ CREATE FUNCTION eql_v2.jsonb_array_elements_text(val eql_v2_encrypted)
AS $$
BEGIN
RETURN QUERY
SELECT * FROM eql_v2.jsonb_array_elements_text(val.data);
SELECT * FROM eql_v2.jsonb_array_elements_text($1);
END;
$$ LANGUAGE plpgsql;
4 changes: 2 additions & 2 deletions src/ore_block_u64_8_256/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ CREATE FUNCTION eql_v2.ore_block_u64_8_256(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.ore_block_u64_8_256(val.data);
RETURN eql_v2.ore_block_u64_8_256($1);
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -113,7 +113,7 @@ CREATE FUNCTION eql_v2.has_ore_block_u64_8_256(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.has_ore_block_u64_8_256(val.data);
RETURN eql_v2.has_ore_block_u64_8_256($1);
END;
$$ LANGUAGE plpgsql;

Expand Down
4 changes: 2 additions & 2 deletions src/ore_cllw_u64_8/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CREATE FUNCTION eql_v2.ore_cllw_u64_8(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.ore_cllw_u64_8(val.data));
RETURN (SELECT eql_v2.ore_cllw_u64_8($1));
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -84,7 +84,7 @@ CREATE FUNCTION eql_v2.has_ore_cllw_u64_8(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.has_ore_cllw_u64_8(val.data);
RETURN eql_v2.has_ore_cllw_u64_8($1);
END;
$$ LANGUAGE plpgsql;

Expand Down
4 changes: 2 additions & 2 deletions src/ore_cllw_var_8/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ CREATE FUNCTION eql_v2.ore_cllw_var_8(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.ore_cllw_var_8(val.data));
RETURN (SELECT eql_v2.ore_cllw_var_8($1));
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -86,7 +86,7 @@ CREATE FUNCTION eql_v2.has_ore_cllw_var_8(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.has_ore_cllw_var_8(val.data);
RETURN eql_v2.has_ore_cllw_var_8($1);
END;
$$ LANGUAGE plpgsql;

Expand Down
10 changes: 5 additions & 5 deletions src/ste_vec/functions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ CREATE FUNCTION eql_v2.ste_vec(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.ste_vec(val.data));
RETURN (SELECT eql_v2.ste_vec($1));
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -94,7 +94,7 @@ CREATE FUNCTION eql_v2.is_ste_vec_value(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.is_ste_vec_value(val.data);
RETURN eql_v2.is_ste_vec_value($1);
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -147,7 +147,7 @@ CREATE FUNCTION eql_v2.to_ste_vec_value(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN eql_v2.to_ste_vec_value(val.data);
RETURN eql_v2.to_ste_vec_value($1);
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -192,7 +192,7 @@ CREATE FUNCTION eql_v2.selector(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.selector(val.data));
RETURN (SELECT eql_v2.selector($1));
END;
$$ LANGUAGE plpgsql;

Expand Down Expand Up @@ -235,7 +235,7 @@ CREATE FUNCTION eql_v2.is_ste_vec_array(val eql_v2_encrypted)
IMMUTABLE STRICT PARALLEL SAFE
AS $$
BEGIN
RETURN (SELECT eql_v2.is_ste_vec_array(val.data));
RETURN (SELECT eql_v2.is_ste_vec_array($1));
END;
$$ LANGUAGE plpgsql;

Expand Down
Loading
Loading