-
Notifications
You must be signed in to change notification settings - Fork 342
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
How do you deal with circular imports ? #59
Comments
Hi! In the example of @aggregated models are in the same file. I'd try something like this http://docs.sqlalchemy.org/en/latest/orm/query.html#sqlalchemy.orm.query.Query.count in the query. Probably @frol could suggest something more useful. |
I am not completely sure I got your question, but here are some ideas:
|
Thanks for the quick answers. Sorry for the missing examples. @aggregated('unpaid_consultations', db.Column(db.Integer))
def unpaid_consultations_count(self):
return db.func.count(Patient.unpaid_consultations)
unpaid_consultations = db.relationship(
'Claim',
primaryjoin=
'and_(Claim.patient_id == Patient.id, Claim.invoice_id.is_(None))',
viewonly=True
) This is actually working really fine. I would like to be able to have maybe aggregate like this : @aggregated('unpaid_consultations', db.Column(db.Integer))
def unpaid_sum(self):
return db.func.sum('amount').label('unpaid_sum') To return the sum of the amount column select by the above relationship... (I know this isn't related to this project directly, I appreciate your help!) |
In fact my query is something like : SELECT SUM(amount) FROM claim WHERE patient_id = %d AND invoice_id IS NOT NULL; |
Yes this is what I've been up these last minutes. @aggregated('claims', db.Column(db.Integer))
def unpaid_sum(self):
return db.func.sum(Claim.amount) |
For example I have models like this :
Patient is in dedicated module "patient"
and claim model is in 'accounting' modules with other models related to accounting.
The problem is I can't import claim model and I can't access to claim model in patient model in order to, for example, make the sum of claims amount.
I think this is some design issue, but I want to be sure if there's any workaround before rewriting....
The text was updated successfully, but these errors were encountered: