Skip to content

Doesn't work with Rails 7 #13

@rmeritz

Description

@rmeritz
  • When I try and find a model backed by a scenic mysql view and rails 7, I get the following error:
 NoMethodError: undefined method `match' for nil:NilClass                                                                                          
from /home/rebecca/.rbenv/versions/2.7.5/lib/ruby/gems/2.7.0/gems/activerecord-7.0.3/lib/active_record/connection_adapters/mysql/schema_statements
.rb:162:in `default_type'
  • I was able to fix it via adding the following monkey patch:
module ActiveRecord
  module ConnectionAdapters
    class AbstractMysqlAdapter < AbstractAdapter
      def create_table_info(table_name) # :nodoc:
        info = exec_query("SHOW CREATE TABLE #{quote_table_name(table_name)}", "SCHEMA").first
        info["Create Table"] || info["Create View"]
      end
    end
  end
end
  • All of the existing tests in the repo work with Rails 7. I tried to figure out how to add a test, that would catch this problem but I'm unsure how to do it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions