ibmdb / ruby-ibmdb

Rails Adapter/Ruby driver for IBM DB2 and IBM Informix
42 stars 48 forks source link

Various issues with ibm_db and Rails 7.1.2 #165

Closed scotdb closed 1 month ago

scotdb commented 8 months ago

Coming back to Rails development after quite some time away.

Looks like things have regressed, plus there are issues with currency.

Here's what I've found in terms of general points -

1) The code that used to automatically support ibm_db within Rails has been taken out. It looks like we have to again manually patch in ibm_db as one of the supported platforms. I remember the joy when a patch to add ibm_db to the supported platforms was accepted, so why has this been allowed to get removed !!! 2) There is no template ibm_db.yml.tt available. The recommendation on a previous issue to copy an old ibm_db.yml.tt file from when this was removed from Rails is hardly helpful for anybody but the most dedicated Db2 users, particularly as the file pointed to relates to a different ibm_db from the IBM developed and supported ones.

Then I come to points specific to the latest Rails version (V7.1.2).

I get this message when trying to issue "rails my myapp --database=ibm_db"

Could not find compatible versions

Because ibm_db >= 5.4.0 depends on activerecord < 7.1 and rails >= 7.1.2 depends on activerecord = 7.1.2, ibm_db >= 5.4.0 is incompatible with rails >= 7.1.2. So, because Gemfile depends on rails ~> 7.1.2 and Gemfile depends on ibm_db ~> 5.4.1, version solving has failed.

When I list the ibm_db gem dependency I get essentially the same information -

$ gem dependency ibm_db Gem ibm_db-5.4.1 activerecord (< 7.1) down (>= 0) zip (>= 0)

So the ibm_db gem has not kept up to date with the Rails (ActiveRecord) versions. Admittedly it is only about 3 months since Rails 7.1 came out, but folks will be wanting to use the latest versions, not have to specify old versions on installation.

Like other Db2 adapters / tools, you need to be tracking the release cycles so that when new versions come out you are ready for them.

praveen-db2 commented 8 months ago

@scotdb ibm_db v 5.4.0 is meant to support rails 7.0, and its dependency packages also must be <= 7.0. Officially we are yet to support rails v 7.1. Its in our pipeline.

Coming to your points 1 and 2. Point 1, I didnt get what you are saying, can you please clarify this in details. Point 2, In this issue https://github.com/ibmdb/ruby-ibmdb/issues/164 If you read it clearly, I had specified from where you can get ibm_db.yml.tt file.

scotdb commented 8 months ago

With regard to your two questions -

Many years ago I worked with Antonio Cangiano to ensure that the Db2 drivers worked right away without having to manually modify the Rails code. Antonio submitted a patch that got the changes you are now suggesting need to be made manually into the Rails codebase -

https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1136-patch-to-enable-databaseibm_db

This was in 2008 at the Rails 2.x level. It was a great day for Db2 support, since it meant that you didn't have to do any manual tinkering with the Rails code to allow Db2 to work - you just needed to install ibm_db adapter and you were good to go.

It looks like at some point (possibly about 2012 if my Googling is correct) this patch was reversed. Why was this allowed to happen: why did nobody from IBM shout about this and prevent it happening. You aren't going to get people use Db2 as their back end database if it is hard to get working. I myself am a big Db2 fan, having spent a lifetime advocating for its wider acceptance - but the majority of folks are just going to go for one of the options that works out of the box.

It's the same with the yml configuration file for Db2 connections. It looks like this has also been removed from the base code. The link you sent in the previous ticket is where it gets removed from the Rails codebase. There is nothing in the documentation provided with ibm_db to say that you need to make these changes.

Since you are not going to be able to generate a Rails application without these two changes you should at the very least be -

1) Documenting this as part of the documentation shipped with the ibm_db adapter and on the adapter web page 2) Providing the sample yml file as part of the ibm_db installation and also a patch that can be applied to the Rails code.

It isn't acceptable that you wait for people to raise a ticket when things don't work and then point them at a 12 year old ticket to try to piece together what needs put back from the diffs.

Providing the information in the adapter repository is the minimum you should be doing. Ideally you should be -

a) Working to get the Db2 support put back into the Rails code, and ensuring that it doesn't get removed again b) Providing a decent sample in the ibm_db codebase itself if that is easier to maintain (although I doubt there is much that will need updated ever, so it is better in the Rails code itself)

Beyond that you should be looking to support modern methods of setting up a Db2 connection (db2dsdriver.cfg for example).

praveen-db2 commented 8 months ago

@scotdb I had created github issue for rails framework to support DB2 back in their framework. Here is link https://github.com/rails/rails/issues/50537 They are very clear that they are committed to only maintaining three default options: sqlite, PostgreSQL, mysql

Even otherwise, As you suggested I will document the same in our adapter page so it helps in future.

scotdb commented 8 months ago

I've replied on the Rails thread. While they state they only support three databases, the code tells a different story -

 JDBC_DATABASES = %w( jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc )
  DATABASES = %w( mysql trilogy postgresql sqlite3 oracle sqlserver ) +

JDBC_DATABASES

It's only the Db2 entry that has been removed, leaving other entries such as oracle, sqlserver and trilogy (whatever that is) in place.

Phil

On Tue, 2 Jan 2024 at 16:54, Praveen Narayanappa @.***> wrote:

@scotdb https://github.com/scotdb I had created github issue for rails framework to support DB2 back in their framework. Here is link rails/rails#50537 https://github.com/rails/rails/issues/50537 They are very clear that they are committed to only maintaining three default options: sqlite, PostgreSQL, mysql

Even otherwise, As you suggested I will document the same in our adapter page so it helps in future.

— Reply to this email directly, view it on GitHub https://github.com/ibmdb/ruby-ibmdb/issues/165#issuecomment-1874284838, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAP7FQ4AEFJGSQ3CCF4ZNDYMQ3V7AVCNFSM6AAAAABBJIPA2CVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGI4DIOBTHA . You are receiving this because you were mentioned.Message ID: @.***>

jfahrenkrug commented 5 months ago

Just a "plus one" for adding support for Rails 7.1 soon. I'd like to be able to use the new bin/rails routes --unused feature in 7.1. Thanks for your ongoing work!

praveen-db2 commented 5 months ago

@jfahrenkrug I had started working on to support Rails 7.1, in coming days we will release new version for the same.

jfahrenkrug commented 4 months ago

@praveen-db2 It's exciting that you are working on Rails 7.1 support. Thank you! A major feature of Rails 7.1 that I'm looking forward to is composite primary keys (see https://guides.rubyonrails.org/7_1_release_notes.html#composite-primary-keys and https://edgeguides.rubyonrails.org/active_record_composite_primary_keys.html). Will the next version of the IBM_DB gem include support for composite primary keys?

matthewkrom commented 2 months ago

@praveen-db2 Thanks for your continuing effort. I too am wondering if you'll be able to announce Rails 7.1 compatibility, and also if you could test against Ruby 3.2 and Ruby 3.3.

matthewkrom commented 2 months ago

I'll move my Ruby 3.2 / 3.3 notes to a separate issue.

praveen-db2 commented 1 month ago

closing this issue.