[SERVER-241] Can't change field data type when using $set Created: 18/Aug/09 Updated: 10/Sep/09 Resolved: 26/Aug/09 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 0.9.9 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Ryan Nitz | Assignee: | Eliot Horowitz (Inactive) |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Participants: |
| Description |
|
The following code fails to convert the data type from a boolean to a double (calling $set). If this feature is not supported by $set, perhaps the driver should check the data type and throw an illegal argument exception if the types do not match. if (doc.containsField(SiteDocField.HAS_SYND_FEED.key)) { else { doc.removeField(SiteDocField.HAS_SYND_FEED.key); pCol.save(doc); } pDb.getDb().getLastError(); The code below successfully changes the data type (by calling save(doc)). if (doc.containsField(SiteDocField.HAS_SYND_FEED.key)) { else { doc.removeField(SiteDocField.HAS_SYND_FEED.key); } pCol.save(doc); |
| Comments |
| Comment by Eliot Horowitz (Inactive) [ 10/Sep/09 ] |
|
closed b/c resolved more than 2 week ago |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/09 ] |
|
java test that works changing bool to double with $set http://github.com/mongodb/mongo-java-driver/commit/6785d32efefa70d9bfcda5f17ac37a3ad966c3b5 |
| Comment by Ryan Nitz [ 26/Aug/09 ] |
|
I truncated this and removed any identifiable product info. This uses a couple of custom objects and won't compile on its own. In this example... both fields were boolean (trying to convert to double). It includes the code that works and the code that did not (using $set). Let me know if you have any questions. |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/09 ] |
|
in shell - but it shouldn't be different. |
| Comment by Ryan Nitz [ 26/Aug/09 ] |
|
You can't reproduce in the Java driver or from the shell? |
| Comment by Eliot Horowitz (Inactive) [ 26/Aug/09 ] |
|
take a look at jstests/set2.js that seems like the same thing, but works fine. |