Uploaded image for project: 'Scala'
  1. Scala
  2. SCALA-485

@BsonProperty is ignored in ADT case classes

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Fixed
    • Affects Version/s: 2.5.0
    • Fix Version/s: 2.7.0
    • Component/s: API
    • Labels:
      None

      Description

      @BsonProperty is not being applied in ADT case classes:

      sealed class Tree
      case class Branch(@BsonProperty("someName") b1: Tree, b2: Tree, value: Int) extends Tree
      case class Leaf(value: Int) extends Tree
      collection.insertOne(Branch(Branch(Leaf(1),Leaf(2), 3),Leaf(4),5))
      

      gets saved as 

      {
        "_id" : ObjectId("5c207fd77aa018cccb795f38"),
        "_t" : "Branch",
        "b1" : {
          "_t" : "Branch",
          "b1" : {
            "_t" : "Leaf",
            "value" : 1
          },
        "b2" : {
          "_t" : "Leaf",
          "value" : 2
          },
        "value" : 3
        },
        "b2" : {
          "_t" : "Leaf",
          "value" : 4
        },
        "value" : 5
      }
      

        Attachments

          Activity

            People

            Assignee:
            ross.lawley Ross Lawley
            Reporter:
            kayjaystudio Константин Владимирович Зайцев
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: