修复匹配时候忽视了word_type的约束

This commit is contained in:
LambdaYH 2022-08-21 23:47:21 +08:00
parent 016a7e87ea
commit 31d4d29f3e

View File

@ -234,10 +234,10 @@ class WordBank(db.Model):
query = query.where(cls.word_scope == word_type) query = query.where(cls.word_scope == word_type)
sql_text += f" and word_scope = {word_scope}" sql_text += f" and word_scope = {word_scope}"
# 完全匹配 # 完全匹配
if await query.where(cls.problem == problem).gino.first(): if await query.where(((cls.word_type == 0) | (cls.word_type == 3)) & (cls.problem == problem)).gino.first():
return query.where(cls.problem == problem) return query.where(cls.problem == problem)
# 模糊匹配 # 模糊匹配
if await query.where(cls.problem.contains(problem)).gino.first(): if await query.where((cls.word_type == 1) & (cls.problem.contains(problem))).gino.first():
return query.where(cls.problem.contains(problem)) return query.where(cls.problem.contains(problem))
# 正则匹配 # 正则匹配
if await db.first( if await db.first(