-
Notifications
You must be signed in to change notification settings - Fork 39
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
Cannot get nil value from BackingStore with delta query when a property value was changed to nil (empty) #725
Comments
Hi @baywet @andrueastman This is a case where the json payload has explicitly defined a field as null, and the intention is to differentiate fields that were not returned but are with a nil value, vs fields that were explicitly set as nil because the value is null. |
Thanks for the call out. Andrew, Ronald, don't hesitate to share suggestions if you have other ideas here. |
One thing we could try is play around with the serialization hooks and provide and possibly provide an alternative serialization factory implementation (this would require some investigation and thinking through). By having the alternative implementation have the actions to initialize the store before the json payload is deserialized(rather than after) we could have the store initialized with the values from the API in such a scenario to include nulls and other values.... |
A pointer to an uninitialized value and a nil would evaluate to the same value but different types type Null interface{}
func checkType(v interface{}) {
switch v := v.(type) {
case nil:
fmt.Println("nil value")
case *Null:
fmt.Println("Pointer to Null")
default:
fmt.Printf("Unknown type: %T\n", v)
}
}
func main() {
var a *Null
var b *int
checkType(nil) // nil value
checkType(a) // Pointer to Null
checkType(b) // Unknown type: *int
if a == nil {
fmt.Println("a is nil")
}
if a == (*Null)(nil) {
fmt.Println("a is null")
}
} a possible solution is to define a |
Wouldn't any object value (non-nil) satisfy this null interface since it's empty? |
Yes it will, but it will give the ability to differentiate is a serialized value was null as opposed to if a serialized value was not present at all. As Is the problem we have is that there is no difference between values that were not returned by the server as opposed to values that were returned with an explicitly null value |
Couldn't we use this instead? https://github.com/microsoft/kiota-abstractions-go/blob/main/serialization/untyped_null.go |
I am trying to implement the delta query to track user changes.
For example, I changed
First name
andLast name
to empty on https://entra.microsoft.com/ .I got the below response. You can see
givenName
andsurname
are detected as null values.But, I cannot know whether the
givenName
andsurname
were changed to null since theEnumerate()
orEnumerateKeysForValuesChangedToNil()
methods don't return the values (nil).Another sample code to confirm the user data.
Also, the user data doesn't have both
givenName
andsurname
properties.In my debugging,
InMemoryBackingStore
doesn't handle a nil value inUser.GetFieldDeserializers()
method.Could you tell me how do I check both
givenName
andsurname
properties were changed to nil via msgraph-sdk-go API?Reference
The text was updated successfully, but these errors were encountered: