Skip to content

Commit

Permalink
test_replication_origin fixed, optimized sql
Browse files Browse the repository at this point in the history
  • Loading branch information
Pyry Liukas committed Dec 7, 2023
1 parent 7f3d636 commit a6c33c8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
11 changes: 2 additions & 9 deletions lib/pgsync/data_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,8 @@ def set_replication_origin(origin)
CASE
WHEN EXISTS (SELECT 1 FROM pg_replication_origin WHERE roname = $1) THEN null
ELSE pg_replication_origin_create($1)
END;
SQL
execute(query, [origin])
query = <<~SQL
SELECT
CASE
WHEN pg_replication_origin_session_is_setup() THEN null
ELSE pg_replication_origin_session_setup($1)
END;
END,
pg_replication_origin_session_setup($1);
SQL
execute(query, [origin])
end
Expand Down
1 change: 0 additions & 1 deletion test/sync_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ def test_disable_integrity_v2

def test_replication_origin
insert(conn1, "posts", [{"id" => 1}])
assert_error "Sync failed for 1 table: posts", "posts", config: true
assert_works "posts --replication-origin=test --debug", config: true
assert_equal [{"exists" => 1}], conn2.exec("SELECT 1 AS exists FROM pg_replication_origin WHERE roname = 'test'").to_a
end
Expand Down

0 comments on commit a6c33c8

Please sign in to comment.