Skip to content

Commit

Permalink
ft: improve some decoding paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hauleth committed Jun 28, 2024
1 parent 91df94f commit 2413263
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions lib/supavisor/protocol/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,18 @@ defmodule Supavisor.Protocol.Client do
end

def decode_payload(:simple_query, payload) do
case String.split(payload, <<0>>) do
case String.split(payload, <<0>>, parts: 2) do
[query, ""] -> query
_ -> :undefined
end
end

def decode_payload(:parse_message, <<0>>), do: :undefined

def decode_payload(:parse_message, payload) do
case String.split(payload, <<0>>) do
[""] ->
:undefined

other ->
case Enum.filter(other, &(&1 != "")) do
[sql] -> sql
message -> message
end
case String.split(payload, <<0>>, trim: true) do
[sql] -> sql
message -> message
end
end

Expand Down

0 comments on commit 2413263

Please sign in to comment.