diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Compute.py b/M02_MasterTemplete/DataFlow/M02_DF_Compute.py index 01f9c20c8..cef97b616 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Compute.py +++ b/M02_MasterTemplete/DataFlow/M02_DF_Compute.py @@ -326,6 +326,11 @@ def _same(a: Any, b: Any) -> bool: return False +def _exact(a: Any, b: Any) -> bool: + """표 찾기 같음 — 글끼리는 대소문자까지(옛 find · Rule lookup FIND) · 그 밖은 엑셀 「=」.""" + return a == b if isinstance(a, str) and isinstance(b, str) else _same(a, b) + + def _compare(a: Any, op: str, b: Any) -> bool: if op in ("=", "≠"): return _same(a, b) == (op == "=") @@ -371,7 +376,7 @@ def _lookup(rule: dict, block: Any, conds: dict) -> tuple[Any, str | None]: col, want = str(c.get("col")), _cond_of(conds, c.get("from") or {}) if col in head: i = head.index(col) - tests.append(lambda row, i=i, want=want: row[i] is None or _same(row[i], want)) + tests.append(lambda row, i=i, want=want: row[i] is None or _exact(row[i], want)) elif col + dv.RANGE_LOW in head and col + dv.RANGE_HIGH in head: lo, hi, x = ( head.index(col + dv.RANGE_LOW), diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Rule.ts b/M02_MasterTemplete/DataFlow/M02_DF_Rule.ts index df684c2d3..d5ee5b516 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Rule.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_Rule.ts @@ -204,7 +204,13 @@ function lookup( const same = at(c.col); const low = at(`${c.col}·아래`); const high = at(`${c.col}·위`); - if (same) tests.push((r) => `OR(ISBLANK(${same}${r}),${same}${r}=${ref})`); + // 글끼리는 대소문자까지 같아야 맞음(옛 find · 「t_2」 ≠ 「T_2」) — FIND 는 대소문자를 가림 + if (same) + tests.push( + (r) => + `OR(ISBLANK(${same}${r}),IF(AND(ISTEXT(${same}${r}),ISTEXT(${ref})),` + + `AND(LEN(${same}${r})=LEN(${ref}),ISNUMBER(FIND(${ref},${same}${r}))),${same}${r}=${ref}))`, + ); else if (low && high) { ups.push(high); tests.push( diff --git a/resources/tester/test_m02_df_model.py b/resources/tester/test_m02_df_model.py index b3dbefa41..ad50754b2 100644 --- a/resources/tester/test_m02_df_model.py +++ b/resources/tester/test_m02_df_model.py @@ -949,3 +949,22 @@ def test_화면_값_물음_조건_찾기_인력기계유가_검색어_틀_다른 designs = {"기계": "0201-0020", "지역": "전국평균"} assert ["*", "기계", None, {"key": "GC000270", "designs": designs}, False] in qs assert server == {"노무비": 123} # 서버가 셈한 다른 로직 출력이 있으면 그것 + + +def test_표_찾기_글은_대소문자까지_같아야() -> None: + from M02_MasterTemplete.DataFlow import M02_DF_Compute as cp + + block = [["구분", "값"], ["T_2", 1], ["t_2", 3], ["e", 0.96], ["E", 0.45]] + rule = { + "kind": "lookup", + "conds": [{"col": "구분", "from": {"box": "v", "name": "g"}}], + "col": "값", + } + gs = ["t_2", "T_2", "E", "e", "x"] + got = _run( + RULE + + f"const block = {json.dumps(block)};\nconst rule = {json.dumps(rule, ensure_ascii=False)};\n" + f"out({json.dumps(gs)}.map(g => {{ const r = R.applyRule(rule, block, {{ g }}); return [r.value, r.why]; }}));" + ) + assert got == [[3, None], [1, None], [0.45, None], [0.96, None], [None, "표에 없는 조건"]] + assert [list(cp._lookup(rule, block, {"g": g})) for g in gs] == got