Permalink
Browse files

Renamed new sqerl types, prefixed with sqerl_.

  • Loading branch information...
1 parent 22a9f3b commit 9c813592f6f243e8438a68a0a0fae1aaed1255dd langloisjp committed Oct 15, 2012
Showing with 15 additions and 13 deletions.
  1. +5 −5 include/sqerl.hrl
  2. +2 −2 src/sqerl.erl
  3. +2 −2 src/sqerl_client.erl
  4. +3 −1 src/sqerl_mysql_client.erl
  5. +3 −3 src/sqerl_pgsql_client.erl
View
@@ -23,9 +23,9 @@
{conflict, term()} |
{foreign_key, term()}.
--type row() :: [{binary(), term()}].
--type rows() :: [row()].
--type sql() :: string() | binary().
--type dbquery() :: atom() | sql().
--type dbresults() :: {ok, integer() | rows()} | {error, atom() | tuple()}.
+-type sqerl_row() :: [{binary(), term()}].
+-type sqerl_rows() :: [sqerl_row()].
+-type sqerl_sql() :: string() | binary().
+-type sqerl_query() :: atom() | sqerl_sql().
+-type sqerl_results() :: {ok, integer() | sqerl_rows()} | {error, atom() | tuple()}.
View
@@ -117,7 +117,7 @@ execute_statement(StmtName, StmtArgs, XformName, XformArgs) ->
%% @doc Execute query or statement with no parameters
%% See execute/2 for return info.
--spec execute(dbquery() | atom()) -> dbresults().
+-spec execute(sqerl_query()) -> sqerl_results().
execute(QueryOrStatement) ->
execute(QueryOrStatement, []).
@@ -132,7 +132,7 @@ execute(QueryOrStatement) ->
%%
%% Row is a proplist, e.g. [{<<"id">>, 1}, {<<"name">>, <<"John">>}]
%%
--spec execute(dbquery(), [] | [term()]) -> dbresults().
+-spec execute(sqerl_query(), [] | [term()]) -> sqerl_results().
execute(QueryOrStatement, Parameters) ->
F = fun(Cn) -> sqerl_client:execute(Cn, QueryOrStatement, Parameters) end,
with_db(F).
View
@@ -75,12 +75,12 @@ behaviour_info(_) ->
%% @doc Execute SQL or prepared statement with no parameters.
%% See execute/3 for return values.
--spec execute(pid(), dbquery()) -> dbresults().
+-spec execute(pid(), sqerl_query()) -> sqerl_results().
execute(Cn, QueryOrStatement) ->
execute(Cn, QueryOrStatement, []).
%% @doc Execute SQL or prepared statement with parameters.
--spec execute(pid(), dbquery(), [any()]) -> dbresults().
+-spec execute(pid(), sqerl_query(), [any()]) -> sqerl_results().
execute(Cn, QueryOrStatement, Parameters) when is_pid(Cn) ->
gen_server:call(Cn, {execute, QueryOrStatement, Parameters}, infinity).
@@ -39,7 +39,9 @@
%% @doc execute query or prepared statement.
%% Emysql has a common interface for both queries and prepared statements.
--spec execute(StatementOrQuery :: dbquery(), Parameters :: [any()], State :: #state{}) -> {dbresults(), #state{}}.
+-spec execute(StatementOrQuery :: sqerl_query(),
+ Parameters :: [any()],
+ State :: #state{}) -> {sqerl_results(), #state{}}.
execute(NameOrQuery, Args, #state{cn=Cn}=State) ->
TArgs = input_transforms(Args, State),
case catch emysql_conn:execute(Cn, NameOrQuery, TArgs) of
@@ -60,10 +60,10 @@
%%
%% Row: proplist e.g. [{<<"id">>, 1}, {<<"name">>, <<"Toto">>}]
%%
--spec execute(StatementOrQuery :: dbquery(),
+-spec execute(StatementOrQuery :: sqerl_query(),
Parameters :: [any()],
State :: #state{}) ->
- {dbresults(), #state{}}.
+ {sqerl_results(), #state{}}.
execute(SQL, Parameters, #state{cn=Cn}=State) when is_binary(SQL) ->
TParameters = input_transforms(Parameters),
DBResult = pgsql:equery(Cn, SQL, TParameters),
@@ -201,7 +201,7 @@ format_result_test() ->
%% Result packet can be from a prepared statement execution
%% (column data is embedded in prepared statement record),
%% or from a simple query.
--spec unpack_rows(#prepared_statement{} | [sql()], [tuple()]) -> rows().
+-spec unpack_rows(#prepared_statement{} | [sqerl_sql()], [tuple()]) -> sqerl_rows().
unpack_rows(#prepared_statement{output_fields=ColumnData}, Rows) ->
%% Takes in a prepared statement record that
%% holds column data that holds column names

0 comments on commit 9c81359

Please sign in to comment.