date, datetime, and integer columns get :limit in schema.rb for
arjdbc-postgresql adapter
-----------------------------------------------------------------------------------------
Key: JRUBY-5187
URL: http://jira.codehaus.org/browse/JRUBY-5187
Project: JRuby
Issue Type: Bug
Components: JRuby-extras
Environment: $ jruby --version
jruby 1.5.1 (ruby 1.8.7 patchlevel 249) (2010-06-06 f3a3480) (Java HotSpot(TM)
64-Bit Server VM 1.6.0_22) [x86_64-java]
activerecord (3.0.1)
activerecord-jdbc-adapter (1.0.2 java)
activerecord-jdbcpostgresql-adapter (1.0.2 java)
jdbc-postgres (8.4.702 java)
Reporter: Uwe Kubosch
Hi!
For a newly generated Rail 3 app using the JRuby template and postgresql, the
generated schema.rb sets limits on date, datetime, and integer columns. It
seems the sql_type reported contains parenthesis which standard AR interprets
as limit.
The migration used:
{noformat}
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.integer :age, :null => false
t.date :birthdate, :null => false
t.datetime :epiphany_at, :null => false
t.timestamps
end
end
def self.down
drop_table :users
end
end
{noformat}
The resulting schema.rb:
{noformat}
ActiveRecord::Schema.define(:version => 20101115094722) do
create_table "users", :force => true do |t|
t.integer "age", :limit => 10, :null => false
t.date "birthdate", :null => false
t.datetime "epiphany_at", :limit => 29, :null => false
t.datetime "created_at", :limit => 29
t.datetime "updated_at", :limit => 29
end
end
{noformat}
Adding the following code to config/environment.rb fixes the problem:
{noformat}
module ::ArJdbc::PostgreSQL::Column
def extract_limit_with_fix(sql_type)
return nil if sql_type =~ /^date|datetime|int4|timestamp/i
extract_limit_without_fix(sql_type)
end
alias_method_chain :extract_limit, :fix
end
{noformat}
And the resulting schema.rb:
{noformat}
ActiveRecord::Schema.define(:version => 20101115094722) do
create_table "users", :force => true do |t|
t.integer "age", :null => false
t.date "birthdate", :null => false
t.datetime "epiphany_at", :null => false
t.datetime "created_at"
t.datetime "updated_at"
end
end
{noformat}
I tried adding the fix directly to the arjdbc/postgresql/adapter.rb file, but
it seems the extract_limit method in that file is not run.
It is also possible that the actual problem is that the sql_type contains
parenthesis.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email