From fe6db38bec2d28b67818cbeafb57c8b52cf29a3d Mon Sep 17 00:00:00 2001 From: lsowen Date: Fri, 2 Nov 2012 23:06:34 -0400 Subject: [PATCH] flatzone call was returning a list. Update return value convention in ezic_db_ets:flatzone() to match ezic_db:flatzone(). --- src/ezic_db_ets.erl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/ezic_db_ets.erl b/src/ezic_db_ets.erl index 742dc04..f3c570f 100644 --- a/src/ezic_db_ets.erl +++ b/src/ezic_db_ets.erl @@ -90,8 +90,18 @@ handle_call({all, Table}, _, Ets) -> Matches= ets:lookup(Ets, Table), {reply, Matches, Ets}; handle_call({flatzone, Date, Name}, _, Ets) -> - Matches= ets:select(Ets, ezic_flatten:ms(Date, Name)), - {reply, Matches, Ets}; + FlatZones= ets:select(Ets, ezic_flatten:ms(Date, Name)), + Result= case length(FlatZones) of + 1 -> + hd(FlatZones); + 2 -> + erlang:error(ambiguous_zone, FlatZones); + 0 -> + erlang:error(no_zone); + _ -> + erlang:error(should_not_happen, {FlatZones, Date, Name}) + end, + {reply, Result, Ets}; %handle_call({insert_all, Records}, _, Ets) -> % Result= ets:insert(Ets, Records), % {reply, Result, Ets};