Doctrine inheritance mapping -- add cascade on update to id field

71 views Asked by At

I have set my datas with separate tables inheritance mapping, but Doctrine seems to give very limited controls about it.
Among other issues, one I get is that it only cascades on DELETE.

(I use XML mapping)
From what I see, cascades are put inside the relation tag, which is absent on an ID column using inheritance mapping.

Is there no easy way to ensure my datas stay consistent ? (e.g. if accessed from outside) ?
Without this, even a simple update on one of my lines of data becomes complex, since it would violate constraints.

EDIT @Cerad : here's a sample working example. I use MariaDB 10.3.22

CREATE DATABASE kaskade;
USE kaskade;

CREATE TABLE a (main_id INT PRIMARY KEY);
CREATE TABLE b (fk_id INT PRIMARY KEY);
INSERT INTO a (main_id) VALUES (1), (2), (3);
INSERT INTO b (fk_id) VALUES (1), (2), (3);

ALTER TABLE b ADD CONSTRAINT id_link FOREIGN KEY (fk_id) REFERENCES a(main_id) ON UPDATE CASCADE;

SELECT * from a;
SELECT * from b;
UPDATE a SET main_id = main_id + 10 WHERE main_id > 1;
#UPDATE b SET id = 5 where id = 1;  // Would be rejected, since the cascade must come from the "parent"
SELECT * from a;
SELECT * from b;
0

There are 0 answers