Uploaded image for project: 'Go Driver'
  1. Go Driver
  2. GODRIVER-1751

Struct codec does not honor custom codecs if another codec was used first

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 1.4.2
    • Affects Version/s: None
    • Component/s: None
    • None

      Reproducible example: https://play.golang.org/p/uugW5Adb3-J

      In the example, the decodeInt function implements a value decoder for int32 that reads an int32 from the ValueReader and multiplies it by -1 before setting it in the struct. The expected output from the main function is

      {"int": {"$numberInt":"1"}}

      {Int:-1}

      but the actual output is

      {"int": {"$numberInt":"1"}}

      {Int:1}

      When using MarshalWithRegistry followed by UnmarshalWithRegistry, everything works as expected. When using Marshal followed by UnmarshalWithRegistry, the custom decoder is not honored.

            Assignee:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Reporter:
            divjot.arora@mongodb.com Divjot Arora (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: