Skip to content

[go]: Range Checks and Null Values? #472

Closed
@meyerdan

Description

@meyerdan

We are generating Encoders/Decoders for go.

In our schema, we have a field, defined as follows:

<field name="position" id="2" type="uint64" presence="optional" />

Our question goes to the range-checking which can be enabled in the generated decoder.
We observe that the check is generated as follows, regardless whether the presence="optional" attribute is set or not:

  if s.PositionInActingVersion(actingVersion) {
        if s.Position < s.PositionMinValue() || s.Position > s.PositionMaxValue() {
            return fmt.Errorf("Range check failed on s.Position (%d < %d > %d)", s.PositionMinValue(), s.Position, s.PositionMaxValue())
        }
    }

If a null value is received, it will be s.PositionMaxValue() + 1.

Our question is: should the range check code accommodate for null values or are we maybe confusing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions