Skip to content

Commit

Permalink
keep original param ordering in location header
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetised committed Jan 30, 2025
1 parent 40f04f9 commit fa7387e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/sync-service/lib/electric/shapes/api/response.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ defmodule Electric.Shapes.Api.Response do
end

defp put_location_header(conn, %__MODULE__{status: 409} = response) do
params = %{
params = [
table: Electric.Utils.relation_to_sql(response.shape.root_table),
handle: response.handle,
offset: "-1"
}
]

query = URI.encode_query(params)

Expand Down
2 changes: 1 addition & 1 deletion packages/sync-service/test/electric/plug/router_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ defmodule Electric.Plug.RouterTest do
new_shape_handle = get_resp_header(conn, "electric-handle")

assert get_resp_header(conn, "location") ==
"/v1/shape?handle=#{new_shape_handle}&offset=-1&table=public.items"
"/v1/shape?table=public.items&handle=#{new_shape_handle}&offset=-1"
end

test "GET receives 409 when shape handle is not found but there is another shape matching the definition",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ defmodule Electric.Plug.ServeShapePlugTest do
assert get_resp_header(conn, "electric-handle") == [@test_shape_handle]

assert get_resp_header(conn, "location") == [
"/?handle=#{@test_shape_handle}&offset=-1&table=public.users"
"/?table=public.users&handle=#{@test_shape_handle}&offset=-1"
]
end

Expand Down Expand Up @@ -631,7 +631,7 @@ defmodule Electric.Plug.ServeShapePlugTest do
assert get_resp_header(conn, "electric-handle") == [new_shape_handle]

assert get_resp_header(conn, "location") == [
"/?handle=#{new_shape_handle}&offset=-1&table=public.users"
"/?table=public.users&handle=#{new_shape_handle}&offset=-1"
]
end

Expand Down

0 comments on commit fa7387e

Please sign in to comment.