Hi Charles,
i created a table which is related to another table by a ForeignKeyField and on='CASCADE' policy in Sqlite.
It seems like if i delete a record from the parent table, the children are not deleted.
Here is a test that proves that behavior:
https://gist.github.com/aellwein/9e814769196e5524e94199163aa4a0bd
Am i doing something wrong?
Thanks!
Alex
Looks like sqlite by default has foreign key support turned off:
http://stackoverflow.com/a/13641365/724251
Need to add something like:
Tweet.raw("PRAGMA foreign_keys=ON").execute()
Might be a nicer way included somewhere in the peewee docs.
@alexlatchford
thanks for pointing it out.
Seems to be mentioned in the documentation, in http://docs.peewee-orm.com/en/latest/peewee/database.html?#additional-connection-initialization
Although imho it is a little bit scary, that referential integrity is turned off by default.
@aellwein -- don't use SQLite if you don't know how it works. Simple as that.