I'm trying to test the extension with a simple parent-child relation One-to-Many. I create the models and also the controller and views. All is fine but the Update and Delete operations in child table. When I delete or change any content or add any new record in child table and Update, it generates duplicate entry in the child table.
These are my tables config:
Order Table:
id int 10 Auto Increment, Not Null, Primary Key
order_date date 0 Not Null
qty int 6 Allow Null, NULL as Default
Products Table:
id bigint 15 Auto Increment, Not Null, Primery Key
order_id int 10 Not Null, Foreign Key id in Order table
qty int 4 Not Null
name varchar 150 Not Null
I'm also using RelationTrait, so in Update action is simple as:
`public function actionUpdate($id)
{
$model = $this->findModel($id);
So it seems than in SaveAll() it is not deleting old records or adding new ones.
Reviewing the log, it seems that when Update the model it first deletes all records before insert new ones, and the Delete query is generating an error: "Impossible WHERE". The SQL is: DELETE FROM product WHERE (order_id=8) AND (id<>NULL)
It seems that the ('id'<>NULL) clause in the query is generating the error, because if I run the query in the database, no records are selected. But if I use only DELETE FROM product WHERE (order_id=8), the query is running fine.
Hello,
I'm trying to test the extension with a simple parent-child relation One-to-Many. I create the models and also the controller and views. All is fine but the Update and Delete operations in child table. When I delete or change any content or add any new record in child table and Update, it generates duplicate entry in the child table.
These are my tables config:
Order Table: id int 10 Auto Increment, Not Null, Primary Key order_date date 0 Not Null qty int 6 Allow Null, NULL as Default
Products Table: id bigint 15 Auto Increment, Not Null, Primery Key order_id int 10 Not Null, Foreign Key id in Order table qty int 4 Not Null name varchar 150 Not Null
I'm also using RelationTrait, so in Update action is simple as: `public function actionUpdate($id) { $model = $this->findModel($id);
So it seems than in SaveAll() it is not deleting old records or adding new ones.
Reviewing the log, it seems that when Update the model it first deletes all records before insert new ones, and the Delete query is generating an error: "Impossible WHERE". The SQL is: DELETE FROM
product
WHERE (order_id
=8) AND (id
<>NULL)It seems that the ('id'<>NULL) clause in the query is generating the error, because if I run the query in the database, no records are selected. But if I use only DELETE FROM
product
WHERE (order_id
=8), the query is running fine.What I'm doing wrong?