Fix nested model serialization state tracking
Nested model fields now correctly track their state by querying the
nested model's own isSet() and isValid() methods, rather than
treating them like primitive types.
The previous implementation used the same logic for both primitive
types and nested model objects:
m_fieldIsValid = fromJsonValue(m_field, json["fieldName"]);
m_fieldIsSet = !json["fieldName"].isNull() && m_fieldIsValid;
This works for primitive types but fails for nested models. A model
can be valid but not set when all its fields are optional. The model
must be queried directly to determine its actual state.
The new implementation for nested models:
m_fieldIsValid = m_field.isValid();
m_fieldIsSet = m_field.isSet() || (m_fieldIsValid && object.isEmpty());
This fix enables proper handling of:
- Empty nested objects ({}) - now recognized as "set but empty"
- Missing fields - correctly distinguished from empty fields
- Nested models where all fields are optional
Adds comprehensive test coverage via new Ente schema, which tests
nested model references (Ente.family references Duck, which contains
Duck_family). Tests cover empty objects, missing fields, type
validation, and edge cases.
Removes QEXPECT_FAIL annotations for QTBUG-145568. All previously
failing test cases now pass with the corrected state tracking logic.
Updates petstore tests to handle empty Category objects ({}), which
are now properly distinguished from absent Category fields. Changes
default status from "freaky" to "sold" to match server behavior.
Fixes: QTBUG-145568
Pick-to: 6.11
Change-Id: I7f491cd127d4bc11a1ee5e639bb49afb905e445a
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>