We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
当mssql查询语句中带有子查询时,拼接的sql语句会将子查询中的select也增加top限制,导致子查询结果错误
--原始sql select * from table where id in (select id from table2) --生成的sql select top 100 * from table where id in (select top 100 id from table2)
错误代码位置: sql/engines/mssql.py
def filter_sql(self, sql="", limit_num=0): sql_lower = sql.lower() # 对查询sql增加limit限制 if re.match(r"^select", sql_lower): if sql_lower.find(" top ") == -1: if sql_lower.find(" distinct ") > 0: return sql_lower.replace( "distinct", "distinct top {}".format(limit_num) ) return sql_lower.replace("select", "select top {}".format(limit_num)) # 这里替换的时候会连通子查询也进行替换,导致查询结果错误 return sql_lower.replace("select", "select top {}".format(limit_num),1) return sql.strip()
--原始sql select * from table where id in (select id from table2) --生成的sql select top 100 * from table where id in (select id from table2)
No response
v1.9.1
Docker
The text was updated successfully, but these errors were encountered:
No branches or pull requests
重现步骤
当mssql查询语句中带有子查询时,拼接的sql语句会将子查询中的select也增加top限制,导致子查询结果错误
错误代码位置:
sql/engines/mssql.py
预期外的结果
日志文本
No response
版本
v1.9.1
部署方式
Docker
是否还有其他可以辅助定位问题的信息?比如数据库版本等
No response
The text was updated successfully, but these errors were encountered: