Boolean mysql error

Hello,

I ran into a bug/issue where running rake db:migrate under JRuby with a
mysql DB and a type of boolean produces the following error. Is this a
known bug/issue with rake under JRuby ?

Rake Output (0.8.1):

– add_column(:clips, :featured, :bool, {:default=>false})
rake aborted!
ActiveRecord::ActiveRecordError: You have an error in your SQL syntax;
check
the manual that corresponds to your MySQL server version for the right
syntax to use near ‘(1) DEFAULT 0’ at line 1: ALTER TABLE clips ADD
featured bool(1) DEFAULT 0

From Migration:

add_column :clips, :featured, :bool, :default=>false

/opt/jruby/bin/jruby -v

ruby 1.8.6 (2008-05-28 rev 6586) [amd64-jruby1.1.2]

mysql -V

mysql Ver 14.12 Distrib 5.0.22, for redhat-linux-gnu (x86_64) using
readline 5.0

Thanks
Adam

On Tue, Jul 1, 2008 at 8:41 AM, AD [email protected] wrote:

Hello,

I ran into a bug/issue where running rake db:migrate under JRuby with a
mysql DB and a type of boolean produces the following error. Is this a
known bug/issue with rake under JRuby ?

Rake Output (0.8.1):

– add_column(:clips, :featured, :bool, {:default=>false})

You should use :boolean, not :bool. Does that help?

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

it helps and it worked.
Any reason it works in MRI rake and not JRuby rake ?

Nick S. wrote:

On Tue, Jul 1, 2008 at 9:56 PM, AD [email protected] wrote:

it helps and it worked.
Any reason it works in MRI rake and not JRuby rake ?

No particular reason. My best guess is that MRI’s mysql adapter has a
mapping for :bool, while AR-JDBC does not? Not sure…

I’ve run into this before with :int and :integer. I think AR just passes
the column type through to the DB in many cases [2], so if the adapter
and/or DB supports calling “boolean” “bool”, then it’ll work. So the
difference you’re seeing is most likely a difference between using the
regular mysql adapter vs. activerecord-jdbc’s mysql adapter. Since
:boolean is the correct name for the type [1], ar-jdbc is probably more
correct.

[1]

[2] It looks like it tries to translate it, and if it doesn’t recognize
the type, it just passes it through.


Matt


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Tue, Jul 1, 2008 at 9:56 PM, AD [email protected] wrote:

it helps and it worked.
Any reason it works in MRI rake and not JRuby rake ?

No particular reason. My best guess is that MRI’s mysql adapter has a
mapping for :bool, while AR-JDBC does not? Not sure…

/Nick


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email