Spring Data MongoDB
  1. Spring Data MongoDB
  2. DATAMONGO-104 Review MongoTemplate
  3. DATAMONGO-97

ID replacement not working correctly when using updateFirst/updateMulti

    Details

    • Type: Sub-task Sub-task
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Complete
    • Affects Version/s: 1.0 M2
    • Fix Version/s: 1.0 M3
    • Component/s: Core
    • Labels:
      None

      Description

      this is not working
      mongoTemplate.updateMulti(
      new Query(where("id").is("theidstring"),
      new Update().set("name", "hellen"));
      but find by id is fine

        Issue Links

          Activity

          Hide
          afridayh added a comment -

          sorry that is not a bug, one should write the query like this:
          new Query(where("_id").is(new ObjectId("theidstring")))

          Show
          afridayh added a comment - sorry that is not a bug, one should write the query like this: new Query(where("_id").is(new ObjectId("theidstring")))
          Hide
          Mark Pollack added a comment - - edited

          no, it is a bug as we should be handling this correctly / consistently in save, find and updateFirst/Multi operations. We will introduce whereId() as a convenience so it reads nicer as it is feels a bit unnatural to specify the underscore prefix.

          Show
          Mark Pollack added a comment - - edited no, it is a bug as we should be handling this correctly / consistently in save, find and updateFirst/Multi operations. We will introduce whereId() as a convenience so it reads nicer as it is feels a bit unnatural to specify the underscore prefix.
          Hide
          Jon Brisbin added a comment -

          Our tests show that recent fixes to the way Query and Update objects are handled address this problem. They allow the developer to query based on the property name of the object (e.g. "id", "objectId", or "bob") and have the template recognize the Query is referencing an ID field and translate the name of the field to "_id" automagically.

          Show
          Jon Brisbin added a comment - Our tests show that recent fixes to the way Query and Update objects are handled address this problem. They allow the developer to query based on the property name of the object (e.g. "id", "objectId", or "bob") and have the template recognize the Query is referencing an ID field and translate the name of the field to "_id" automagically.

            People

            • Assignee:
              Jon Brisbin
              Reporter:
              afridayh
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: