rsim / oracle-enhanced

Oracle enhaced adapter for ActiveRecord
MIT License
544 stars 308 forks source link

db:schema:load fails with error `NoMethodError: undefined method 'to_sym' for {:type=>:string, :limit=>36}:Hash` #2340

Open roygopal opened 1 year ago

roygopal commented 1 year ago

Steps to reproduce

In schema.rb/oracle_schema.rb file the syntax that is generated for default id column is in hash notation. It happens because of id: { type: :string, limit: 191 } syntax in oracle_schema.rb. When we change manually it to id: :string, limit: 36 then schema load passes. Generated migration (schema.rb/oracle_schema.rb)file has syntax as below create_table "settings", primary_key: "name", id: { type: :string, limit: 191 }, force: :cascade do |t|

Expected behavior

db:schema:load should pass.

Actual behavior

On db:schema:load, it fails with error NoMethodError: undefined methodto_sym' for {:type=>:string, :limit=>36}:Hash`

System configuration

Rails version: 6.1

Oracle enhanced adapter version: 6.1.0

Ruby version: >=3.0

Oracle Database version: XE

Screenshot 2023-05-19 at 10 24 52 PM
Physium commented 12 months ago

Hey i am facing this issue as well. is there a fix to this?

Currently on:

roygopal commented 12 months ago

@Physium For now, we solved it by applying monkey patches to our application. Added below patch and loaded this in config/initializers. See the attached screenshot. It worked for us.

Screenshot 2023-07-13 at 10 06 52 PM Screenshot 2023-07-13 at 10 08 54 PM
Physium commented 11 months ago

@roygopal thanks for sharing! Is there a reason why you patch here and not at this gem adapter level?

roygopal commented 11 months ago

@roygopal thanks for sharing! Is there a reason why you patch here and not at this gem adapter level?

No particular reason. Its just that in our app it was blocking other priority changes and due to time constraint we patched in our app.

Physium commented 11 months ago

Apologies, what i meant was that i notice that the code is to override TableDefinitation class which seems like an ActiveRecord thing. Shouldn't the patch be targeting some class under the gem adapter layer? I dont know enough about this adapter and the underlyng of how it work hence would just like to understand how this patch works.