Fix state_abbr not globally unique across countries#29
Merged
Conversation
Scope state lookups by country in get_state_id using a 3-step fallback (exact match, abbr+country, name+country). Add stateless country fallback in StateTable for countries without state subdivisions. Update state_name index to include country_id for multi-country uniqueness. Fixes #18
- Fix COLLATE NOCASE placement on both indexes (apply to abbr/name columns, not country_id) - Add nil guard for country_id in StateTable#write - Add nil guard for state_id in ZipcodeTable#write - Strengthen fallback tests to verify correct state ID returned - Add test for nil country input to get_state_id - Add test verifying row mutation for downstream Kiba destinations
2 tasks
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
get_state_idlookups by country using a 3-step fallback chain (exact match → abbr+country → name+country) to resolve incorrect state associations in multi-country modeStateTable#writefor countries without state subdivisions (synthesizes state from country lookup table)state_nameunique index to includecountry_id, allowing same-named states in different countries to coexistCountyTable,ZipcodeTable) and tests to passcountrytoget_state_idTest plan
get_state_idfallback chain (exact, abbr-only, name-only, country scoping, nil return)Fixes #18
Supersedes #19