-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Hello,
I have a problem with a batch increment update.
class Category include Mongoid::Document field :position, type: Integer scope :ordered, order_by(position: :asc) default_scope ordered end
When I do
Category.all.inc :position, 1
None of my 13 categories are updated.
Unable to find source-code formatter for language: log. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
Wed Oct 3 17:32:24 [conn3] update test.categories query: { $query: {}, $orderby: { position: 1 } } update: { $inc: { position: 1 } } nscanned:13 nupdated:0 keyUpdates:0 locks(micros) w:156 0ms
But if I remove the default_scope, now the 13 categories are updated.
Unable to find source-code formatter for language: log. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
Wed Oct 3 17:32:54 [conn3] update test.categories update: { $inc: { position: 1 } } nscanned:13 nupdated:13 keyUpdates:0 locks(micros) w:159 0ms
I think there is a problem because the orderby is included in the update query.