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

Collection uuidRepresentation appears to be read only

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Codecs
    • None
    • Java Drivers

      When querying data - I'd expect the collections codec registry to be used for the filters. However, with uuids this appears not to be the case.

      // Test finding old UUIDs - insert data
      collection.insertOne(new Document("uuid",
              new BsonBinary(UUID.fromString("00000000-0000-0000-0000-000000000101"), UuidRepresentation.JAVA_LEGACY)));
      
      // Expected to not be found when using STANDARD representation
      Document uuidEncodedUsingLegacyJAVA = collection.find(eq("uuid",
              UUID.fromString("00000000-0000-0000-0000-000000000101"))).first();
      System.out.println(" >>>  " + uuidEncodedUsingLegacyJAVA);
      
      // Expected to find as have updated the codec registry, but does not!!
      uuidEncodedUsingLegacyJAVA = collection
              .withCodecRegistry(withUuidRepresentation(collection.getCodecRegistry(), UuidRepresentation.JAVA_LEGACY))
              .find(eq("uuid", UUID.fromString("00000000-0000-0000-0000-000000000101"))).first();
      System.out.println(" >>>  " + uuidEncodedUsingLegacyJAVA);
      
      // Is found when manually setting the BsonBinary
      uuidEncodedUsingLegacyJAVA = collection.find(eq("uuid",
                      new BsonBinary(UUID.fromString("00000000-0000-0000-0000-000000000101"), UuidRepresentation.JAVA_LEGACY)))
              .first();
      System.out.println(" >>>  " + uuidEncodedUsingLegacyJAVA);
      

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

              Created:
              Updated: