Skip to content
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

what does this error mean #9

Open
sylvoslee opened this issue Jul 8, 2022 · 2 comments
Open

what does this error mean #9

sylvoslee opened this issue Jul 8, 2022 · 2 comments

Comments

@sylvoslee
Copy link

  File "D:\db\logic.py", line 8, in declare_logic
    Rule.sum(
  File "C:\lib\site-packages\logic_bank\logic_bank.py", line 104, in sum
    return Sum(derive, as_sum_of, where)
  File "C:\lib\site-packages\logic_bank\rule_type\sum.py", line 30, in __init__
    self._child_role_name = self.get_child_role_name(child_attrs=child_attrs)
  File "C:\\lib\site-packages\logic_bank\rule_type\aggregate.py", line 258, in get_child_role_name
    raise Exception(
Exception: Invalid 'as_sum_of' - not a reference to: Pur in Derive Pur.r_qty as Sum(Pur.qty Where None)
@valhuber
Copy link
Owner

valhuber commented Jul 8, 2022

Sorry, looks like a very poor error message.

It appears that the summed attribute is not in the child table.

For example, in the sample, see

Rule.sum(derive=models.Customer.Balance, # adjust iff AmountTotal or ShippedDate or CustomerID changes
as_sum_of=models.Order.AmountTotal,
where=lambda row: row.ShippedDate is None) # adjusts - *not* a sql select sum...

AmountTotal must be a valid attribute in Order (the child table being summed into Customer.Balance).

I would think that code completion would work here, so you get only valid choices.

If this is not enough, perhaps I would need to see your project.

@valhuber
Copy link
Owner

valhuber commented Nov 2, 2022

It may also be due to multiple relationships between 2 tables (Dept to Employees -- worksFor, onLoan). Fix in progress

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

No branches or pull requests

2 participants