It is obviously the unpack_id(_,_) fun that messes up things in
boss_db_adapter_mongodb.erl. It should respect the model defined by
belongs_to_<model> when unpacking the id.
On Saturday, January 3, 2015 11:02:22 PM UTC+1, mpeter wrote:
>
> Dear All,
>
> Sorry for not getting back earlier - notification did not came that it has
> been answered.
> The problem is still present and very easy to reproduce.
> Assume the following simple use case.
> We have foo and bar. bar has an owner and a manager.
>
> -module(foo,[Id,Name]).
> -----
> -module(bar,[Id, OwnerId, ManagerId]).
> -belongs_to_foo(owner).
> -belongs_to_foo(owner).
> ------------
> simple test code with Mongo:
> í{ok,{_,Id,_}}=(foo:new(id,"name")):save().
> {ok,{_,Id2,_,_}}=(bar:new(id,Id,Id)):save().
> B=boss_db:find(Id2).
> B:owner().
> B:manager().
>
> the boss_db:find will rturn the object with changed (useless) ids. This is
> a serious problem which makes it impossible to have multiple belongs_to
> associations to the same type.
>
> Is there a solution to overcome this?
>
>
> Thanks,
> Best,
> Peter
>
> On Thursday, January 17, 2013 8:08:08 PM UTC+1, Holocene wrote:
>>
>> On Sat, Jan 5, 2013 at 12:45 PM, mpeter <[email protected]>
>> wrote:
>>
>> > If I add a new greeting with a specific user id, it gets saved
>> properly, but
>> > the value in the OwnerId column changes from usr-1 usr-2 etc to oner-1,
>> > owner-2 etcwhen saved.
>> >
>>
>> The belongs_to(usr) in your model is superseding the belongs_to(owner)
>> somehow. Either that, or the variable where you are passing in the
>> OwnerId is being assigned to UsrId instead of OwnerId
>>
>>
>>
>>
>> --
>> --
>> Sam Rose
>> Hollymead Capital Partners, LLC
>> Cel: +1-(517)-974-6451
>> email: [email protected]
>> http://hollymeadcapital.com
>> http://p2pfoundation.net
>> http://socialmediaclassroom.com
>>
>> "The universe is not required to be in perfect harmony with human
>> ambition." - Carl Sagan
>>
>
--
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/9990ace1-7cff-4dff-b35e-b43bd04b6394%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.