{"issue":{"created_at":"2011-12-07T00:42:29Z","state":"open","updated_at":"2011-12-07T01:14:24Z","comments":2,"user":{"gravatar_id":"b54c8f86a5b842e01d9691ff065d2824","id":27563,"url":"https://api.github.com/users/gerad","login":"gerad","avatar_url":"https://secure.gravatar.com/avatar/b54c8f86a5b842e01d9691ff065d2824?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"I just ran into this bug in a project. Basically, if you change the sort\r\noption on a criteria, it updates the sort on the original criteria and\r\nthe cloned copy, rather than just updating the sort on the cloned copy\r\n\r\nthat is, if you do:\r\n    names = Person.all.asc(:name)\r\n    names_reverse = names.desc(:name)\r\n\r\nthen both `names` and `names_reverse` will subsequently be sorted\r\ndescending\r\n\r\nI wasn't quite sure where the right place to put this test was, so I'm\r\njust starting it here, and will move it around as I get guidance","assignee":null,"id":2469761,"labels":[],"pull_request":{"patch_url":"https://github.com/mongoid/mongoid/pull/1482.patch","html_url":"https://github.com/mongoid/mongoid/pull/1482","diff_url":"https://github.com/mongoid/mongoid/pull/1482.diff"},"number":1482,"title":"example spec for bug with criteria cloning","html_url":"https://github.com/mongoid/mongoid/issues/1482","closed_at":null,"url":"https://api.github.com/repos/mongoid/mongoid/issues/1482","milestone":null},"action":"created","comment":{"created_at":"2011-12-07T01:14:24Z","updated_at":"2011-12-07T01:14:24Z","user":{"gravatar_id":"49de4cd2f26705785cbef2b15a9df7aa","id":21668,"url":"https://api.github.com/users/nickhoffman","login":"nickhoffman","avatar_url":"https://secure.gravatar.com/avatar/49de4cd2f26705785cbef2b15a9df7aa?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Thanks for the patch, mate. It should probably go in _spec/unit/mongoid/criteria_spec.rb_ .\r\n\r\nTo fix this, I'd start in _lib/mongoid/criterion/optional.rb_ , which is where the code for `asc` and `desc` lives.","id":3041746,"url":"https://api.github.com/repos/mongoid/mongoid/issues/comments/3041746"}}