-
Notifications
You must be signed in to change notification settings - Fork 46
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
AggregateModel with referenced field in expression throwing error #1078
Labels
Comments
@mkrecek234 thank you for describing the problem, please add here a small repro code that can be copied and run. |
Please check this sample code based on a MySQL database as described showing the error:
|
This was referenced Dec 19, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps to reproduce:
open_amount
(ignore the name, in fact it is a "sign" that can be -1 or 1)article_geoup
andtotal_net
and which also adds the fieldopen_amount
through a hasOne relation to order_doc (so$this->hasOne('order_doc_id', ['model' => OrderDoc::class])->addField('open_amount')
)If you place a referenced field like
sign
(coming from a parent table) into the aggregate expressionsum(...)
, an erroneous SQL statement is created by Atk4/Data:Doctrine\DBAL\Driver\Mysqli\Exception\ConnectionError [code: 1054]: Unknown column '_od_odp_cfb1e779955f.order_doc_id' in 'where clause'
If you omit the [open_amount] in the expression, there is no error.
Expected result:
It correctly multiplies the child table's total_net with the parent tables sign and sums this up.
For more background here is the complete error:
The text was updated successfully, but these errors were encountered: