fix: 修復 Excel 批次查詢的表名驗證支援 schema.table 格式

原本的正則表達式不支援帶 schema 前綴的表名(如 DWH.DW_MES_LOTMATERIALSHISTORY),
導致查詢失敗並顯示「無效的資料表名稱」錯誤。

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
beabigegg
2026-02-02 20:29:02 +08:00
parent bd3591703b
commit c3899c4593

View File

@@ -9,9 +9,9 @@ import re
from datetime import datetime from datetime import datetime
from typing import Any, Dict, List, Tuple from typing import Any, Dict, List, Tuple
import pandas as pd import pandas as pd
from mes_dashboard.core.database import get_db_connection from mes_dashboard.core.database import get_db_connection
# Oracle IN clause limit # Oracle IN clause limit
@@ -77,8 +77,8 @@ def sanitize_column_name(name: str) -> str:
def validate_table_name(table_name: str) -> bool: def validate_table_name(table_name: str) -> bool:
"""Validate table name format.""" """Validate table name format (supports schema.table format)."""
return bool(re.match(r'^[A-Za-z_][A-Za-z0-9_]*$', table_name)) return bool(re.match(r'^[A-Za-z_][A-Za-z0-9_]*(\.[A-Za-z_][A-Za-z0-9_]*)?$', table_name))
def execute_batch_query( def execute_batch_query(