Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/dao/notifications_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ def dao_timeout_notifications(cutoff_time, limit=100000):
)

Notification.query.filter(
Notification.id.in_([n.id for n in notifications]),
Notification.id.in_(n.id for n in notifications),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SQLAlchemy source is too convoluted to work out exactly how this will behave but I would be very wary of inadvertent generator exhaustion here.

The documentation says to use a list (although it doesn’t say not to use a generator).

I’d consider carefully:

  • how much time/memory this is saving in the overall context of a request/task
  • the complexity cost and potential for introducing subtle errors
  • how good this function’s test coverage is

).update({"status": new_status, "updated_at": updated_at}, synchronize_session=False)

db.session.commit()
Expand Down Expand Up @@ -698,7 +698,7 @@ def dao_update_notifications_by_reference(references, update_dict):


def dao_get_unknown_references(references):
v = values(column("reference", String), name="references").data([(r,) for r in references])
v = values(column("reference", String), name="references").data((r,) for r in references)

return (
db.session.execute(
Expand Down
2 changes: 1 addition & 1 deletion app/dao/services_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def _delete(query):
_delete(ApiKey.get_history_model().query.filter_by(service_id=service.id))
_delete(AnnualBilling.query.filter_by(service_id=service.id))

verify_codes = VerifyCode.query.join(User).filter(User.id.in_([x.id for x in service.users]))
verify_codes = VerifyCode.query.join(User).filter(User.id.in_(x.id for x in service.users))
list(map(db.session.delete, verify_codes))
users = list(service.users)
for user in users:
Expand Down