just add a cascade directive to your relationship:
'_meta': relation(
UserMeta,
collection_class=attribute_mapped_collection('key'),
passive_deletes=True,
cascade="all, delete-orphan"
),
when UserMeta becomes an "orphan" it will be deleted instead of the FK marked
as NULL.
On Jun 21, 2013, at 11:43 AM, Felix Schwarz <[email protected]>
wrote:
>
> I'm using SQLAlchemy's association_proxy to have extensible metadata for my
> mapped classes.
>
> So for example I can say:
> user.meta[u'foo'] = u'bar'
>
> However when I try to delete an individual item I get an IntegrityError:
> users_meta.user_id may not be NULL ...
>
> So likely I'm missing some 'cascade' configuration in my schema setup or so
> and I'm glad for any pointers.
>
> I attached a minimal script to reproduce the issue. Thank you very much,
> fs
>
> PS: I found
> http://docs.sqlalchemy.org/en/rel_0_7/dialects/sqlite.html#sqlite-foreign-keys
> but that doesn't seem to make a difference in my case
> (sqlite-3.7.13-2.fc18.x86_64).
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/sqlalchemy.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> <meta-test.py>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.