Skip to content

Quote identifier names #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion lib/strategy.ex
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule LibclusterPostgres.Strategy do

def handle_info(:heartbeat, state) do
Process.cancel_timer(state.meta.heartbeat_ref)
Postgrex.query(state.meta.conn, "NOTIFY #{state.config[:channel_name]}, '#{node()}'", [])
Postgrex.query(state.meta.conn, "NOTIFY \"#{state.config[:channel_name]}\", '#{node()}'", [])
ref = heartbeat(state.config[:heartbeat_interval])
{:noreply, put_in(state.meta.heartbeat_ref, ref)}
end
Expand Down
14 changes: 14 additions & 0 deletions test/strategy_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ defmodule LibclusterPostgres.StrategyTest do
assert_receive {:notification, _, _, ^channel_name, ^node}, 1000
end

@quoted_config Keyword.put(@config, :channel_name, "123_oops")
test "sends psql notification with cluster information to a channel that requires quoting" do
verify_conn_notification = start_supervised!({Notifications, @quoted_config})
Notifications.listen(verify_conn_notification, @quoted_config[:channel_name])

topologies = [postgres: [strategy: LibclusterPostgres.Strategy, config: @quoted_config]]
start_supervised!({Cluster.Supervisor, [topologies]})

channel_name = @quoted_config[:channel_name]
node = "#{node()}"

assert_receive {:notification, _, _, ^channel_name, ^node}, 1000
end

describe "connect via cookie" do
@cookie_config Keyword.put(@config, :channel_name, "my_random__123_long_cookie")
@cookie :"my-random-#123-long-cookie"
Expand Down