Explorar o código

Fix user_manager get_user_tags sql

StrayWarrior hai 2 días
pai
achega
e9709f5f4e
Modificáronse 1 ficheiros con 4 adicións e 1 borrados
  1. 4 1
      pqai_agent/user_manager.py

+ 4 - 1
pqai_agent/user_manager.py

@@ -273,8 +273,11 @@ class MySQLUserManager(UserManager):
             sql = f"""
                 SELECT a.third_party_user_id, b.tag_id, b.name FROM qywx_user_tag a
                     JOIN qywx_tag b ON a.tag_id = b.tag_id
-                    AND a.third_party_user_id IN {str(tuple(batch_user_ids))}
                 """
+            if len(batch_user_ids) == 1:
+                sql += f" AND a.third_party_user_id = '{batch_user_ids[0]}'"""
+            else:
+                sql += f" AND a.third_party_user_id IN {str(tuple(batch_user_ids))}"
             rows = self.db.select(sql, pymysql.cursors.DictCursor)
             # group by user_id
             for row in rows: