Skip to content
This repository was archived by the owner on Mar 15, 2021. It is now read-only.
This repository was archived by the owner on Mar 15, 2021. It is now read-only.

Sequel ORM backend raises error with Fabrication #320

@hedselu

Description

@hedselu

Hi.
When integrating Fabrication with Sequel gem it raises error when trying to create fabrication object.

Minitest::UnexpectedError: FrozenError: can't modify frozen Array: [Sequel::Model, Sequel::Model::Associations
...
 /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sequel-5.41.0/lib/sequel/model/base.rb:500:in `plugin'
            /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/fabrication-2.21.1/lib/fabrication/generator/sequel.rb:33:in `load_instance_hooks'
            /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/fabrication-2.21.1/lib/fabrication/generator/sequel.rb:5:in `initialize'
            /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/fabrication-2.21.1/lib/fabrication/schematic/definition.rb:82:in `new'
            /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/fabrication-2.21.1/lib/fabrication/schematic/definition.rb:82:in `block in fabricate'
            /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/fabrication-2.21.1/lib/fabrication/schematic/definition.rb:81:in `instance_eval'
            /Users/hedselu/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/fabrication-2.21.1/lib/fabrication/schematic/definition.rb:81:in `fabricate'
...

Looks like Sequel is freezing plugins instance variable array after initialization, and by this, disallowing addition of

klass.plugin :instance_hooks unless klass.new.respond_to? :after_save_hook

in this place

Sequel version: 5.41.0
Fabrication version: 2.21.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions