QAnything icon indicating copy to clipboard operation
QAnything copied to clipboard

[BUG] <INSERT IGNORE INTO User SQL报错>

Open luckyxue opened this issue 5 months ago • 1 comments

V2.0.0版本

当前行为 | Current Behavior

插入User表的sql错误,字段长度不匹配,如下:
# 对外接口不需要增加用户,新建知识库的时候增加用户就可以了
def add_user_(self, user_id, user_name):
    query = "INSERT IGNORE INTO User (user_id, user_name) VALUES (%s, %s, %s)"
    self.execute_query_(query, (user_id, user_name), commit=True)
    debug_logger.info(f"Add user: {user_id} {user_name}")

期望行为 | Expected Behavior

# 对外接口不需要增加用户,新建知识库的时候增加用户就可以了
def add_user_(self, user_id, user_name):
    query = "INSERT IGNORE INTO User (user_id, user_name) VALUES (%s, %s)"
    self.execute_query_(query, (user_id, user_name), commit=True)
    debug_logger.info(f"Add user: {user_id} {user_name}")

QAnything日志 | QAnything logs

2024-09-10 02:06:40,249 - [PID: 1211][Sanic-Server-0-0] - [Function: execute_query_] - ERROR - 执行数据库操作失败:Not enough parameters for the SQL statement,SQL:INSERT IGNORE INTO User (user_id, user_name) VALUES (%s, %s, %s)

是否已有关于该错误的issue或讨论? | Is there an existing issue / discussion for this?

  • [X] 我已经搜索过已有的issues和讨论 | I have searched the existing issues / discussions

该问题是否在FAQ中有解答? | Is there an existing answer for this in FAQ?

  • [X] 我已经搜索过FAQ | I have searched FAQ

luckyxue avatar Sep 10 '24 02:09 luckyxue