marat-gainullin / platypus-js

Apache License 2.0
9 stars 9 forks source link

model.save() works bad in queries with joined tables (CRITICAL BUG!) #99

Open valeriy-maslov opened 7 years ago

valeriy-maslov commented 7 years ago

This is more like web client part bug. This thing was found while modifying model entity for query with multiple tables connected with outer join. The app project with test case will be soon. Right now I can provide only a simple text explanation. Let's say we have 2 tables A & B connected with foreign key. In the project we make a query with this tables joined by outer join, for this example let's say it is left outer join for A & B. App makes requery() of this entity and changes some data. While using left outer join there is possibility of empty fields appearing for table B in case of left join, which means that there is no matching record in B. If there is it's okay, we can modify data with no problem. But if there is not matching record, so platypus must insert it into B and update foreign key field in A. But it does not do that, ORM tries to modify nonexist record in B instead.

marat-gainullin commented 7 years ago

It would be quite new functionality for the Platypus ORM. This situation pushes us to turn some updates into insert/update/update while applying a change log to a database.

Can you please turn your test project into test case in PlatypusTests ?

valeriy-maslov commented 7 years ago

I can do it, okay. I'll write you when it will be finished.