Skip to content

Conversation

@denyszhak
Copy link

PR Info

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.

@denyszhak denyszhak force-pushed the fix/nested-option-model branch from 388a538 to e65735d Compare December 7, 2025 14:18
@denyszhak denyszhak force-pushed the fix/nested-option-model branch from e65735d to 5b37411 Compare December 7, 2025 14:19
@Huliiiiii Huliiiiii requested a review from tyt2y3 December 8, 2025 09:23
@denyszhak denyszhak force-pushed the fix/nested-option-model branch from 094b391 to b8e7b8b Compare December 8, 2025 09:45
@denyszhak denyszhak force-pushed the fix/nested-option-model branch from b8e7b8b to d70adc5 Compare December 8, 2025 09:45
@tyt2y3 tyt2y3 requested a review from Huliiiiii December 8, 2025 13:11
@tyt2y3
Copy link
Member

tyt2y3 commented Dec 8, 2025

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?

@denyszhak
Copy link
Author

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?

Looking into this

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.

FromQueryResult fails when having nested Option<Model>

2 participants