-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix slice specific repository commands from being nil #14
Comments
ℹ️ This still doesn't work on Hanami 2.2.0, RC1. This seems like a major issue for releasing 2.2.0. |
Agree that Can you take an attempt at opening a PR fixing this @bkuhlmann? I hope it's a simple fix since they already work on the main application slice |
OK, I'll drop you a line if I find anything (no promises, got a bunch of irons in the fire). |
@bkuhlmann I think this should be fixed in hanami/hanami#1478 |
Hey Armin, thanks, but I'm afraid I still get the gem "hanami", github: "wuarmin/hanami", branch: "fix_slice_repo_root_auto_setting" My initial glance at your fixes might stem from the fact that you check for constants that end in |
Hey @bkuhlmann, thanks |
Hmm, I'm afraid there was no change in behavior with your latest change either. If it helps, I updated the steps to recreate above so they are more clear. You might want to clone my project and run the test to see. You'd only need to make an additional modification to the
Here's the output from the test suite as well: RSpec Output
The only spec failures are with the |
@bkuhlmann oh, I see, I hadn't looked at your code that closely, I just experienced the same behavior. Of course, you completely omit the term “Repo” or “Repository” in your class name. Then I would recommend adapting the repo-class-name convention: module Tasks
module Repositories
class TaskRepo < DB::Repository # or TaskRepository
end
end
end or to set the root explicitly: module Tasks
module Repositories
class Task < DB::Repository[:tasks] # set root explicitly
end
end
end I would adapt my repo-class-name convention. |
Ah, yes, using Ancestors[Tasks::Repositories::Task,
ROM::Repository::RelationReader::InstanceMethods,
#<ROM::Repository::RelationReader:0x0000000129a9af18>,
Dry::Initializer::Mixin::Local[Tasks::Repositories::Task],
#<Class:0x0000000128e33e00>,
Dry::Initializer::Mixin::Local[#<Class:0x0000000128e33e00>],
Tasks::DB::Repository,
Dry::Initializer::Mixin::Local[Tasks::DB::Repository],
Hemo::DB::Repository,
Dry::Initializer::Mixin::Local[Hemo::DB::Repository],
Hanami::DB::Repo,
Hanami::Extensions::DB::Repo,
Dry::Initializer::Mixin::Local[Hanami::DB::Repo],
ROM::Repository,
ROM::Initializer::InstanceMethods,
Dry::Initializer::Mixin::Root,
Dry::Initializer::Mixin::Local[ROM::Repository],
Dry::Core::Cache::Methods,
Object,
PP::ObjectMixin,
JSON::Ext::Generator::GeneratorMethods::Object,
DEBUGGER__::TrapInterceptor,
Kernel,
BasicObject] You'll notice the In summary, I think fixing this so people can think in terms of normal inheritance would be the least surprising behavior because the new Hanami DB gem is already wrapping and attempting to mask ROM behavior. One way to do this -- albeit not entirely elegant -- is to ask if the current object (my class in this case) can respond (i.e. |
Why
Hello. 👋 When using ROM commands within a slice, they end up as
nil
objects. My initial guess is something is broken with object inheritance because commands work if used with repository objects within the application slice (i.e. the main slice).How
In my case, I have a
Tasks
slice which uses ROM commands for create, update, and delete:Source Code
Notice that I've disabled (commented) the
commands
macro in favor of creating the equivalent methods for create, update, and delete. That's the workaround. ...but I'd prefer to use only thecommands
macro and delete the additional methods.This appears to work when working within a normal Hanami 2.2.0, Beta 2 application with no slices.
Steps to Recreate
https://github.com/bkuhlmann/hemo
.bin/setup
.commands
macro and comment thecreate
,update
, anddelete
methods.nil
exceptions being thrown. You can revert the changes to make the specs pass again.The text was updated successfully, but these errors were encountered: