[SERVER-16589] findAndModify return value changes upon error Created: 18/Dec/14  Updated: 26/Apr/19  Resolved: 18/Dec/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.8.0-rc2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Derick Rethans Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Minor Change
Operating System: ALL
Participants:

 Description   

Note, this issue is with 2.8.0-rc3-pre, not with rc2, but JIRA wouldn't let me fill in 2.8.0-rc3-pre

The following code:

    $retval = $col->findAndModify(
         array("inprogress" => false, "name" => "Biz report"),
         array('$set' => array('$set' => array('inprogress' => true, "started" => new MongoDate()))),
         null,
         array(
            "sort" => array("priority" => -1),
            "new" => true,
        )
    );

Returns this with rc2:

string(9) "2.8.0-rc2"
exception message: localhost:30000: The dollar ($) prefixed field '$set' in '$set' is not valid for storage.
exception code: 2
array(3) {
  'lastErrorObject' =>
  array(5) {
    'connectionId' =>
    int(3)
    'err' =>
    string(72) "The dollar ($) prefixed field '$set' in '$set' is not valid for storage."
    'code' =>
    int(52)
    'n' =>
    int(0)
    'ok' =>
    double(1)
  }
  'ok' =>
  double(0)
  'errmsg' =>
  string(72) "The dollar ($) prefixed field '$set' in '$set' is not valid for storage."
}

But in the latest master build, it is suddenly:

string(14) "2.8.0-rc3-pre-"
exception message: localhost:30000: exception: The dollar ($) prefixed field '$set' in '$set' is not valid for storage.
exception code: 52
array(3) {
  'errmsg' =>
  string(83) "exception: The dollar ($) prefixed field '$set' in '$set' is not valid for storage."
  'code' =>
  int(52)
  'ok' =>
  double(0)
}

It doesn't seem to break any code... but it did trip up a test case for us. As I couldn't find a reference to this (slightly) BC breaking change, I am filing this issue.



 Comments   
Comment by Ian Whalen (Inactive) [ 26/Apr/19 ]

Switching "Drivers Changes Needed" from "Maybe" to "Not Needed" since this was closed as something other than Fixed.

Comment by Derick Rethans [ 18/Dec/14 ]

I'm okay with that - I was just flagging it up in case it was unintentional.

Comment by Andy Schwerin [ 18/Dec/14 ]

Thanks for the report; the code change was intentional. The new code identifies the problem as "illegal dollar prefixed field name", while the old code was the less specific "bad value". I suspect that applications aren't generally making decisions based on this value, so propose to leave it as is.

Generated at Thu Feb 08 03:41:34 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.