zf

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

query.ex (1468B)


      1 defprotocol DBConnection.Query do
      2   @moduledoc """
      3   The `DBConnection.Query` protocol is responsible for preparing and
      4   encoding queries.
      5 
      6   All `DBConnection.Query` functions are executed in the caller process which
      7   means it's safe to, for example, raise exceptions or do blocking calls as
      8   they won't affect the connection process.
      9   """
     10 
     11   @doc """
     12   Parse a query.
     13 
     14   This function is called to parse a query term before it is prepared using a
     15   connection callback module.
     16 
     17   See `DBConnection.prepare/3`.
     18   """
     19   @spec parse(any, Keyword.t()) :: any
     20   def parse(query, opts)
     21 
     22   @doc """
     23   Describe a query.
     24 
     25   This function is called to describe a query after it is prepared using a
     26   connection callback module.
     27 
     28   See `DBConnection.prepare/3`.
     29   """
     30   @spec describe(any, Keyword.t()) :: any
     31   def describe(query, opts)
     32 
     33   @doc """
     34   Encode parameters using a query.
     35 
     36   This function is called to encode a query before it is executed using a
     37   connection callback module.
     38 
     39   If this function raises `DBConnection.EncodeError`, then the query is
     40   prepared once again.
     41 
     42   See `DBConnection.execute/3`.
     43   """
     44   @spec encode(any, any, Keyword.t()) :: any
     45   def encode(query, params, opts)
     46 
     47   @doc """
     48   Decode a result using a query.
     49 
     50   This function is called to decode a result after it is returned by a
     51   connection callback module.
     52 
     53   See `DBConnection.execute/3`.
     54   """
     55   @spec decode(any, any, Keyword.t()) :: any
     56   def decode(query, result, opts)
     57 end