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

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4.2
    • Component/s: None
    • Security Level: Public
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

            Assignee:
            divjot.arora Divjot Arora
            Reporter:
            divjot.arora Divjot Arora
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: