This project is archived and is in readonly mode.
ActiveRecord::Calculations.count( ) not work , when mysql table is empty
-
Hunter
the trace stack is already in the post.
extract the excetion for count here:
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.0/lib/active_r
ecord/relation/calculations.rb:58:in count'from C:in `count' from D:/vob/g2/config/initializers/cargo_category_load.rb:95:in `<top (required)>'
mysql_adapter.rb:629:in select': undefined methodall_hashes' for
<Mysql::Result:0x19b94c8> (NoMethodError)
, and not only for count , but also for other method, like all, will get same break.
-
David Trasbo
I was unable to reproduce this on edge Rails using Ruby 1.9.2:
➜ in ~/code/rails/railties/tmp on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp ../../bin/rails new ticket_5549 --dev -d mysql ... ➜ in ~/code/rails/railties/tmp on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp cd ticket_5549 ➜ in ~/code/rails/railties/tmp/ticket_5549 on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp bundle exec rails g model foo ... ➜ in ~/code/rails/railties/tmp/ticket_5549 on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp rake db:create (in /Users/dtrasbo/code/rails/railties/tmp/ticket_5549) ➜ in ~/code/rails/railties/tmp/ticket_5549 on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp rake db:migrate (in /Users/dtrasbo/code/rails/railties/tmp/ticket_5549) .. ➜ in ~/code/rails/railties/tmp/ticket_5549 on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp cat config/database.yml # MySQL. Versions 4.1 and 5.0 are recommended. # # Install the MySQL driver: # gem install mysql2 # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql2 encoding: utf8 reconnect: false database: ticket_5549_development pool: 5 username: root password: socket: /tmp/mysql.sock test: ... ➜ in ~/code/rails/railties/tmp/ticket_5549 on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp bundle exec rails c Loading development environment (Rails 3.1.0.beta) ruby-1.9.2-p0 > Foo.count => 0 ruby-1.9.2-p0 > exit ➜ in ~/code/rails/railties/tmp/ticket_5549 on 5549 (✔) using ruby-1.9.2-p0@edgerailsapp mysql --version mysql Ver 14.14 Distrib 5.1.49, for apple-darwin10.4.0 (i386) using readline 6.0I'm on OS X.
-
David Trasbo
That turned out to be a bit crufty. Here we go again:
➜ ../../bin/rails new ticket_5549 --dev -d mysql... ➜ cd ticket_5549 ➜ bundle exec rails g model foo... ➜ rake db:create(in /Users/dtrasbo/code/rails/railties/tmp/ticket_5549) ➜ rake db:migrate(in /Users/dtrasbo/code/rails/railties/tmp/ticket_5549) .. ➜ cat config/database.yml # MySQL. Versions 4.1 and 5.0 are recommended. # # Install the MySQL driver: # gem install mysql2 # # And be sure to use new-style password hashing: # http://dev.mysql.com/doc/refman/5.0/en/old-client.html development: adapter: mysql2 encoding: utf8 reconnect: false database: ticket_5549_development pool: 5 username: root password: socket: /tmp/mysql.sock test: ... ➜ bundle exec rails c Loading development environment (Rails 3.1.0.beta) ruby-1.9.2-p0 > Foo.count => 0 ruby-1.9.2-p0 > exit ➜ mysql --versionmysql Ver 14.14 Distrib 5.1.49, for apple-darwin10.4.0 (i386) using readline 6.0 -
Hunter
Hi, Thanks for your quick action on this fault.
Something clarify here.
-
I use mysql gem rather than mysql2
-
I am on windows platform
-
when I switch back to Rails 2.3.5, everything ok, and no exception .
Brs
Hunter Hu
-
-
David Trasbo
Ah, okay. I repeated the process above except I used the
mysqladapter/gem instead but I still couldn't reproduce. That leaves Windows.I do have access to a Windows machine with Ruby but I won't be near it before tomorrow. I'll try and see if I can reproduce this then.
-
Santiago Pastorino
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino
- State changed from open to stale