admin管理员组

文章数量:1123101

There is a class that acts as a repository, and it has a .summary_rewards method, so, on my local machine it returns one data, and on my server it returns completely different data when I use this method. The timestamp data in the table is naive, the input data for searching is also naive. The time zone in the database settings is UTC. The isolation level is read committed.

What could be wrong? The server and my local machine have absolutely identical copies of my application.

class ReferalEntityRewardsRepository(SQLAlchemyRepository):

    model = ReferalEntityReward

    async def summary_rewards(self, start_dt: datetime, end_dt: datetime, currency: str = 'rub', **filter_by):

        currency_map = {
            'rub': self.model.amount,
            'usd': self.model.amount_usd
        }

        stmt = (
            select(func.count(self.model.id).label("total_rewards"), func.sum(currency_map[currency]).label("total_amount"))
            .filter_by(**filter_by)
            .filter(self.model.add_dt.between(start_dt, end_dt))
        )

        result = await self.session.execute(stmt)
        total_rewards, total_amount = result.all()[0]

        return total_rewards, total_amount

本文标签: sqlI get incorrect data when I use betweenStack Overflow