fix(seed): coerce every *_date field, not just release_date - #49
Merged
Conversation
_load_dir turned "release_date" strings into date objects by name, so a category whose date column is named differently reached SQLite as a str: seeding data/website failed with TypeError: SQLite Date type only accepts Python date objects as input on website.launch_date. Coercion now keys on the _date suffix. The endpoint tests for each category insert fixtures through the model with real date objects, so none of them covered the JSON -> DB path where this happens; test_seed_date_coercion.py now does. Verified by seeding the 40,084-record data/website tree: 40,084 rows inserted.
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.
Bug
_load_dirconverted ISO date strings by field name:So a category whose date column is named anything else reached SQLite as a
str. Seeding the newdata/websitetree (#48) died on the first insert:Coercion now keys on the
_datesuffix, solaunch_date— and any future category's date column — works without another special case.Why the existing tests missed it
Every category's endpoint tests insert their fixture through the model, passing a real
dateobject:That never exercises the JSON → DB path where this conversion happens, which is why #48 passed CI with the bug in it.
tests/unit/test_seed_date_coercion.pycovers that path now: a*_datefield is converted, a non-date field is left alone, and a missing directory stays empty.Verification
pytest tests/unit/test_seed_date_coercion.py→ 3 passeddata/websitetree end to end:SEED OK: {'websites': 40084}(it failed on record 1 before)ruff check app tests✅ ·mypy app✅Follow-up to #48; the TechAPI data PR is blocked on this.