The update of SQLAlchemy 1.4.10 has caused some conflicts in our code. This PR fixes most of those conflicts.

- sqlalchemy.sql.expression.case must include an else statement.
- clearly define list of columns for inbound_sms_history insert, getting the list from InboundSmsHistory.__table__.c was causing data type errors.
- remove relationships when not needed, the foreign key relationship is established in the creation of the column. This will get rid of the warnings referenced here: http://sqlalche.me/e/14/qzyx.
- update queries now that he user relationship in ServiceUser db model has been removed.
- move the check that a template is archived to the view instead of the dao method. The check was clearing the session before the version history could be done.

Deleting notifications in the night tasks still needs to be
investigated. The raw sql is causing an error.
This commit is contained in:
Rebecca Law
2021-04-26 11:50:17 +01:00
parent e1a626855d
commit 1b070d69a1
8 changed files with 24 additions and 50 deletions

View File

@@ -150,9 +150,12 @@ def fetch_letter_line_items_for_all_services(start_date, end_date):
[(FactBilling.postage.in_(INTERNATIONAL_POSTAGE_TYPES), "international")], else_=FactBilling.postage
).label("postage")
postage_order = case(((formatted_postage == "second", 1),
(formatted_postage == "first", 2),
(formatted_postage == "international", 3)))
postage_order = case(
(formatted_postage == "second", 1),
(formatted_postage == "first", 2),
(formatted_postage == "international", 3),
else_=0 # assumes never get 0 as a result
)
query = db.session.query(
Organisation.name.label("organisation_name"),