Skip to content

Merge develop, fixing state abbreviation uniqueness#30

Merged
midwire merged 5 commits intomasterfrom
develop
Feb 14, 2026
Merged

Merge develop, fixing state abbreviation uniqueness#30
midwire merged 5 commits intomasterfrom
develop

Conversation

@midwire
Copy link
Copy Markdown
Owner

@midwire midwire commented Feb 14, 2026

  • I wrote specs to cover new or modified code in this PR
  • I ran rake spec locally and ALL specs pass

Related Issue: #
Description: <please-add-a-comprehensive-description-of-fix/feature>

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
Fix state_abbr not globally unique across countries
…ve test coverage

- Add warn/verbose logging to eliminate silent data loss cascade:
  country_table, state_table, county_table, and zipcode_table now log
  when rows are skipped due to missing lookups
- Add warn_once helper to DbTable for deduplicated warnings
- Narrow rescue SQLite3::ConstraintException to only swallow UNIQUE
  violations; re-raise NOT NULL, FOREIGN KEY, and CHECK violations
- Extract find_state_where helper to keep get_state_id under method
  length limit
- Add early return for nil/empty country in get_state_id
- Expand synthesize_state comment to document Kiba row-hash mutation
- Add missing tests: zipcode state_id nil guard, state country_id nil
  guard, and cross-country integration tests through full Kiba pipeline
- Silence logger and initialize Options in spec_helper for all tests
Replace references to old rake tasks with the unified
free_zipcode_data executable and update Ruby version to 3.4+.
@midwire midwire merged commit f087b33 into master Feb 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant