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

Sequel ORM backend raises error with Fabrication #320

Open
hedselu opened this issue Mar 2, 2021 · 1 comment
Open

Sequel ORM backend raises error with Fabrication #320

hedselu opened this issue Mar 2, 2021 · 1 comment

Comments

@hedselu
Copy link

hedselu commented Mar 2, 2021

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

@paulelliott
Copy link
Owner

I'm not seeing this in the fabrication test suite, which activates the gem similarly to how a real project would. Is there anything else you could tell me about your setup that might help to track this down? A PR reproducing the failure would be welcome as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants