zf

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

result.ex (1384B)


      1 defmodule Postgrex.Result do
      2   @moduledoc """
      3   Result struct returned from any successful query. Its fields are:
      4 
      5     * `command` - An atom or a list of atoms of the query command, for example:
      6       `:select`, `:insert`, or `[:rollback, :release]`;
      7     * `columns` - The column names;
      8     * `rows` - The result set. A list of lists, each inner list corresponding to a
      9       row, each element in the inner list corresponds to a column;
     10     * `num_rows` - The number of fetched or affected rows;
     11     * `connection_id` - The OS pid of the PostgreSQL backend that executed the query;
     12     * `messages` - A list of maps of messages, such as hints and notices, sent by the
     13       the driver during the execution of the query
     14   """
     15 
     16   @type t :: %__MODULE__{
     17           command: atom | [atom],
     18           columns: [String.t()] | nil,
     19           rows: [[term] | binary] | nil,
     20           num_rows: integer,
     21           connection_id: pos_integer,
     22           messages: [map()]
     23         }
     24 
     25   defstruct [:command, :columns, :rows, :num_rows, :connection_id, messages: nil]
     26 end
     27 
     28 if Code.ensure_loaded?(Table.Reader) do
     29   defimpl Table.Reader, for: Postgrex.Result do
     30     def init(%{columns: columns}) when columns in [nil, []] do
     31       {:rows, %{columns: [], count: 0}, []}
     32     end
     33 
     34     def init(result) do
     35       {:rows, %{columns: result.columns, count: result.num_rows}, result.rows}
     36     end
     37   end
     38 end