Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#138] Add node name to test-shell target #193

Merged
merged 1 commit into from
Sep 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ CT_OPTS = -cover test/sumo.coverspec -vvv -erl_args -config ${CONFIG}
SHELL_OPTS = -name ${PROJECT}@`hostname` -config ${CONFIG} -s sync

test-shell: build-ct-suites app
erl -pa ebin -pa deps/*/ebin -pa test -s lager -s sync -config ${CONFIG}
erl -name ${PROJECT}@`hostname` -pa ebin -pa deps/*/ebin -pa test -s lager -s sync -config ${CONFIG}

erldocs:
erldocs . -o docs
Expand Down
23 changes: 9 additions & 14 deletions src/sumo_store_pgsql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,10 @@ create_column(Field) ->
create_column(Name, integer, Attrs) ->
case lists:member(auto_increment, Attrs) of
true ->
[escape(atom_to_list(Name)), create_column_options(Attrs)];
AttrsNoAutoInc = lists:delete(auto_increment, Attrs),
[escape(atom_to_list(Name)),
" SERIAL ",
create_column_options(AttrsNoAutoInc)];
false ->
[escape(atom_to_list(Name)), " INTEGER ", create_column_options(Attrs)]
end;
Expand All @@ -333,15 +336,11 @@ create_column(Name, datetime, Attrs) ->
[escape(atom_to_list(Name)), " TIMESTAMP ", create_column_options(Attrs)].

create_column_options(Attrs) ->
lists:filter(fun(T) -> is_list(T) end, lists:map(
fun(Option) ->
create_column_option(Option)
end,
Attrs
)).
Options = lists:map(fun create_column_option/1, Attrs),
lists:filter(fun is_list/1, Options).

create_column_option(auto_increment) ->
[" SERIAL "];
throw({badarg, "Only integer can be auto_increment"});
create_column_option(not_null) ->
[" NOT NULL "];
create_column_option({length, X}) ->
Expand All @@ -352,12 +351,8 @@ create_column_option(_Option) ->
create_index(Field) ->
Name = sumo_internal:field_name(Field),
Attrs = sumo_internal:field_attrs(Field),
lists:filter(fun(T) -> is_list(T) end, lists:map(
fun(Attr) ->
create_index(Name, Attr)
end,
Attrs
)).
Attrs1 = [create_index(Name, Attr) || Attr <- Attrs],
lists:filter(fun is_list/1, Attrs1).

create_index(Name, id) ->
["PRIMARY KEY(", escape(atom_to_list(Name)), ")"];
Expand Down
2 changes: 1 addition & 1 deletion test/sumo_test_people_pgsql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
-spec sumo_schema() -> sumo:schema().
sumo_schema() ->
Fields =
[sumo:new_field(id, integer, [id, auto_increment]),
[sumo:new_field(id, integer, [id, not_null, auto_increment]),
sumo:new_field(name, string, [{length, 255}, not_null]),
sumo:new_field(last_name, string, [{length, 255}, not_null]),
sumo:new_field(age, integer),
Expand Down