zf

zenflows testing
git clone https://s.sonu.ch/~srfsh/zf.git
Log | Files | Refs | Submodules | README | LICENSE

bool.ex (528B)


      1 defmodule Postgrex.Extensions.Bool do
      2   @moduledoc false
      3   import Postgrex.BinaryUtils, warn: false
      4   use Postgrex.BinaryExtension, send: "boolsend"
      5 
      6   def encode(_) do
      7     quote location: :keep do
      8       true ->
      9         <<1::int32(), 1>>
     10 
     11       false ->
     12         <<1::int32(), 0>>
     13 
     14       other ->
     15         raise DBConnection.EncodeError, Postgrex.Utils.encode_msg(other, "a boolean")
     16     end
     17   end
     18 
     19   def decode(_) do
     20     quote location: :keep do
     21       <<1::int32(), 1>> -> true
     22       <<1::int32(), 0>> -> false
     23     end
     24   end
     25 end