Skip to content

Commit fa4e5e9

Browse files
committed
ignore router scope within sync route
1 parent e596a2a commit fa4e5e9

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/phoenix/sync/router.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ defmodule Phoenix.Sync.Router do
135135
unquote(path),
136136
Phoenix.Sync.Router.Shape,
137137
%{shape: unquote(Macro.escape(definition))},
138-
[]
138+
alias: false
139139
)
140140
end
141141
end

test/phoenix/sync/router_test.exs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@ defmodule Phoenix.Sync.RouterTest do
6464
sync "/query-config", Support.Todo, replica: :full
6565
sync "/query-config2", Support.Todo, replica: :full, storage: %{compaction: :disabled}
6666
end
67+
68+
scope "/namespaced-sync", WebNamespace do
69+
sync "/todos", Support.Todo
70+
end
6771
end
6872

6973
defmodule Endpoint do
@@ -112,6 +116,30 @@ defmodule Phoenix.Sync.RouterTest do
112116
] = Jason.decode!(resp.resp_body)
113117
end
114118

119+
@tag table: {
120+
"todos",
121+
[
122+
"id int8 not null primary key generated always as identity",
123+
"title text",
124+
"completed boolean default false"
125+
]
126+
}
127+
@tag data: {"todos", ["title"], [["one"], ["two"], ["three"]]}
128+
test "supports schema modules within aliased scope", _ctx do
129+
resp =
130+
Phoenix.ConnTest.build_conn()
131+
|> Phoenix.ConnTest.get("/namespaced-sync/todos", %{offset: "-1"})
132+
133+
assert resp.status == 200
134+
assert Plug.Conn.get_resp_header(resp, "electric-offset") == ["0_0"]
135+
136+
assert [
137+
%{"headers" => %{"operation" => "insert"}, "value" => %{"title" => "one"}},
138+
%{"headers" => %{"operation" => "insert"}, "value" => %{"title" => "two"}},
139+
%{"headers" => %{"operation" => "insert"}, "value" => %{"title" => "three"}}
140+
] = Jason.decode!(resp.resp_body)
141+
end
142+
115143
@tag table: {
116144
"todos",
117145
[

0 commit comments

Comments
 (0)