Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Blocker
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1.2
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:rails 2.1 (but any 2.x.x should behave the same)
jruby 1.1.2
Windows XP 32bits/Gentoo Linux 2006
-
Number of attachments :5
Description
steps to reproduce :
1) jruby -S rails myapp -d sqlite3
2) change manually sqlite3 to jdbcsqlite3 in config/database.yaml
3) jruby -S rake db:create:all
4) jruby script/generate scaffold note title:string message:text publish_date:date
5) jruby -S rake db:migrate
6) jruby script/server -p 3000
go to the page : http://localhost:3000/notes/new
fill the form, and submit, it gives : 1 error(s) on assignment of multiparameter attributes
The same test with a jdbcmysql adapter is correct, that's why i think jdbcsqlite3 adapter is guilty.
Attachments
-
- development.log-jruby-113
- 02/Sep/08 7:29 PM
- 1 kB
- Rene Androsch
-
- development.log-jruby-114
- 02/Sep/08 7:29 PM
- 1 kB
- Rene Androsch
-
- development.log-mri
- 02/Sep/08 7:29 PM
- 3 kB
- Rene Androsch
-
- jdbc_sqlite3_add_proper_date_time_columns.diff
- 21/Aug/08 12:24 AM
- 1 kB
- Dylan Stamat
-
$i18n.getText("admin.common.words.hide")
- migration_problem_src.zip
- 02/Sep/08 7:30 PM
- 99 kB
- Rene Androsch
-
- migration_problem/.DS_Store 6 kB
- migration_problem/app/.DS_Store 6 kB
- __MACOSX/migration_problem/.../._.DS_Store 0.1 kB
- migration_problem/app/.../application.rb 0.5 kB
- migration_problem/.../application_helper.rb 0.1 kB
- migration_problem/app/models/bill.rb 0.5 kB
- migration_problem/config/boot.rb 3 kB
- migration_problem/config/database.yml 0.6 kB
- migration_problem/config/environment.rb 3 kB
- migration_problem/config/.../development.rb 0.7 kB
- migration_problem/config/.../production.rb 0.9 kB
- migration_problem/config/.../test.rb 1.0 kB
- migration_problem/config/.../date_formats.rb 0.4 kB
- migration_problem/.../dirty_checking.rb 0.1 kB
- migration_problem/config/.../inflections.rb 0.4 kB
- migration_problem/.../javascript_caching.rb 0.1 kB
- migration_problem/config/.../mime_types.rb 0.2 kB
- migration_problem/.../new_rails_defaults.rb 0.7 kB
- migration_problem/.../query_caching.rb 0.2 kB
- migration_problem/config/routes.rb 3 kB
- migration_problem/db/.DS_Store 6 kB
- __MACOSX/migration_problem/.../._.DS_Store 0.1 kB
- migration_problem/.../20080701202925_create_bills.rb 0.4 kB
- migration_problem/.../20080718151643_change_date_to_datetime_on_bills.rb 0.4 kB
- migration_problem/db/schema.rb 1 kB
- migration_problem/doc/.DS_Store 6 kB
- migration_problem/doc/README_FOR_APP 0.2 kB
- migration_problem/log/.DS_Store 6 kB
- __MACOSX/migration_problem/.../._.DS_Store 0.1 kB
- migration_problem/public/.DS_Store 6 kB
$i18n.getText("admin.common.words.show")- migration_problem_src.zip
- 02/Sep/08 7:30 PM
- 99 kB
- Rene Androsch
Activity
If i create the project under matz ruby an run under jruby (webrick, mongrel-java, glassfish_rails and jetty_rails tested) work without problem
the problem apparently is in the migration of the bbdd if i do a
jruby -S rake db:migrate i obtain the next schema.rb (tested with rails 2.1)
ActiveRecord::Schema.define(:version => 20080717202218) do
create_table "notes", :force => true do |t|
t.string "title"
t.string "message", :limit => 2000000000
t.integer "publish_date", :limit => 2000000000
t.integer "created_at", :limit => 2000000000
t.integer "updated_at", :limit => 2000000000
end
end
but with ruby -S rake db:migrate (matz version) i obtain the next schema.rb
ActiveRecord::Schema.define(:version => 20080717200735) do
create_table "notes", :force => true do |t|
t.string "title"
t.text "message"
t.date "publish_date"
t.datetime "created_at"
t.datetime "updated_at"
end
end
the ar-jdbcsqlite adapter add the strange :limit to all the fields
if i transfer the database from the application migrated with matz ruby to the apllication generated with jruby this one runs without problems
my mistake, the migration with jdbcsqlite adapter migrate the text field like a string field with a :limit => 2000000000 and the date/datetime like integer fields
see attached for patch.
all the date/time related columns were being set to integer for some reason. re-declared them to the appropriate data types
I've the same/related issue (and I think JRUBY-2438 (closed), JRUBY-2718 (open) are always about the same problem.
Here is the data I collected:
Using sqlite3 as database driver, the MRI implementation has no problem with the included migrations.
However running the same migration on jruby (1.1.3 or 1.1.4), the migration fail.
The output is provided for:
-) MRI "1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]"
-) "jruby 1.1.3"
-) "jruby 1.1.4"
Using apple's JRE:
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237)
Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)
The migration "20080718151643_change_date_to_datetime_on_bills.rb" is the source of the problem.
Also included the development.log output of each run.
Here is the output of the 3 runs:
##########
##
-
- ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
##
##########
MacBook:migration_problem art$ rm db/development.sqlite3 ; rake db:create ; rake db:migrate
(in /Users/art/development/projects/rails/_mine/migration_problem)
db/development.sqlite3 already exists
(in /Users/art/development/projects/rails/_mine/migration_problem)
== 20080701202925 CreateBills: migrating ======================================
- create_table(:bills)
-> 0.0033s
== 20080701202925 CreateBills: migrated (0.0035s) =============================
- ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
== 20080718151643 ChangeDateToDatetimeOnBills: migrating ======================
– change_table(:bills)
-> 0.0193s
== 20080718151643 ChangeDateToDatetimeOnBills: migrated (0.0259s) =============
##########
##
-
- jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-07-20 rev 7243) [i386-java]
##
##########
MacBook:migration_problem art$ rm db/development.sqlite3 ; jruby -S rake db:create ; jruby -S rake db:migrate
(in /Users/art/development/projects/rails/_mine/migration_problem)
(in /Users/art/development/projects/rails/_mine/migration_problem)
== 20080701202925 CreateBills: migrating ======================================
- create_table(:bills)
-> 0.0307s
-> 0 rows
== 20080701202925 CreateBills: migrated (0.0317s) =============================
- jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-07-20 rev 7243) [i386-java]
== 20080718151643 ChangeDateToDatetimeOnBills: migrating ======================
– change_table(:bills)
rake aborted!
ActiveRecord::ActiveRecordError: near "ALTER": syntax error: ALTER TABLE bills ALTER COLUMN date INTEGER
(See full trace by running task with --trace)
##########
##
-
- jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-08-28 rev 7570) [i386-java]
##
##########
MacBook:migration_problem art$ rm db/development.sqlite3 ; jruby -S rake db:create ; jruby -S rake db:migrate
(in /Users/art/development/projects/rails/_mine/migration_problem)
(in /Users/art/development/projects/rails/_mine/migration_problem)
== 20080701202925 CreateBills: migrating ======================================
- create_table(:bills)
-> 0.0339s
-> 0 rows
== 20080701202925 CreateBills: migrated (0.0347s) =============================
- jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-08-28 rev 7570) [i386-java]
== 20080718151643 ChangeDateToDatetimeOnBills: migrating ======================
– change_table(:bills)
rake aborted!
ActiveRecord::ActiveRecordError: near "ALTER": syntax error: ALTER TABLE bills ALTER COLUMN date INTEGER
(See full trace by running task with --trace)
-
- ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] ## ########## MacBook:migration_problem art$ rm db/development.sqlite3 ; rake db:create ; rake db:migrate (in /Users/art/development/projects/rails/_mine/migration_problem) db/development.sqlite3 already exists (in /Users/art/development/projects/rails/_mine/migration_problem) == 20080701202925 CreateBills: migrating ======================================
- create_table(:bills) -> 0.0033s == 20080701202925 CreateBills: migrated (0.0035s) =============================
-
- jruby 1.1.3 (ruby 1.8.6 patchlevel 114) (2008-07-20 rev 7243) [i386-java] ## ########## MacBook:migration_problem art$ rm db/development.sqlite3 ; jruby -S rake db:create ; jruby -S rake db:migrate (in /Users/art/development/projects/rails/_mine/migration_problem) (in /Users/art/development/projects/rails/_mine/migration_problem) == 20080701202925 CreateBills: migrating ======================================
- create_table(:bills) -> 0.0307s -> 0 rows == 20080701202925 CreateBills: migrated (0.0317s) =============================
-
- jruby 1.1.4 (ruby 1.8.6 patchlevel 114) (2008-08-28 rev 7570) [i386-java] ## ########## MacBook:migration_problem art$ rm db/development.sqlite3 ; jruby -S rake db:create ; jruby -S rake db:migrate (in /Users/art/development/projects/rails/_mine/migration_problem) (in /Users/art/development/projects/rails/_mine/migration_problem) == 20080701202925 CreateBills: migrating ======================================
- create_table(:bills) -> 0.0339s -> 0 rows == 20080701202925 CreateBills: migrated (0.0347s) =============================
Sample source -> just run the migration:
MRI:
rm db/development* ; rake db:create ; rake db:migrate
JRuby:
rm db/development* ; jruby -S rake db:create ; jruby -S rake db:migrate
I try authlogic plugin , redmine and others app/gems with Jruby , NetBeans 6.5 and SqLite3 database and my result is, that is not possible switch between JRuby and Ruby(C) if I use SqLite3 database. Another result - majority Rails app in Jruby with SqLite3 can't work properly.
I think, ther is some problems, how column type is interpreted in Ruby-Sqlite3 adapter and jdbc_sqlite3 adapter. All Date-Time and boolean is interpreted different , and default values for boolean are not exported by rake db:export: in Jruby
class TestDb < ActiveRecord::Migration
def self.up
create_table :test_column, :force => true do |t|
t.column "is_closed", :boolean, :default => false, :null => false
t.column "is_enabled", :boolean, :default => true, :null => false
t.column "created_on", :timestamp
t.column "modified_at", :datetime, :null => false
t.column "start_on", :date, :null => false
t.column "start_at", :time, :null => false
end
end
....
end
C -Ruby:
CREATE TABLE "test_column" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "is_closed" boolean DEFAULT 'f' NOT NULL, "is_enabled" boolean DEFAULT 't' NOT NULL, "created_on" datetime, "modified_at" datetime NOT NULL, "start_on" date NOT NULL, "start_at" time NOT NULL);
rake db:export:
create_table "test_column", :force => true do |t|
t.boolean "is_closed", :default => false, :null => false
t.boolean "is_enabled", :default => true, :null => false
t.datetime "created_on"
t.datetime "modified_at", :null => false
t.date "start_on", :null => false
t.time "start_at", :null => false
end
Jruby:
CREATE TABLE test_column (id INTEGER PRIMARY KEY AUTOINCREMENT, is_closed INTEGER(1) DEFAULT 0 NOT NULL, is_enabled INTEGER(1) DEFAULT 1 NOT NULL, created_on INTEGER, modified_at INTEGER NOT NULL, start_on INTEGER NOT NULL, start_at INTEGER NOT NULL);
rake db:export:
create_table "test_column", :force => true do |t|
t.integer "is_closed", :limit => 1
t.integer "is_enabled", :limit => 1
t.integer "created_on", :limit => 2000000000
t.integer "modified_at", :limit => 2000000000
t.integer "start_on", :limit => 2000000000
t.integer "start_at", :limit => 2000000000
end
Ther are some code from jdbc_sqlite3.rb, where ther is clarify :
def modify_types(tp)
tp[:primary_key] = "INTEGER PRIMARY KEY AUTOINCREMENT"
tp[:float] = { :name => "REAL" }
tp[:decimal] = { :name => "REAL" }
tp[:datetime] = { :name => "INTEGER" }
tp[:timestamp] = { :name => "INTEGER" }
tp[:time] = { :name => "INTEGER" }
tp[:date] = { :name => "INTEGER" }
tp[:boolean] = { :name => "INTEGER", :limit => 1}
tp
end
I think, there cause too many problems in Rails app and would be better if behavior for both adapters are similar.
I followed the steps to reproduce and confirmed that it is still broken with jruby 1.1.5, jdbc-sqlite3-3.5.8, and activerecord-jdbcsqlite3-adapter-0.9.
The schema appears as follows:
ActiveRecord::Schema.define(:version => 20081130234148) do
create_table "notes", :force => true do |t|
t.string "title"
t.string "message", :limit => 2000000000
t.integer "publish_date", :limit => 2000000000
t.integer "created_at", :limit => 2000000000
t.integer "updated_at", :limit => 2000000000
end
end
When I applied JRUBY-2967 I also added the smarts to fix this for sqlite3. So this is what the schema looks like now:
ActiveRecord::Schema.define(:version => 20090116223215) do
create_table "notes", :force => true do |t|
t.string "title"
t.string "message", :limit => nil
t.date "publish_date"
t.datetime "created_at"
t.datetime "updated_at"
end
end
So t.string "message" is still not right, but it works and it is not this issue. So I am resolving this for 0.9.1 of AR.
ActiveRecord::Schema.define(:version => 20090116223215) do
create_table "notes", :force => true do |t|
t.string "title"
t.string "message", :limit => nil
t.date "publish_date"
t.datetime "created_at"
t.datetime "updated_at"
end
end
Any possibility you could look at jdbcsqlite3 source and figure out where this is happening? We're a little short-handed on sqlite3 resources right now