Skip to content

Commit

Permalink
var! method
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Rychlewski authored and Greg Rychlewski committed Jul 1, 2024
1 parent e04c63d commit 049fbd8
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 80 deletions.
6 changes: 3 additions & 3 deletions lib/postgrex/extensions/array.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ defmodule Postgrex.Extensions.Array do

def decode(_) do
quote location: :keep do
<<len::int32(), binary::binary-size(len)>>, [oid], [type], mod ->
<<len::int32(), binary::binary-size(len)>>, [oid], [type] ->
<<ndims::int32(), _has_null::int32(), ^oid::uint32(), dims::size(ndims)-binary-unit(64),
data::binary>> = binary

# decode_list/2 defined by TypeModule
type =
case type do
{extension, sub_oids, sub_types} -> {extension, sub_oids, sub_types, mod}
extension -> {extension, mod}
{extension, sub_oids, sub_types} -> {extension, sub_oids, sub_types, var!(mod)}
extension -> {extension, var!(mod)}
end

flat = decode_list(data, type)
Expand Down
2 changes: 1 addition & 1 deletion lib/postgrex/extensions/multirange.ex
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ defmodule Postgrex.Extensions.Multirange do

def decode(_) do
quote location: :keep do
<<len::int32(), data::binary-size(len)>>, [_oid], [type], _ ->
<<len::int32(), data::binary-size(len)>>, [_oid], [type] ->
<<_num_ranges::int32(), ranges::binary>> = data

# decode_list/2 defined by TypeModule
Expand Down
2 changes: 1 addition & 1 deletion lib/postgrex/extensions/range.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ defmodule Postgrex.Extensions.Range do

def decode(_) do
quote location: :keep do
<<len::int32(), binary::binary-size(len)>>, [_oid], [type], _ ->
<<len::int32(), binary::binary-size(len)>>, [_oid], [type] ->
<<flags, data::binary>> = binary

# decode_list/2 defined by TypeModule
Expand Down
4 changes: 2 additions & 2 deletions lib/postgrex/extensions/record.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ defmodule Postgrex.Extensions.Record do

def decode(_) do
quote location: :keep do
<<len::int32(), binary::binary-size(len)>>, nil, types, _ ->
<<len::int32(), binary::binary-size(len)>>, nil, types ->
<<count::int32(), data::binary>> = binary
# decode_tuple/3 defined by TypeModule
decode_tuple(data, count, types)

<<len::int32(), binary::binary-size(len)>>, oids, types, _ ->
<<len::int32(), binary::binary-size(len)>>, oids, types ->
<<_::int32(), data::binary>> = binary
# decode_tuple/3 defined by TypeModule
decode_tuple(data, oids, types)
Expand Down
4 changes: 2 additions & 2 deletions lib/postgrex/extensions/timestamp.ex
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ defmodule Postgrex.Extensions.Timestamp do

def decode(infinity?) do
quote location: :keep do
<<8::int32(), microsecs::int64()>>, precision ->
unquote(__MODULE__).microsecond_to_elixir(microsecs, precision, unquote(infinity?))
<<8::int32(), microsecs::int64()>> ->
unquote(__MODULE__).microsecond_to_elixir(microsecs, var!(mod), unquote(infinity?))
end
end

Expand Down
Loading

0 comments on commit 049fbd8

Please sign in to comment.