On 09/04/2013 13:18, Werner wrote:
On 09/04/2013 12:56, Werner wrote:
Hi,
On 01/03/2013 15:59, Werner wrote:
Hi,
Found it in the doc, the "Adjacency List Relationship" is what I
wanted.
http://docs.sqlalchemy.org/en/latest/orm/relationships.html#adjacency-list-relationships
I am having a problem when I try to delete an item where I use this,
I get this exception: ...
...
Do I have to manually clear out the foreign keys first or can I fix
it by correctly setting things in the model?
I currently have:
StandardColumnMixin creates the "id" and date/user creation/update
columns.
class Winerack(DeclarativeBase, mix.StandardColumnMixin):
__tablename__ = u'winerack'
name = sa.Column(sa.Unicode(length=30))
...
class Wineracku(DeclarativeBase, mix.StandardColumnMixin):
__tablename__ = u'wineracku'
description = sa.Column(sa.Unicode(length=30))
...
fk_winerack_id = sautils.reference_col('winerack')
fk_combrack_id = sa.Column(cts.KEYS, sa.ForeignKey('wineracku.id'))
Winerack.wineracku = sao.relationship('Wineracku', backref='winerack',
cascade="all, delete,
delete-orphan")
Wineracku.winerackb = sao.relationship('Winerackb', backref='wineracku',
cascade="all, delete,
delete-orphan")
Wineracku.combrack = sao.relationship('Wineracku',
remote_side=[Wineracku.id],
cascade="all, delete,
delete-orphan",
single_parent=True)
I think I found it, adding a backref to the combrack relationship like
this:
Wineracku.combrack = sao.relationship('Wineracku',
backref='winerackucomb',
remote_side=[Wineracku.id],
cascade="all, delete,
delete-orphan",
single_parent=True)
Seems to work, need to test this some more.
Seems to isn't good enough(:.
I don't get an error any more but on delete not everything is deleted.
So, I am still searching how to setup the "Adjacency List Relationship"
correctly so it works for me on deleting a parent of the list.
Any tips or links to further reading would be very appreciated.
Werner
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.