Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-5281

Allow bson-kotlin to support default values where the value is null

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: Codecs, Kotlin
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      Kotlin supports default values, in data classes where a field is non nullable and has a default value then the default value should be used if the database contains nulls

      data class Item(val name:String, val category:String = "default")
      
      // This data will error
      { name: "item2", category: null }
      

      A PR has been submitted reporting this issue: https://github.com/mongodb/mongo-java-driver/pull/1260

            Assignee:
            Unassigned Unassigned
            Reporter:
            ross@mongodb.com Ross Lawley
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: