check deeply nested values section of manual 
http://www.chicagoboss.org/api-record.html

get(Path::string()) -> Value

Returns a deeply nested value described by a dot-separated Path (e.g. 
"puppy.mother.name")

On Thursday, July 3, 2014 6:05:07 PM UTC+4, graeme defty wrote:
>
> Another interesting one...
>
> One of my models was returning 'undefined' in response to boss_db:find/1
>
> I tracked it down to boss_db:find/2, part of which looks like this:
>
> <pre>
> find(Key, Timeout) when is_list(Key), is_integer(Timeout) ->
>     [IdToken|Rest] = string:tokens(Key, "."),
>     case db_call({find, IdToken}, Timeout) of
>         undefined -> undefined;
>         {error, Reason} -> {error, Reason};
>         BossRecord -> BossRecord:get(string:join(Rest, "."))
>     end;</pre>
>
> For some reason the BossRecord:get call on the second last line was 
> returning 'undefined' on one of my models. (I didnt try them all, but 8-10 
> others I tried were fine!)
>
> I fixed the problem by changing the code as follows:
>
> <pre>
> find(Key, Timeout) when is_list(Key), is_integer(Timeout) ->
>     [IdToken|Rest] = string:tokens(Key, "."),
>     case db_call({find, IdToken}, Timeout) of
>         undefined -> undefined;
>         {error, Reason} -> {error, Reason};
>         BossRecord -> 
>             case Rest of
>                 []    ->    BossRecord;
>                 _    ->    BossRecord:get(string:join(Rest, "."))
>             end
>     end;
> </pre>
>
>
> I have no idea if this is a good solution (though it looks reasonable) and 
> I am also equally puzzled by the fact that it only happened with one of my 
> models, but then I dont know what the 'get' function is supposed to do. 
> Perhaps someone wiser than I . . . . 
>
>
> g
>
>
>
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at http://groups.google.com/group/chicagoboss.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/chicagoboss/7614a9a2-5337-45e5-bbf0-29d625908166%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to