-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
defmodule Postgrex.Extensions.Xid8 do | ||
@moduledoc false | ||
import Postgrex.BinaryUtils, warn: false | ||
use Postgrex.BinaryExtension, send: "xid8send" | ||
|
||
@xid8_range 0..18_446_744_073_709_551_615 | ||
|
||
def encode(_) do | ||
range = Macro.escape(@xid8_range) | ||
|
||
quote location: :keep do | ||
int when int in unquote(range) -> | ||
<<8::int32, int::uint64>> | ||
|
||
other -> | ||
raise DBConnection.EncodeError, Postgrex.Utils.encode_msg(other, unquote(range)) | ||
end | ||
end | ||
|
||
def decode(_) do | ||
quote location: :keep do | ||
<<8::int32, int::uint64>> -> int | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters