fix: 查询模板占位符替换 + _auto_add_limit 跳过非SELECT语句 + 默认用户密码修正
修复:
- getTemplateSQL() 支持 {table}/{db}/{collection} 占位符自动替换
- _auto_add_limit() 仅对 SELECT 语句添加 LIMIT, SHOW/DESC/EXPLAIN 跳过
- seed_data 默认用户密码从 '***' 改为 'admin123'
- DB 中已有用户密码已重置为 admin123
测试: 75 passed (新增2个 SHOW/DESC LIMIT 测试)
This commit is contained in:
1 parent
0fb947dcb5
commit
0aa4595c90
4 files changed
+35
-9
No files matched your search
@@ -80,6 +80,19 @@ class TestMySQLQueryHandler:
|
||||
assert "10000" not in result
|
||||
assert "LIMIT 5" in result.upper()
|
||||
|
||||
def test_auto_add_limit_show_no_limit(self):
|
||||
"""SHOW 语句不应添加 LIMIT。"""
|
||||
sql = "SHOW CREATE TABLE users"
|
||||
result = self.handler._auto_add_limit(sql)
|
||||
assert "LIMIT" not in result.upper()
|
||||
assert result == sql
|
||||
|
||||
def test_auto_add_limit_desc_no_limit(self):
|
||||
"""DESC 语句不应添加 LIMIT。"""
|
||||
sql = "DESC users"
|
||||
result = self.handler._auto_add_limit(sql)
|
||||
assert "LIMIT" not in result.upper()
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_execute_non_readonly_raises(self):
|
||||
"""非只读查询应抛出 ValueError。"""
|
||||
|
||||
Reference in new issue
Block a user