Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #1418 (closed enhancement: duplicate)

Opened 3 years ago

Last modified 3 years ago

[XPATCH] Firebird Adapter

Reported by: wishdev@gmail.com Assigned to: Jeremy Kemper <rails@bitsweat.net>
Priority: normal Milestone: 1.1
Component: ActiveRecord Version: 0.12.1
Severity: normal Keywords: firebird
Cc:

Description

This is a Firebird Adapter.

The patch is based upon revision 1396 of the svn trunk. The only problem is that it incorporates the same changes that are in Patch #1391 because they are required for the adapter. If someone can tell me how to do an svn diff after adding Patch #1391 I will be more then happy to split it out.

The adapter requires my Redbird database driver (which is basically the ruby-interbase driver with Rails changes). It can be found here http://rubyforge.org/projects/redbird

The following tests current error/fail on the driver (along with binary_test which is by-passed as is the case with DB2 and Oracle)

Error:test_building_the_belonging_object(BelongsToAssociationsTest): Error:test_creating_the_belonging_object(BelongsToAssociationsTest): Error:test_first_level(ClassInheritableAttributesTest): Error:test_second_level(ClassInheritableAttributesTest): Error:test_assignment_without_replacement_on_create(HasOneAssociationsTest): Failure:test_failing_with_object_rollback(TransactionTest) ./test/transactions_test.rb:68: Failure:test_nested_explicit_transactions(TransactionTest) ./test/transactions_test.rb:97: Failure:test_successful(TransactionTest) ./test/transactions_test.rb:19: Failure:test_successful_with_instance_method(TransactionTest) ./test/transactions_test.rb:31:

It should be noted that each of these error/failures also exist for the SQLite adapter under revision 1396 (at least on my machine). Therefore I believe that they may not be a direct result of nor a problem with the Firebird Adapter.

Sorry if this was too long - I like to cover all bases on larger patches!

Attachments

FirebirdAdapter.patch (57.1 kB) - added by wishdev@gmail.com on 06/09/05 21:59:26.
Firebird Adapter Patch
FirebirdAdapter.2.patch (57.1 kB) - added by wishdev@gmail.com on 06/09/05 22:10:51.
Sorry missed a file in the first try - this should be better
firebird_adapter.patch.1447 (55.3 kB) - added by wishdev@gmail.com on 06/16/05 16:55:06.
Brought up to rev 1447
1455.patch (55.4 kB) - added by wishdev@gmail.com on 06/20/05 17:19:34.
Update to rev 1455 - Small change to add created_at and updated_at to the developers definition

Change History

06/09/05 21:59:26 changed by wishdev@gmail.com

  • attachment FirebirdAdapter.patch added.

Firebird Adapter Patch

06/09/05 22:10:51 changed by wishdev@gmail.com

  • attachment FirebirdAdapter.2.patch added.

Sorry missed a file in the first try - this should be better

06/16/05 05:37:14 changed by david

All tests now pass for the SQLite adapter. Could you rerun the tests for this and verify that all is good?

06/16/05 16:54:27 changed by wishdev@gmail.com

I've updated the patch to reflect svn changes up to revision 1447. I still have 2 errors that I get for both my adapter and sqlite. I don't understand the area all that well so I'll include the error (it's 2 of the exact same error in the same spot) and maybe you can lead me in the right path :) It seems to have an issue with test/fixtures/default.rb which is something I don't touch with a ten foot pole :)

1) Error:

test_first_level(ClassInheritableAttributesTest): Fixture::FormatError: ./test/fixtures/default.rb: fixture format error at 'class Default < ActiveRecord::Base '. Expecting 'key => value'.

./test/../lib/active_record/fixtures.rb:399:in `read_fixture_file' ./test/../lib/active_record/fixtures.rb:393:in `inject' ./test/../lib/active_record/fixtures.rb:393:in `each' ./test/../lib/active_record/fixtures.rb:393:in `inject' ./test/../lib/active_record/fixtures.rb:393:in `read_fixture_file' ./test/../lib/active_record/fixtures.rb:345:in `initialize' ./test/../lib/active_record/fixtures.rb:310:in `new' ./test/../lib/active_record/fixtures.rb:310:in `read_fixture_files' ./test/../lib/active_record/fixtures.rb:307:in `each' ./test/../lib/active_record/fixtures.rb:307:in `read_fixture_files' ./test/../lib/active_record/fixtures.rb:270:in `initialize' ./test/../lib/active_record/fixtures.rb:231:in `new' ./test/../lib/active_record/fixtures.rb:231:in `create_fixtures' ./test/../lib/active_record/fixtures.rb:230:in `map' ./test/../lib/active_record/fixtures.rb:230:in `create_fixtures' ./test/../lib/active_record/fixtures.rb:536:in `load_fixtures' ./test/../lib/active_record/fixtures.rb:493:in `setup'

06/16/05 16:55:06 changed by wishdev@gmail.com

  • attachment firebird_adapter.patch.1447 added.

Brought up to rev 1447

06/20/05 17:19:34 changed by wishdev@gmail.com

  • attachment 1455.patch added.

Update to rev 1455 - Small change to add created_at and updated_at to the developers definition

06/21/05 05:53:25 changed by david

What's the reason for all the exceptions in the tests? Why must the type column be in uppercase?

Also, could you submit a version of the patch with proper indention? We're 2 spaces, no tabs.

06/21/05 08:25:41 changed by wishdev@gmail.com

I'll try and get the patch straightened out tonight. The type column issue is because Firebird views type as a reserved word so it at least wants it quoted - and I believe since I have it quoted and uppercased in the definition that it would want it uppercased in the SQL. Upper case is the normal convention on Firebird as far as I know. Using :type for the conditions does remove the issue because when the sql string is created by AR the Firebird adapter compensates for reserved keywords. The test cases use a lot of manual sql conditions and therefore exceptions are much more prevalent there. I'm not the best at "ruby-enhanced" coding - I'm sure there are plenty of optimizations that could be made in this area....

06/21/05 11:37:59 changed by bitsweat

  • cc set to rails@bitsweat.net.
  • keywords set to firebird.
  • summary changed from [PATCH] Firebird Adapter to [XPATCH] Firebird Adapter.
  • severity changed from normal to enhancement.
  • milestone set to 1.x.

Does Firebird deal with lowercase column names? If so, it'd be simpler (and easier) to stick with the AR convention rather than introduce a new one.

06/21/05 12:31:05 changed by wishdev@gmail.com

I admit I'm a litle shaky on my answer to this but here goes. Firebird I believe will handle the upper or lower case scenarios just fine - with one big exception....quoted column names retain their case (which I believe is actually the SQL92 standard). Normally this is fine - except for the fact that firebird has reserved "type" as a keyword and therefore to have a column name called type you need it quoted and therefore it is now case-sensitive. This means that at the very least I'm looking at an exception to have "type" quoted for firebird, even if we use lower case.

The other piece of the puzzle is that the majority of firebird tool and I believe firebird users use upper case as the default for all column names. Since I was already going to need the exception because of the quoting I went with upper case for "TYPE". The adapter will lower case all ActiveRecord references to the field and deals with upper casing everything that the adapter needs internally. This is the only area (user defined conditions) where I run into issues.

If this really is a show stopper - I shall see what I can do if it's going to cause too much pain....

08/16/05 10:50:57 changed by anonymous

yes, firebird treats intMyField and INTMYFIELD as th same thing but "intMyField" and "INTMYFIELD" are two different fields. Because type is a keyword, you get a double whammy, in that it must be quoted, and therefor "TYPE" "Type" and "type" are three distinctly different fields.

11/16/05 06:23:06 changed by bitsweat

  • cc deleted.
  • owner changed from David to bitsweat.

Hey wishdev, are you and Ken Kunz working together? (see #1874)

A unified effort on the Firebird adapter would be great.

11/16/05 08:22:06 changed by bitsweat

  • status changed from new to closed.
  • resolution set to duplicate.

Superseded by #1874.