Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Simon King
Are you sure? I just tested it (using the definitions from the "Simplifying Association Objects" section) with the following at the bottom: if __name__ == '__main__': user = User('log') user.keywords = [Keyword('one'), Keyword('two')] for uk in user.user_keywords: print uk, uk.

Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
Yes. However doing so: user.keywords = [ Keyword('one'), Keyword('two') ] ...will create UserKeywords with user unset. This is the problem. Dne čtvrtek 5. března 2015 15:11:20 UTC+1 Simon King napsal(a): > > I haven't looked at your code closely so I'm not sure what the problem > is, but I'm n

Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Simon King
I haven't looked at your code closely so I'm not sure what the problem is, but I'm not sure your creator factory should be necessary. The association proxy docs say that something like: kw = Keyword('one') user.keywords.append(kw) has the same effect as: kw = Keyword('one') uk =

Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
Hi, I just noticed that User.groups relationship is not needed at all (it was a relict of previous setup before System column was added). So the problem is completely gone. --- I already use *AssociationProxy* pattern in order to have relations like *User.A_groups, User.B_group**s, USer.C_gr

Re: [sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Simon King
Glad you've figured it out. This is touched on briefly in the docs, in the note at the bottom of: http://docs.sqlalchemy.org/en/rel_0_9/orm/basic_relationships.html#association-object As an alternative to making User.groups a relationship, you could also consider using the Association Proxy exten

[sqlalchemy] Re: many-to-many relation: unexpected count of rows

2015-03-05 Thread Pavel S
Hi, Adding viewonly=True on User.groups relationship solved the issue. cheers! Dne čtvrtek 5. března 2015 11:26:58 UTC+1 Pavel S napsal(a): > > Hello, > > I have relation User-User2Group-Group with additional attribute System on > User2Group table. > The System is part of primary key, which means