A1: dong_code 8자리 application layer 검증 강화 (DB 무영향)#197
Merged
Conversation
DB 컬럼 길이 통일 (E1) 은 ALTER COLUMN 다운타임 위험으로 별 PR 보류 — 대신 application layer 입력 검증 강화로 silent inconsistency 차단. 위험: - 행정동 dong_code 컬럼 정의 String(8/10/15/text) 혼재 - 실 데이터는 모두 8자리 (현재 검증됨) - 단 새 ETL/사용자가 10자리 (법정동) 입력 시 일부 컬럼 통과 → silent drift Fix (application layer, DB 무영향): A. services/dong_resolver.py: validate_dong_code(code, strict=True) helper 신설 - 8자리 숫자 검증 (행정동 형식) - strict=True (default): 형식 위반 ValueError - strict=False: None 반환 + warning 로그 (silent skip) - trim 처리 + None/빈 문자 graceful B. schemas/simulation_input.py: - target_district / target_districts 입력 시 dong_code 형식 검증 - 숫자 입력 (dong_code 직접 입력 케이스): 8자리 강제 → 10자리 거부 - 한글 동명 입력: 통과 (dong_resolver 후속 매핑) - list 도 동일 검증 적용 검증: - validate_dong_code: 8자/trim 통과, 10자/non-digit 거부 - SimulationInput: 한글 통과, 8자 통과, 10자 ValidationError 거부 - list 입력 검증 DB 변경: 0 (alembic 마이그레이션 없음, ALTER COLUMN 0) 별 PR 권장 (보류): - E1 dong_code String(8) DB 컬럼 통일 — 다운타임 + 팀 합의 필요 (대신 application 측 검증으로 미래 silent drift 1단계 차단) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
DB 컬럼 길이 통일 (E1) 은 다운타임 + 팀 합의 필요로 별 PR 보류. 대신 application layer 검증 강화로 silent drift 1단계 차단.
배경
행정동 dong_code 컬럼 정의:
String(8/10/15/text)혼재 (28개 테이블 — DB 실측). 실 데이터는 모두 8자리. 단 새 ETL/사용자가 10자리 (법정동) 입력 시 일부 컬럼 통과 → silent drift.Fix
A.
services/dong_resolver.py—validate_dong_code()helperB.
schemas/simulation_input.py— Pydantic validatortarget_district/target_districts입력 시:검증
validate("11440660")validate(" 11440660 ")validate("1144066000")(10자)validate("abc")validate("1144066000", strict=False)SimulationInput target_district='서교동'target_district='11440660'target_district='1144066000'target_districts=['서교동','11440690','망원동']target_districts=['1144066000']DB 변경
없음. alembic 마이그레이션 0, ALTER COLUMN 0.
보류 (별 PR)
IM3-dong-code-string-unify거리.🤖 Generated with Claude Code