Closed kjetilk closed 8 years ago
Where do you want this check to happen? In the planner? Or the model? I can think of a few different options here:
$self
) aren't the same type (or, that one and only one is a model object)Attean::API::CostPlanner
so that the role that models consume when they can do some planning isn't identical to the one full query planners consume.It seems the latter option isn't very attractive, since what the model and the planner does in this regard is very similar, and so should be a single role.
I think both the planner and the model should check, and it sounds like a reasonable check that they aren't the same time and only one is a model object.
They're very similar, yes. But models don't have to return a cost for all plans. They have the option of returning undef
and letting the upstream planner handle it. The upstream planner is required to generate costs for all plans. That seems like a relevant difference, doesn't it?
For now, I can add the checks about the two objects not being the same.
Right, that's a good point! Any of them would have caught the previous error, so it works for me. Thanks!
Yup, this looks good. Would have caught the problem for sure!
Since the bugs caused by mixing up the second argument, plan/model to
cost_for_plan
causes pretty obscure problems, I think we should make it croak if that happens. I looked into it (and therefore started feature-cost-ensure-planner), but then I became unsure how to do it... Since you can't just checkdoes('Attean::API::CostPlanner')
since they both do that. It could be implemented in that role, but would we checkisa('Attean::QueryPlanner')
, etc? That would then mean that all query planners would extend that instead of just composing everything...