diff --git a/app/dao/inbound_sms_dao.py b/app/dao/inbound_sms_dao.py index 690b007bc..6d1c266cb 100644 --- a/app/dao/inbound_sms_dao.py +++ b/app/dao/inbound_sms_dao.py @@ -84,9 +84,9 @@ def _insert_inbound_sms_history(subquery, query_limit=10000): InboundSms.provider, ).where(InboundSms.id.in_(subquery_select)) - inbound_sms_count = db.session.execute( - select(func.count()).select_from(inbound_sms_query.subquery()).scalars().one_or_none() or 0 - ) + count_query = select(func.count()).select_from(inbound_sms_query.subquery()).scalar() + print(f"COUNT QUERY {count_query}") + inbound_sms_count = db.session.execute(count_query) or 0 while offset < inbound_sms_count: statement = insert(InboundSmsHistory).from_select(