Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix not null value relation #3446

Merged
merged 5 commits into from
May 23, 2024
Merged

Fix not null value relation #3446

merged 5 commits into from
May 23, 2024

Conversation

uclaros
Copy link
Contributor

@uclaros uclaros commented May 17, 2024

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 :

"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!

@uclaros uclaros marked this pull request as ready for review May 21, 2024 12:46
@tomasMizera
Copy link
Collaborator

Does it fix the issue now @uclaros? :)

@tomasMizera
Copy link
Collaborator

If you merge master here, the iOS CI will pass

@uclaros
Copy link
Contributor Author

uclaros commented May 21, 2024

Does it fix the issue now @uclaros? :)

Yes, this fixes it!

@tomasMizera
Copy link
Collaborator

Test CI failures seem unrelated

Copy link
Collaborator

@tomasMizera tomasMizera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! This is how it behaved previously

@tomasMizera tomasMizera merged commit e952599 into master May 23, 2024
11 of 12 checks passed
@tomasMizera tomasMizera deleted the fix-not-null-value-relation branch May 23, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not null constraint not met when multiple values selected in drop down selector widget
3 participants