 |
Forums |
Admin Discussion Forums: help Start New Thread
By: Praveen Devarao
RE: IBM_DB with ActiveRecord unit test errors. [ reply ] 2011-10-11 02:11
|
Hi Yasuo,
You will not need to have two AR tests. The files after replacing will still hold good for other adapters too.
Only exception being, in schema.rb (for creating tables camelcase and warehouse_things) I don't have a if condition to create appropriately based on DB being used.
Thanks
Praveen
|
By: Yasuo Honda
RE: IBM_DB with ActiveRecord unit test errors. [ reply ] 2011-10-11 01:32
|
Praveen, Sorry for my late reply.
If I understand correctly,
I need two ActiveRecord unit tests, one for generic(PostgreSQL, MySQL and Oracle etc..) another one for DB2 only. It would be some hard task for me to keep them up-to-date.
I'd be glad if you have a plan to merge your tests into upstream branch.
Thank you for your help.
|
By: Praveen Devarao
RE: IBM_DB with ActiveRecord unit test errors. [ reply ] 2011-10-06 04:16
|
Sure Yasuo.
One thing I will need to point on again is the tests packaged in IBM_DB are only those files which needed modifications for handling IBM_DB specifics. Hence you will need to replace these files in AR and continue to use the rest of the files for your regression.
Thanks
Praveen
|
By: Yasuo Honda
RE: IBM_DB with ActiveRecord unit test errors. [ reply ] 2011-10-05 20:38
|
Praveen,
Thank you for your answers. It is very clear to me.
I tried to IBM_DB gem works with ActiveRecord
unit tests and reduced the number of failures/erros from 51 failures/384 errors to 58 failures/132 errors of 3089 tests, but it would be a very long way to fix all of them.
Therefore I'll test with your tests bundled with the IBM_DB package for regression tests.
Regards,
|
By: Praveen Devarao
RE: IBM_DB with ActiveRecord unit test errors. [ reply ] 2011-10-05 04:28
|
Hi Yasuo,
You might want to have a look at the test suite modifications in the IBM_DB package. The files which need modifications (to handle DB2 specifics) is been changed over there.
Coming to your points in the post
1) This is been handled rightly
2) DB2 is not case-sensitive, hence CamelCase and camelcase are same. Due to this when table info is retrieved we get back CAMELCASE which will not match CamelCase. To solve this make changes in schema.rb to create camelcase table with name all in small letters (in a conditional if adapter is IBM_DB).
3) That's correct you cannot have the special character '-' in the table name. To work around this replace the '-' with '_ (in a conditional if adapter is IBM_DB) and you should be good to go. Also note you will need to rename your fixtures file warehouse-things.yml to warehouse_things.yml and inclusion of the same needs to be changed accordingly.
Let me know if you need clarification on any.
Thanks
Praveen
|
By: Yasuo Honda
IBM_DB with ActiveRecord unit test errors. [ reply ] 2011-10-04 18:27
|
Hi,
As I sometimes make commits ActiveRecord Oracle enhanced adapters,
then try to exeute ActiveRecord unit tests when any commits made
not to cause regressions other databases such as PostgreSQL and MySQL.
Recently, IBM_DB-2.5.7 gem supports Rails 3.1.0,
I'd like to test ActiveRecord unit tests with IBM DB2(LUW), then got some errors.
I'd like to hear from IBM DB2 professional point of view for these errors.
- Environment
Rails master branch
ruby 1.9.2 p 290(Linux 64-bit)
DB2 Express-C 9.7.4 for Linux 64-bit.
- Commands executed
$ cd rails/activerecord
$ rake test_db2
- 3 errors I've met
#1 SQL0604N: when it tries to create table with decimal(55,0) column
/var/lib/jenkins/.rvm/gems/ruby-1.9.2-p290@rails_master/gems/ibm_db-2.5.7/lib/active_record/connection_adapters/ibm_db_adapter.rb:1910:in `rescue in execute': RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL0604N The length, precision, or scale attribute for column, distinct type, structured type, array type, attribute of structured type, routine, cast target type, type mapping, or global variable "decimal(55,0)" is not valid. SQLSTATE=42611 SQLCODE=-604: CREATE TABLE numeric_data (id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, bank_balance decimal(10,2), big_bank_balance decimal(15,2), world_population decimal(10,0), my_house_population decimal(2,0), decimal_number_with_default decimal(3,2) DEFAULT 2.78, temperature float, atoms_in_universe decimal(55,0)) (ActiveRecord::StatementInvalid)
According to the IBM DB2 manual,
Table 2. Numeric Limits
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.sql.ref.doc%2Fdoc%2Fr0001029.html
Description Limit
Largest decimal precision 31
The largest decimal precision is 31, I made a following modification has made at my repository.
it has not pushed to the upstream one yet.
https://github.com/yahonda/rails/commit/575e8d7e3bf5f2a9e6c043cc6fac6a8c5247516d
--
395 + # IBM DB2 supports precision up to 31
396 + elsif current_adapter?(:IBM_DBAdapter)
397 + t.decimal :atoms_in_universe, :precision => 31, :scale => 0
--
Now I'm planning to do push request for this commit after addressing error #2 and #3 also.
#2 SQL0601N: when recreating CamelCase table when it exists as CAMELCASE
At 2nd time execution of "rake test_db2", the following error happend.
/var/lib/jenkins/.rvm/gems/ruby-1.9.2-p290@rails_master/gems/ibm_db-2.5.7/lib/active_record/connection_adapters/ibm_db_adapter.rb:1910:in `rescue in execute': RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL0601N The name of the object to be created is identical to the existing name "ARUNIT.CAMELCASE" of type "TABLE". SQLSTATE=42710 SQLCODE=-601: CREATE TABLE CamelCase (id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, name varchar(255)) (ActiveRecord::StatementInvalid)
"rake test_db2" will create each tables described in schema.rb. "CamelCase" table will be created as follows.
https://github.com/rails/rails/blob/master/activerecord/test/schema/schema.rb
--
101 create_table "CamelCase", :force => true do |t|
102 t.string :name
103 end
--
Here is my assuption based on trace files captured during rake test_db2.
- Trace files were captured with following commands.
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING TRACE 1
$ db2 UPDATE CLI CFG FOR SECTION COMMON USING TRACEPATHNAME /var/tmp/db2
1st execution - arunit user does not have any tables.
Following SQL executed, then the "CAMELCASE" table created.
--
p25845t87348992.cli:( StmtOut="CREATE TABLE CamelCase (id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, name varchar(255))" )
--
2nd execution of rake test_db2 with arunit user has their tables.
As :force => true option specified within create_table method,
rake test would try to drop the table if already exists by table_exists,
but it did not drop "CAMELCASE" table for some reason.
I tried to investigate the reason from IBM_DB modules but I gave it up when I reached to the" ibm_db.c".
I'd be happy if anyone has an idea how to investigate or handle this error.
#3 SQL0104N: when creating 'warehouse-things' table
/var/lib/jenkins/.rvm/gems/ruby-1.9.3-rc1@rails_master/gems/ibm_db-2.5.7/lib/active_record/connection_adapters/ibm_db_adapter.rb:1910:in `rescue in execute': RuntimeError: Failed to execute statement due to: [IBM][CLI Driver][DB2/LINUXX8664] SQL0104N An unexpected token "-" was found following "EATE TABLE warehouse". Expected tokens may include: ".". SQLSTATE=42601 SQLCODE=-104: CREATE TABLE warehouse-things (id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1) PRIMARY KEY, value integer) (ActiveRecord::StatementInvalid)
At 1st execution of rake test_db2,
https://github.com/yahonda/rails/blob/master/activerecord/test/schema/schema.rb
--
656 create_table 'warehouse-things', :force => true do |t|
657 t.integer :value
658 end
--
Accoriding to the following manual, It looks hypens are not allowed for table names
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/index.jsp?topic=%2Fcom.ibm.db2.luw.admin.dbobj.doc%2Fdoc%2Fc0007246.html
>>
DB2 object naming rules
Table 2. Database object naming rules
... snip ...
Package names and package versions can also include periods (.), hyphens (-), and colons (:).
<<
Same as #2, I'd be happy if anyone has an idea how to investigate or handle this error.
Thanks in advance,
|
|
 |