fix: allow LEFT JOIN to produce None for nested models
PR Info
- Closes #2617
Bug Fixes
When using LEFT JOIN with a nested Option<Model>, code tried to read the missing
related row as if it were always present. This caused a type error instead of simply
returning None.
This change makes nested optional models behave normal by treating all-null fields as a missing record.
Testing
Added test that validates the fix.
the test case failed, any ideas?
thread 'from_query_result_left_join_with_optional_model_does_not_exist' (9460) panicked at tests/from_query_result_tests.rs:108:10:
succeeds to get the result: Type("A null value was encountered while decoding \"id\"")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
my current understanding: if the parent object is Option<Model>, then it effectively made all children fields Option<T>.
but if a struct has 2 required fields, we can only construct a model if all 2 required fields are Some.
is my understanding correct?
the test case failed, any ideas?
thread 'from_query_result_left_join_with_optional_model_does_not_exist' (9460) panicked at tests/from_query_result_tests.rs:108:10: succeeds to get the result: Type("A null value was encountered while decoding \"id\"") note: run with `RUST_BACKTRACE=1` environment variable to display a backtracemy current understanding: if the parent object is
Option<Model>, then it effectively made all children fieldsOption<T>. but if a struct has 2 required fields, we can only construct a model if all 2 required fields areSome. is my understanding correct?
Looking into this