[SERVER-5997] renameCollection creates an empty collection when run from a script Created: 04/Jun/12 Updated: 15/Aug/12 Resolved: 04/Jun/12 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | JavaScript, Shell |
| Affects Version/s: | 2.0.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | bishwa shrestha | Assignee: | Unassigned |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Operating System: | ALL |
| Participants: |
| Description |
|
renameCollection works from the shell:
I created a script "upgrade.js":
and running it creates an empty "newName" collection:
I can workaround this issue by inserting all the records from the old to the new collection and then dropping the old collection, but its not very clean. |
| Comments |
| Comment by bishwa shrestha [ 22/Jun/12 ] |
|
Cool! Thanks |
| Comment by auto [ 22/Jun/12 ] |
|
Author: {u'date': u'2012-06-22T06:50:05-07:00', u'email': u'samk@10gen.com', u'name': u'Sam Kleinman'}Message: also redirecting the wiki page to the manual to reduce confusion |
| Comment by bishwa shrestha [ 04/Jun/12 ] |
|
hmm.. this could be tricky indeed. I think the documentation needs to be updated with this though. |
| Comment by Eliot Horowitz (Inactive) [ 04/Jun/12 ] |
|
People generally very much want to create indexes before inserting any data, so not sure if there is anything that can be done. |
| Comment by bishwa shrestha [ 04/Jun/12 ] |
|
Ahh... I found the problem. An index was created on "newName" collection before the renameCollection command was invoked. This created the newName collection and caused the script to fail. Please see attachment(test.js). I moved the index creation at the end (where it belongs |
| Comment by bishwa shrestha [ 04/Jun/12 ] |
|
Failure condition: create index before renaming |
| Comment by Eliot Horowitz (Inactive) [ 04/Jun/12 ] |
|
See test script attached. |