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

Allow missing and null pointer fields to be nil. #6

Merged
merged 1 commit into from
May 18, 2023

Conversation

jodoherty
Copy link

This commit ensures missing fields for pointer field types remain nil:

  • This allows one to distinguish the property wasn't present from the property being NULL when the PtrNil option is false.
  • This also makes it more convenient to reuse structs with pointer field types with various encoders like the standard library JSON marshaler, where you may want to omit a field if it didn't exist in the queried results.

The expectations around this change are captured in the TestMissingFields test.

In addition, it also fixes an edge case where even with PtrNil set to true, pointer field types would always return with a pointer to a zero value instead of being nil even when the query property's value is VT_NULL.

This fix is checked by the TestNullPointerField test.

These changes provide a bit more flexibility when utilizing custom queries with classes that may have different fields on different versions of Windows.

This commit ensures missing fields for pointer field types remain nil:

  * This allows one to distinguish the field wasn't present from the
    field being NULL when the PtrNil option is false.
  * This also makes it more convenient to reuse structs with pointer
    field types with various encoders like the standard library JSON
    marshaler, where you may want to omit a field if it didn't exist in
    the queried results.

The expectations around this change are captured in the
TestMissingFields test.

In addition, it also fixes an edge case where even with PtrNil set to
true, pointer field types would always return with a pointer to a zero
value instead of being nil even when the query property's value is
VT_NULL.

This fix is checked by the TestNullPointerField test.
@yusufpapurcu
Copy link
Owner

Thanks for contribution!

@yusufpapurcu yusufpapurcu merged commit 8468651 into yusufpapurcu:master May 18, 2023
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.

2 participants