Forum: Ruby on Rails rake test fails on MySQL error

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B7b0ddb76ac5ec37238ec998bfaafd8e?d=identicon&s=25 Jim Tittle (elyod_72)
on 2007-07-05 23:57
I am a VERY newbie, so please forgive me.

I created a project from a tutorial availible online, and when I ran the
rake test, it came up with the following error:

218 %  rake test_units
(in /rubydev/devblog)
rake aborted!
Mysql::Error: You have an error in your SQL syntax near 'ENGINE=InnoDB'
at lin
e 1: CREATE TABLE comments (`id` int(11) DEFAULT NULL auto_increment
PRIMARY K
EY, `body` text DEFAULT '' NOT NULL, `post_id` int(11) DEFAULT 0 NOT
NULL) ENG
INE=InnoDB

(See full trace by running task with --trace)


I ran it with '--trace' and of couse it errored out also. here is what
it said:

219 %  rake test_units --trace
(in /rubydev/devblog)
** Invoke test_units (first_time)
** Invoke test:units (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:test:prepare
** Invoke db:test:clone (first_time)
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:clone
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
rake aborted!
Mysql::Error: You have an error in your SQL syntax near 'ENGINE=InnoDB'
at line 1:
CREATE TABLE comments (`id` int(11) DEFAULT NULL auto_increment PRIMARY
KEY, `body` text DEFAULT '' NOT NULL, `post_id` int(11) DEFAULT 0 NOT
NULL) ENGINE=InnoDB
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract_adapter.rb:128:in
`log'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:104:in
`create_table'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:353:in
`create_table'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:275:in
`send'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:275:in
`method_missing'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:259:in
`say_with_time'
/usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:259:in
`say_with_time'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/migration.rb:273:in
`method_missing'
./db/schema.rb:7
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/schema.rb:43:in
`instance_eval'
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/schema.rb:43:in
`define'
./db/schema.rb:5
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
`load'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
`load'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:342:in
`new_constants_in'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:488:in
`load'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/databases.rake:31
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
`synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/databases.rake:76
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
`synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/databases.rake:153
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:392:in
`execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:362:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
`synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:369:in
`invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `send'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:368:in
`invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:361:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
`synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:369:in
`invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `send'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1003:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:368:in
`invoke_prerequisites'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:361:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in
`synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:355:in `invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in `each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1739:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1733:in
`top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1711:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1761:in
`standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake.rb:1708:in `run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.3/bin/rake:7
/usr/local/bin/rake:16:in `load'
/usr/local/bin/rake:16


I understand that the problem is that RNR is unable to create the tables
needed in the test database, the question is how do I fix the problem so
that it will run the test correctly?
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-07-06 00:35
(Received via mailing list)
On Jul 5, 2007, at 5:57 PM, Jim Tittle wrote:
> 'ENGINE=InnoDB'
> problem so
> that it will run the test correctly?

What version of MySQL are you using?  Does it support the
ENGINE=InnoDB syntax (I think the syntax prior to 5.x was TYPE=InnoDB)?

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
B7b0ddb76ac5ec37238ec998bfaafd8e?d=identicon&s=25 Jim Tittle (elyod_72)
on 2007-07-06 00:39
Rob Biedenharn wrote:
> On Jul 5, 2007, at 5:57 PM, Jim Tittle wrote:
>> 'ENGINE=InnoDB'
>> problem so
>> that it will run the test correctly?
>
> What version of MySQL are you using?  Does it support the
> ENGINE=InnoDB syntax (I think the syntax prior to 5.x was TYPE=InnoDB)?
>
> -Rob
>
> Rob Biedenharn    http://agileconsultingllc.com
> Rob@AgileConsultingLLC.com

Yes it is an old version of MySQL - 3.23.54. Is there a way to make this
distinction?
Ef3aa7f7e577ea8cd620462724ddf73b?d=identicon&s=25 Rob Biedenharn (Guest)
on 2007-07-06 02:39
(Received via mailing list)
On Jul 5, 2007, at 6:39 PM, Jim Tittle wrote:

>>
>> -Rob
>>
>> Rob Biedenharn    http://agileconsultingllc.com
>> Rob@AgileConsultingLLC.com
>
> Yes it is an old version of MySQL - 3.23.54. Is there a way to make
> this
> distinction?

Hey, I found an old migration in an old project:

class CreateUsersTable < ActiveRecord::Migration
   def self.up
     create_table(:users,
                  :options => 'TYPE=InnoDB') do |t| #  DEFAULT
CHARSET=utf8
       t.column :first_name,      :string, :limit => 30, :null => false
       t.column :last_name,       :string, :limit => 30, :null => false
       t.column :department,      :string
       t.column :phone,           :string, :limit => 24
     end
   end

   def self.down
     drop_table(:users)
   end
end

This was when the default was MyIsam and might have also been with
4.x (like I said, it was old), but the server was running 3.23 so I
think that's how I landed on this syntax.

-Rob

Rob Biedenharn    http://agileconsultingllc.com
Rob@AgileConsultingLLC.com
This topic is locked and can not be replied to.