You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When doing a deep UPDATE when using an ambiguous WHERE clause it creates children without parents.
Detailed steps to reproduce
awaitINSERT([{ID: 1},{ID: 2}]).into(Genres)constchanges=awaitUPDATE(Genres).where(`ID > `,{val: 0}).with({children: [{ID: 3},{ID: 4},{ID: 5}]})expect(changes|0).to.be.eq(2)constfinalState=awaitCQL`SELECT *,children{*} from ${Genres}`constresult=[{"ID": 1,"children": []},// Does not have children{"ID": 2,"children": []},// Does not have children// All children are created, but don't have any parent{"ID": 3,"children": []},{"ID": 4,"children": []},{"ID": 5,"children": []},]
Details about your project
package
version
@sap/cds
7.5.x
@cap-js/db-service
all
The text was updated successfully, but these errors were encountered:
I think that this is acceptable. If there's no clear value to be set, this must be set by the application.
We could discuss whether this should cause an error instead.
As deep updates like this can only be done to compositions it does not make sense to allow for updates that have / could result in multiple parents.
// allowed as it guarantees a single parentUDPATE(Genres,{ID: 1}).with({children:[...]})// Could be allowed as the where clause strictly checks all keysUPDATE(Genres).where(`ID = `,1).with({children:[...]})// Could be rejected as there is the chance it will match multiple parentsUPDATE(Genres).with({children:[...]})UPDATE(Genres).where(`ID != `,0).with({children:[...]})...etc
Description of erroneous behaviour
When doing a deep
UPDATE
when using an ambiguousWHERE
clause it creates children without parents.Detailed steps to reproduce
Details about your project
The text was updated successfully, but these errors were encountered: