A quick and dirty fix... There must be a better way to get the belongs_to types proplist though...
diff boss_db_adapter_mongodb_old.erl boss_db_adapter_mongodb.erl
492c492
< unpack_value(AttrName, MongoValue, ValueType)
---
> unpack_value(Type, AttrName, MongoValue, ValueType)
547c547
< unpack_value(_AttrName, [H|T], _ValueType) when is_integer(H) ->
---
> unpack_value(_, _AttrName, [H|T], _ValueType) when is_integer(H) ->
549c549
< unpack_value(_AttrName, {_, _, _} = Value, datetime) ->
---
> unpack_value(_, _AttrName, {_, _, _} = Value, datetime) ->
551,565c551,568
< unpack_value(AttrName, Value, ValueType) ->
< case is_id_attr(AttrName) and (Value =/= "") of
< true ->
< IdType = id_type_from_foreign_key(AttrName),
< unpack_id(IdType, Value);
< false ->
< boss_record_lib:convert_value_to_type(Value, ValueType)
< end.
<
< id_type_from_foreign_key(ForeignKey) ->
< Tokens = string:tokens(atom_to_list(ForeignKey), "_"),
< NameTokens = lists:filter(fun(Token) -> Token =/= "id" end,
< Tokens),
< string:join(NameTokens, "_").
<
---
> unpack_value(RecordType, AttrName, Value, ValueType) ->
> case is_id_attr(AttrName) and (Value =/= "") of
> true ->
> BelongsToTypes=RecordType:belongs_to_types(boss_record:new(RecordType,[])),
> AttrNameAtom=list_to_atom(string:join(lists:reverse(tl(lists:reverse(string:tokens(atom_to_list(AttrName), "_")))),"_")), % drop _id from the end
> case proplists:get_value(AttrNameAtom,BelongsToTypes) of
> undefined ->
> unpack_id(atom_to_list(AttrNameAtom),Value)
> ;
> RealAttrType->
> unpack_id(atom_to_list(RealAttrType),Value)
>
> end
> ;
> false ->
> boss_record_lib:convert_value_to_type(Value, ValueType)
> end
> .