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 extension:

http://docs.sqlalchemy.org/en/rel_0_9/orm/extensions/associationproxy.html#simplifying-association-objects

Hope that helps,

Simon


On Thu, Mar 5, 2015 at 10:43 AM, Pavel S <pa...@schon.cz> wrote:
> 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 'user can me member of
>> group via multiple systems'.
>>
>> class User(Base):
>>     __tablename__ = 'User'
>>
>>     name = Column('Name', Unicode(256), primary_key=True)
>>
>> class Group(Base):
>>     __tablename__ = 'Group'
>>
>>     name = Column('Name', Unicode(256), primary_key=True)
>>
>> class User2Group(Base):
>>     __tablename__ = 'User2Group'
>>
>>     userName = Column('UserName', Unicode(256), ForeignKey(User.name),
>> primary_key=True)
>>     groupName = Column('GroupName', Unicode(256), ForeignKey(Group.name),
>> primary_key=True)
>>     systemName = Column('SystemName', Enum('A', 'B', 'C'),
>> primary_key=True)
>>
>> User.groups = relationship(Group, secondary=User2Group.__table__)
>>
>>
>> Table User2Group looks like following
>>
>> UserName | GroupName | SystemName
>> ---------------------------------
>> fred     |  admins   | A
>> fred     |  admins   | B
>> fred     |  admins   | C
>>
>>
>> However when trying to delete user 'fred' wich is assinged to group
>> 'admins' via multiple systems A, B, C.
>>
>> I'm getting error: DELETE statement on table 'User2Group' expected to
>> delete 1 row(s); Only 3 were matched.
>>
>> Did I misconfigured something?
>>
>> Thanks
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sqlalchemy+unsubscr...@googlegroups.com.
> To post to this group, send email to sqlalchemy@googlegroups.com.
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to