From 6b371732ab0aa148dd2ef1b8acfa9eb22ad8c175 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Tue, 21 Nov 2023 04:49:14 -0600 Subject: [PATCH 1/2] run test --- test/expected/test_space_in_name.out | 0 test/sql/test_space_in_name.sql | 31 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 test/expected/test_space_in_name.out create mode 100644 test/sql/test_space_in_name.sql diff --git a/test/expected/test_space_in_name.out b/test/expected/test_space_in_name.out new file mode 100644 index 0000000..e69de29 diff --git a/test/sql/test_space_in_name.sql b/test/sql/test_space_in_name.sql new file mode 100644 index 0000000..304760d --- /dev/null +++ b/test/sql/test_space_in_name.sql @@ -0,0 +1,31 @@ +select 1 from pg_create_logical_replication_slot('realtime', 'wal2json', false); + +create table public."User Notes"( + id int primary key +); + +insert into realtime.subscription(subscription_id, entity, claims) +select + seed_uuid(1), + 'public.User Notes', + jsonb_build_object( + 'role', 'authenticated', + 'email', 'example@example.com', + 'sub', seed_uuid(1)::text + ); + +select clear_wal(); +insert into public."User Notes"(id) values (1); + +select + rec, + is_rls_enabled, + subscription_ids, + errors +from + walrus; + + +drop table public.notes; +select pg_drop_replication_slot('realtime'); +truncate table realtime.subscription; From 57d47adfd35baf6aa97f72efa9c0bcf5c2fee1d9 Mon Sep 17 00:00:00 2001 From: Oliver Rice Date: Tue, 21 Nov 2023 05:11:31 -0600 Subject: [PATCH 2/2] add test for table with a space in the name --- test/expected/test_space_in_name.out | 60 ++++++++++++++++++++++++++++ test/sql/test_space_in_name.sql | 2 +- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/test/expected/test_space_in_name.out b/test/expected/test_space_in_name.out index e69de29..bfba0c6 100644 --- a/test/expected/test_space_in_name.out +++ b/test/expected/test_space_in_name.out @@ -0,0 +1,60 @@ +select 1 from pg_create_logical_replication_slot('realtime', 'wal2json', false); + ?column? +---------- + 1 +(1 row) + +create table public."User Notes"( + id int primary key +); +insert into realtime.subscription(subscription_id, entity, claims) +select + seed_uuid(1), + '"User Notes"'::regclass, + jsonb_build_object( + 'role', 'authenticated', + 'email', 'example@example.com', + 'sub', seed_uuid(1)::text + ); +select clear_wal(); + clear_wal +----------- + +(1 row) + +insert into public."User Notes"(id) values (1); +select + rec, + is_rls_enabled, + subscription_ids, + errors +from + walrus; + rec | is_rls_enabled | subscription_ids | errors +----------------------------------------------------+----------------+----------------------------------------+-------- + { +| f | {f4539ebe-c779-5788-bbc1-2421ffaa8954} | {} + "type": "INSERT", +| | | + "table": "User Notes", +| | | + "record": { +| | | + "id": 1 +| | | + }, +| | | + "schema": "public", +| | | + "columns": [ +| | | + { +| | | + "name": "id", +| | | + "type": "int4" +| | | + } +| | | + ], +| | | + "commit_timestamp": "2000-01-01T08:01:01.000Z"+| | | + } | | | +(1 row) + +drop table public.notes; +ERROR: table "notes" does not exist +select pg_drop_replication_slot('realtime'); + pg_drop_replication_slot +-------------------------- + +(1 row) + +truncate table realtime.subscription; diff --git a/test/sql/test_space_in_name.sql b/test/sql/test_space_in_name.sql index 304760d..4c0da74 100644 --- a/test/sql/test_space_in_name.sql +++ b/test/sql/test_space_in_name.sql @@ -7,7 +7,7 @@ create table public."User Notes"( insert into realtime.subscription(subscription_id, entity, claims) select seed_uuid(1), - 'public.User Notes', + '"User Notes"'::regclass, jsonb_build_object( 'role', 'authenticated', 'email', 'example@example.com',