You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
2.x branch.
As far as I can see, today you provide <Model>.has<Field>() -> Bool methods for all fields marked as optional in the proto schema.
My request is that you also provide a has(field: String, includeNonOptionals: Bool) -> Bool method or alternatively a presentFields(includeNonOptionals: Bool) -> [String] with all the present fields. Today you have no has method for fields that are not marked as optional. The includeNonOptionals should include these if set to true.
My current use-case is that I want to check that all fields specified in an updateMask are actually specifically set by the caller - instead of just taking on their default values. I can get the updateMask paths with request.message.updateMask.paths, but I can find no easy, general way check that the value for a path component was set, without writing an ugly method myself with a big switch (for the has() method) or a lot of ifs (for the presentFields() variant).
I am new to both Swift and gRPC, so maybe what I want is already possible in some other way I have not discovered?
The text was updated successfully, but these errors were encountered:
Thanks for opening this – this project doesn't control how messages are generated, that's done by the SwiftProtobuf project. You should ask the folks over there instead: https://github.com/apple/swift-protobuf
@glbrntt Thanks for responding so quickly.
For anyone else coming here, I found these that seem to be more generalized versions of what I want: apple/swift-protobuf#1029 apple/swift-protobuf#731 apple/swift-protobuf#1284
None of them seem to have gained much traction with the developers, but the last one contains a workaround that I will see if I can adapt to my use-case.
2.x branch.
As far as I can see, today you provide
<Model>.has<Field>() -> Bool
methods for all fields marked as optional in the proto schema.My request is that you also provide a
has(field: String, includeNonOptionals: Bool) -> Bool
method or alternatively apresentFields(includeNonOptionals: Bool) -> [String]
with all the present fields. Today you have no has method for fields that are not marked as optional. The includeNonOptionals should include these if set to true.My current use-case is that I want to check that all fields specified in an updateMask are actually specifically set by the caller - instead of just taking on their default values. I can get the updateMask paths with
request.message.updateMask.paths
, but I can find no easy, general way check that the value for a path component was set, without writing an ugly method myself with a big switch (for the has() method) or a lot of ifs (for the presentFields() variant).I am new to both Swift and gRPC, so maybe what I want is already possible in some other way I have not discovered?
The text was updated successfully, but these errors were encountered: