Browse Source

Merge pull request #154 from zmstone/fix-epgsqla-spec

Fix epgsqla and epgsqli API specs
Sergey Prokhorov 7 years ago
parent
commit
90d199b5ed
4 changed files with 13 additions and 11 deletions
  1. 1 1
      src/epgsql.app.src
  2. 1 1
      src/epgsql.erl
  3. 2 2
      src/epgsqla.erl
  4. 9 7
      src/epgsqli.erl

+ 1 - 1
src/epgsql.app.src

@@ -1,6 +1,6 @@
 {application, epgsql,
 {application, epgsql,
  [{description, "PostgreSQL Client"},
  [{description, "PostgreSQL Client"},
-  {vsn, "3.4.0"},
+  {vsn, "3.4.1"},
   {modules, []},
   {modules, []},
   {registered, []},
   {registered, []},
   {applications, [kernel,
   {applications, [kernel,

+ 1 - 1
src/epgsql.erl

@@ -36,7 +36,7 @@
 
 
 -include("epgsql.hrl").
 -include("epgsql.hrl").
 
 
--type sql_query() :: string() | iodata().
+-type sql_query() :: iodata().
 -type host() :: inet:ip_address() | inet:hostname().
 -type host() :: inet:ip_address() | inet:hostname().
 -type connection() :: pid().
 -type connection() :: pid().
 -type connect_option() ::
 -type connect_option() ::

+ 2 - 2
src/epgsqla.erl

@@ -69,7 +69,7 @@ set_notice_receiver(C, PidOrName) ->
 get_cmd_status(C) ->
 get_cmd_status(C) ->
     epgsql_sock:get_cmd_status(C).
     epgsql_sock:get_cmd_status(C).
 
 
--spec squery(epgsql:connection(), string()) -> reference().
+-spec squery(epgsql:connection(), epgsql:sql_query()) -> reference().
 squery(C, Sql) ->
 squery(C, Sql) ->
     cast(C, {squery, Sql}).
     cast(C, {squery, Sql}).
 
 
@@ -90,7 +90,7 @@ parse(C, Sql) ->
 parse(C, Sql, Types) ->
 parse(C, Sql, Types) ->
     parse(C, "", Sql, Types).
     parse(C, "", Sql, Types).
 
 
--spec parse(epgsql:connection(), iolist(), string(), [epgsql_type()]) -> reference().
+-spec parse(epgsql:connection(), iolist(), epgsql:sql_query(), [epgsql_type()]) -> reference().
 parse(C, Name, Sql, Types) ->
 parse(C, Name, Sql, Types) ->
     cast(C, {parse, Name, Sql, Types}).
     cast(C, {parse, Name, Sql, Types}).
 
 

+ 9 - 7
src/epgsqli.erl

@@ -62,18 +62,18 @@ get_parameter(C, Name) ->
 set_notice_receiver(C, PidOrName) ->
 set_notice_receiver(C, PidOrName) ->
     epgsql_sock:set_notice_receiver(C, PidOrName).
     epgsql_sock:set_notice_receiver(C, PidOrName).
 
 
--spec get_cmd_status(epgsql:connection()) -> {ok, Status}
-                                          when
-      Status :: undefined | atom() | {atom(), integer()}.
+-spec get_cmd_status(epgsql:connection()) -> {ok, Status} when
+          Status :: undefined | atom() | {atom(), integer()}.
 get_cmd_status(C) ->
 get_cmd_status(C) ->
     epgsql_sock:get_cmd_status(C).
     epgsql_sock:get_cmd_status(C).
 
 
--spec squery(epgsql:connection(), string()) -> reference().
+-spec squery(epgsql:connection(), epgsql:sql_query()) -> reference().
 squery(C, Sql) ->
 squery(C, Sql) ->
     incremental(C, {squery, Sql}).
     incremental(C, {squery, Sql}).
 
 
-equery(C, Sql) ->
-    equery(C, Sql, []).
+-spec equery(epgsql:connection(), #statement{}) -> reference().
+equery(C, Statement) ->
+    equery(C, Statement, []).
 
 
 -spec equery(epgsql:connection(), #statement{}, [epgsql:typed_param()]) -> reference().
 -spec equery(epgsql:connection(), #statement{}, [epgsql:typed_param()]) -> reference().
 equery(C, Statement, TypedParameters) ->
 equery(C, Statement, TypedParameters) ->
@@ -83,13 +83,15 @@ equery(C, Statement, TypedParameters) ->
 prepared_query(C, Statement, TypedParameters) ->
 prepared_query(C, Statement, TypedParameters) ->
     incremental(C, {prepared_query, Statement, TypedParameters}).
     incremental(C, {prepared_query, Statement, TypedParameters}).
 
 
+-spec parse(epgsql:connection(), epgsql:sql_query()) -> reference().
 parse(C, Sql) ->
 parse(C, Sql) ->
     parse(C, "", Sql, []).
     parse(C, "", Sql, []).
 
 
+-spec parse(epgsql:connection(), epgsql:sql_query(), [epgsql_type()]) -> reference().
 parse(C, Sql, Types) ->
 parse(C, Sql, Types) ->
     parse(C, "", Sql, Types).
     parse(C, "", Sql, Types).
 
 
--spec parse(epgsql:connection(), iolist(), string(), [epgsql_type()]) -> reference().
+-spec parse(epgsql:connection(), iolist(), epgsql:sql_query(), [epgsql_type()]) -> reference().
 parse(C, Name, Sql, Types) ->
 parse(C, Name, Sql, Types) ->
     incremental(C, {parse, Name, Sql, Types}).
     incremental(C, {parse, Name, Sql, Types}).