Skip to content

Commit ee26ff7

Browse files
committed
fix merge
1 parent d5ff87a commit ee26ff7

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

lib/phoenix/sync.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ defmodule Phoenix.Sync do
282282
- `columns` - The columns included in the shape. E.g. `["id", "title", "completed"]`
283283
- `params` - The values associated with a parameterized where clause. E.g. `[true, 1, "alive"]`, `%{1 => true}`
284284
"""
285-
@spec interrupt(shape_definition() | (match_shape_params() -> boolean()), shape_options()) ::
285+
@spec interrupt(shape_definition() | (match_shape_params() -> boolean()), shape_specification()) ::
286286
{:ok, non_neg_integer()}
287287
def interrupt(shape, shape_opts \\ []) do
288288
Phoenix.Sync.ShapeRequestRegistry.interrupt_matching(shape, shape_opts)
@@ -334,7 +334,7 @@ defmodule Phoenix.Sync do
334334
335335
#{NimbleOptions.docs(PredefinedShape.schema())}
336336
"""
337-
@spec shape!(shape_definition(), shape_options()) :: PredefinedShape.t()
337+
@spec shape!(shape_definition(), shape_specification()) :: PredefinedShape.t()
338338
def shape!(shape, shape_opts \\ []) do
339339
PredefinedShape.new!(shape, shape_opts)
340340
end

lib/phoenix/sync/client.ex

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,23 @@ defmodule Phoenix.Sync.Client do
126126
@spec stream(Phoenix.Sync.shape_definition(), Electric.Client.stream_options()) :: Enum.t()
127127
def stream(shape, stream_opts \\ [])
128128

129+
def stream(table, stream_opts) when is_binary(table) and is_list(stream_opts) do
130+
stream(Keyword.put(stream_opts, :table, table), [])
131+
end
132+
129133
def stream(shape, []) when is_list(shape) do
130134
{client, shape} = Keyword.pop_lazy(shape, :client, &new!/0)
131135

132-
{shape, shape_stream_opts} = resolve_shape(shape)
136+
{shape, shape_stream_opts} = resolve_shape(shape, [])
133137

134138
Electric.Client.stream(client, shape, shape_stream_opts)
135139
end
136140

137-
def stream(table, stream_opts) when is_binary(table) and is_list(stream_opts) do
138-
stream(Keyword.put(stream_opts, :table, table), [])
139-
end
140-
141141
def stream(shape, stream_opts) when not is_list(shape) and is_list(stream_opts) do
142142
{client, stream_opts} = Keyword.pop_lazy(stream_opts, :client, &new!/0)
143+
{shape, shape_stream_opts} = resolve_shape(shape, stream_opts)
143144

144-
{shape, shape_stream_opts} = resolve_shape(shape)
145-
stream_opts = Keyword.merge(shape_stream_opts, stream_opts)
146-
Electric.Client.stream(client, shape, stream_opts)
145+
Electric.Client.stream(client, shape, shape_stream_opts)
147146
end
148147

149148
defp resolve_shape(shape, stream_opts) do

lib/phoenix/sync/predefined_shape.ex

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ defmodule Phoenix.Sync.PredefinedShape do
4444
@type options() :: [option()]
4545

4646
if Code.ensure_loaded?(Ecto) do
47-
@type shape() :: options() | queryable()
47+
@type shape() :: options() | Phoenix.Sync.queryable()
4848
else
4949
@type shape() :: options()
5050
end
@@ -55,9 +55,6 @@ defmodule Phoenix.Sync.PredefinedShape do
5555
@doc false
5656
def schema, do: @keyword_shape_schema
5757

58-
def schema, do: @schema
59-
def keys, do: @keys
60-
6158
def is_queryable?(schema) when is_atom(schema) do
6259
Code.ensure_loaded?(schema) && function_exported?(schema, :__schema__, 1) &&
6360
!is_nil(schema.__schema__(:source))

lib/phoenix/sync/sandbox.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ if Code.ensure_loaded?(Ecto.Adapters.SQL.Sandbox) do
458458
|> Phoenix.Sync.PredefinedShape.new!()
459459
|> Phoenix.Sync.PredefinedShape.to_stream_params()
460460

461-
Sandbox.Producer.truncate(stack_id, {namespace, table})
461+
Sandbox.Producer.truncate(stack_id, {namespace || "public", table})
462462
end
463463

464464
@impl true

lib/phoenix/sync/shape.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ defmodule Phoenix.Sync.Shape do
492492
types
493493
|> Enum.flat_map(fn
494494
:changes -> [:insert, :update, :delete]
495-
type -> type
495+
type -> [type]
496496
end)
497497
|> Enum.uniq()
498498

test/phoenix/sync/client_test.exs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,11 @@ defmodule Phoenix.Sync.ClientTest do
155155
stream =
156156
Phoenix.Sync.Client.stream(
157157
from(t in Support.Todo, where: t.completed == true),
158-
[namespace: "app", replica: :full, live: false, errors: :stream],
159-
ctx.electric_opts
158+
namespace: "app",
159+
replica: :full,
160+
live: false,
161+
errors: :stream,
162+
client: ctx.client
160163
)
161164

162165
assert %Electric.Client.Stream{

0 commit comments

Comments
 (0)