[Rails] debugging new database adapter

Eric Ocean subscriber at ampede.com
Sat Nov 27 07:01:03 GMT 2004


Hi everybody.

I'm working on an adaptor for FrontBase. I'm new to Ruby, new to Rails,  
and not exactly an SQL expert. Thankfully, not new to programming. :-)  
Still...

I've got my adapter connecting to the database and I can run the tests  
(i.e. rake test_frontbase). Of course, I get tons of errors. When I  
examine my SQL log, though, I see that no SELECTS are being done, just  
BEGIN, DELETE, INSERT, ROLLBACK, over and over again. That can't be  
right. :-(

At this point I could really use a way to track execution, set a  
breakpoint, etc. It's pretty hard for me to see what's going on. Any  
pointers on how to debug this thing? (I'm using an activerecord  
checkout from subversion last night.)

Best, Eric


P.s Here's the first ~20 lines of the test_frontbase output. I've put  
the SQL being logged with it below.

ruby -Ilib:test:test/connections/native_frontbase -e0   
-rtest/aggregations_test  -rtest/associations_test  -rtest/base_test   
-rtest/class_inheritable_attributes_test   
-rtest/deprecated_associations_test  -rtest/finder_test   
-rtest/fixtures_test  -rtest/inflector_test  -rtest/inheritance_test   
-rtest/lifecycle_test  -rtest/modules_test  -rtest/multiple_db_test   
-rtest/pk_test  -rtest/reflection_test  -rtest/thread_safety_test   
-rtest/transactions_test  -rtest/unconnected_test   
-rtest/validations_test
Using native FrontBase
Loaded suite -e
Started
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE..EEEEE 
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 
EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE........EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE 
EEEEEEEEEEEEE.EEEEEEEEEEEEEEEE
Finished in 2.42201 seconds.

   1) Error:
test_change_single_value_object(AggregationsTest):
ActiveRecord::StatementInvalid: Semantic error 231. INSERT value  
doesn't match column: id.
Semantic error 485. Near: INSERT INTO  
"customers"("address_country","address_city","name","address_street","id 
","balance") VALUES('Loony Land','Scary Town','David','Funny  
Street','1','50');.
Semantic error 485. Near: '50'.
Semantic error 231. INSERT value doesn't match column: balance.
Exception 363. Transaction rollback.
: INSERT INTO customers (address_country, address_city, name,  
address_street, id, balance) VALUES('Loony Land', 'Scary Town',  
'David', 'Funny Street', '1', '50')
      
./test/../lib/active_record/connection_adapters/abstract_adapter.rb: 
342:in `log'
      
./test/../lib/active_record/connection_adapters/frontbase_adapter.rb: 
91:in `execute'
     ./test/../lib/active_record/fixtures.rb:105:in `insert_fixtures'
     ./test/../lib/active_record/fixtures.rb:104:in `each'
     ./test/../lib/active_record/fixtures.rb:104:in `insert_fixtures'
     ./test/../lib/active_record/fixtures.rb:83:in `initialize'
     ./test/../lib/active_record/fixtures.rb:68:in `new'
     ./test/../lib/active_record/fixtures.rb:68:in `create_fixtures'
     ./test/../lib/active_record/fixtures.rb:67:in `map'
     ./test/../lib/active_record/fixtures.rb:67:in `create_fixtures'
     ./test/../lib/active_record/fixtures.rb:66:in `transaction'
     ./test/../lib/active_record/fixtures.rb:66:in `create_fixtures'
     ./test/abstract_unit.rb:17:in `create_fixtures'
     ./test/aggregations_test.rb:7:in `setup_without_fixtures'
     ./test/../lib/active_record/fixtures.rb:195:in `setup'
     ./test/../lib/active_record/fixtures.rb:193:in `setup'

   2) Error:
test_find_multiple_value_object(AggregationsTest):
ActiveRecord::StatementInvalid: Semantic error 231. INSERT value  
doesn't match column: id.
Semantic error 485. Near: INSERT INTO  
"customers"("address_country","address_city","name","address_street","id 
","balance") VALUES('Loony Land','Scary Town','David','Funny  
Street','1','50');.
Semantic error 485. Near: '50'.
Semantic error 231. INSERT value doesn't match column: balance.
Exception 363. Transaction rollback.
: INSERT INTO customers (address_country, address_city, name,  
address_street, id, balance) VALUES('Loony Land', 'Scary Town',  
'David', 'Funny Street', '1', '50')
      
./test/../lib/active_record/connection_adapters/abstract_adapter.rb: 
342:in `log'
      
./test/../lib/active_record/connection_adapters/frontbase_adapter.rb: 
91:in `execute'
     ./test/../lib/active_record/fixtures.rb:105:in `insert_fixtures'
     ./test/../lib/active_record/fixtures.rb:104:in `each'
[...]

------------------------ BEGIN SQL LOG ---------------------------

-- *** New log file point: 2004-11-26 22:40:08 ***
--0 0043d8a0 2004-11-26 22:40:16 00000000
--1 0043d8a0 0048975c 2004-11-26 22:40:16 "_SYSTEM" "Ruby::DBI"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 27
SET TIME ZONE 'US/Pacific';
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 6
BEGIN;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "0 2"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 22
DELETE FROM customers;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 160
INSERT INTO customers (address_country, address_city, name,  
address_street, id, balance) VALUES('Loony Land', 'Scary Town',  
'David', 'Funny Street', '1', '50');
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "0 4"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 9
ROLLBACK;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 6
BEGIN;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "0 2"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 22
DELETE FROM customers;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 160
INSERT INTO customers (address_country, address_city, name,  
address_street, id, balance) VALUES('Loony Land', 'Scary Town',  
'David', 'Funny Street', '1', '50');
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "0 4"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 9
ROLLBACK;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 6
BEGIN;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "0 2"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 22
DELETE FROM customers;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 160
INSERT INTO customers (address_country, address_city, name,  
address_street, id, balance) VALUES('Loony Land', 'Scary Town',  
'David', 'Funny Street', '1', '50');
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "0 4"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 9
ROLLBACK;
--6 0043d8a0 0048975c 2004-11-26 22:40:16 "1 0"
--4 0043d8a0 0048975c 2004-11-26 22:40:16 6
BEGIN;
[...]



More information about the Rails mailing list