Editor child:parent issue with insert and update

Editor child:parent issue with insert and update

Tester2017Tester2017 Posts: 145Questions: 23Answers: 17

My database has a typical parent<->>child relation which is always 1<->>n. I use constraint rules for this in the database.

If I select a parent and left join it with a child I can do an insert and both the parent and the child are created, but I can not edit them which will lead to a constraint violation.

If I select a child and left join it with its parent I can do an update and both the parent and the child are updated, but I can not create them, which also will lead to a constraint violation.

Probably caused by a "delete-insert" update instead of a "real" update.

Do I miss something or do I just have to write my own update and insert routines?

Answers

  • rf1234rf1234 Posts: 2,806Questions: 85Answers: 406

    "If I select a parent and left join it with a child I can do an insert and both the parent and the child are created, but I can not edit them which will lead to a constraint violation."

    Hmm ... If I create a parent and want to create the child at the same time (and the child can also be a link table to some other table) I had made the experience that the insert of the child table was not done. I did it myself manually.Editing later on was no problem. And my link table wasn't edited anyway because I defined delete "cascade" and update "restrict" in MySQL. That's maybe something worth checking?!

    "If I select a child and left join it with its parent I can do an update and both the parent and the child are updated, but I can not create them, which also will lead to a constraint violation."

    I actually experienced the same behaviour in this case. So can't really follow.

    One thing that may help to understand what is really happening: Use the debug option in Editor and take a look at the SQL that is being generated by Editor. That helped me a lot to understand what's going on. Please also see Allan's latest comment on this in this post: https://datatables.net/forums/discussion/43722/bug-in-postsubmit-submitsuccess-events#latest

  • allanallan Posts: 61,665Questions: 1Answers: 10,096 Site admin

    For 1:n parent / child relationships in Editor, you'll probably need to use something like in this post. Its presents as a table above and below, but it could also be done with a table in a DataTables child row.

    Allan

  • Tester2017Tester2017 Posts: 145Questions: 23Answers: 17

    Allan and rf1234 I thank you both for spending time on my problem and trying to help me. Although the answers were not directly the ones for my solution, it pointed me to a lot of more interesting content.

    The final solution I have chosen is to write my own CRUD-routines. But again thank you both for all the efforts!

  • rf1234rf1234 Posts: 2,806Questions: 85Answers: 406

    Roll your own is always a good option! Good luck!

  • Tester2017Tester2017 Posts: 145Questions: 23Answers: 17

    Just to come back on this issue.

    What happened was that I forgot to set 1 specific field. So this issue had all to do with an error of myself.

This discussion has been closed.