The bug is as follows:
Not null constraint on multi-select value relations is not met when selecting values,
but works OK as long as a single value is deselected.
If there is no not null constraint, the log looks like this when clicking confirm selection :
"Search (0) completed after 7ms, results: 1191"
"Search (0) completed after 3ms, results: 10"
"Search (0) completed after 4ms, results: 1191"
DEBUG QList(273) QVariant(QString, "{BS04.01}")
DEBUG QList(260, 261) QVariant(QString, "{BS04.01}")
"Search (1) completed after 0ms, results: 10"
"Search (1) completed after 3ms, results: 1191"
When the not null constraint is set, there appears a binding loop :
"Search (2) completed after 6ms, results: 10"
"Search (5) completed after 13ms, results: 1191"
"Search (0) completed after 0ms, results: 10"
"Search (0) completed after 3ms, results: 1191"
DEBUG QList(273) QVariant(QString, "{BS04.01}")
DEBUG QList(260, 261) QVariant(QString, "{BS04.01}")
DEBUG QList() QVariant(QString, "{BS04.01}")
DEBUG QList(273) QVariant(Invalid)
qrc:/com.merginmaps/imports/MMInput/form/MMFormPage.qml:267:7: QML Loader: Binding loop detected for property "fieldValue"
DEBUG QList(260, 261) QVariant(Invalid)
DEBUG QList() QVariant(Invalid)
qrc:/com.merginmaps/imports/MMInput/form/MMFormPage.qml:267:7: QML Loader: Binding loop detected for property "fieldValue"
"Search (6) was canceled after 0ms, results: 120"
"Search (1) completed after 0ms, results: 10"
"Search (7) completed after 3ms, results: 1191"
And if a second value is checked and then immediately unchecked, it works correctly and the log is:
"Search (0) completed after 14ms, results: 1191"
"Search (0) completed after 3ms, results: 10"
"Search (0) completed after 3ms, results: 1191"
DEBUG QList(273) QVariant(QString, "{BS04.01}")
DEBUG QList(260, 261) QVariant(QString, "{BS04.01}")
DEBUG QList() QVariant(QString, "{BS04.01}")
"Search (1) completed after 0ms, results: 10"
"Search (1) completed after 3ms, results: 1191"
When unchecking a value, the array containing the selected ids is copied
root.selected = root.selected.filter( ( x ) => x !== val )
which apparently fixes the issue...
So creating a copy of the array when adding values too brings us the expected behavior!
This is fixing the symptom instead of the cause, so @tomasMizera I think I need your wisdom!
This is an attempt to Fix #3418
The bug is as follows: Not null constraint on multi-select value relations is not met when selecting values, but works OK as long as a single value is deselected.
If there is no not null constraint, the log looks like this when clicking confirm selection :
When the not null constraint is set, there appears a binding loop :
And if a second value is checked and then immediately unchecked, it works correctly and the log is:
When unchecking a value, the array containing the selected ids is copied
which apparently fixes the issue... So creating a copy of the array when adding values too brings us the expected behavior!
This is fixing the symptom instead of the cause, so @tomasMizera I think I need your wisdom!