cowork-bot: automated improvements (cowork/improve-json2sql-20260808) - #38
cowork-bot: automated improvements (cowork/improve-json2sql-20260808)#38github-actions[bot] wants to merge 1 commit into
Conversation
…ad of hardcoding TEXT
Coding-Dev-Tools
left a comment
There was a problem hiding this comment.
Pre-PR Code Review: REQUEST_CHANGES
Reviewer: Pre-PR Code Analyzer
Date: 2026-08-08
Verdict: REQUEST_CHANGES
Summary
This PR improves generate_schema to infer primitive column types (INTEGER, DOUBLE, etc.) instead of hardcoding TEXT for primitive arrays. The change is well-tested with 3 new regression tests covering int/float/bool arrays across PostgreSQL, MySQL, and SQLite dialects.
Positive Findings
- Type inference for primitive arrays is a genuine improvement
- Tests cover all three SQL dialects with appropriate expected types
- The formatting cleanup (removing unnecessary line wraps) improves readability
- CI passes (ensure-pr workflow green)
Concerns
1. Edge case: mixed-type primitive arrays
The inference uses sql_type_for(data[0], ...) — it only looks at the first element. If the array is [1, "hello", 3], the schema would declare INTEGER but the second value would fail to insert. Consider:
- Sampling more elements (first N or all)
- Falling back to TEXT if types are heterogeneous
- Documenting this limitation
2. Empty array handling
col_type = sql_type_for(data[0], ...) if isinstance(data, list) and data else "TEXT" — the else "TEXT" covers empty arrays correctly, but the conditional is dense. A comment would help.
3. Age/contributor gate
This PR is less than 6 hours old and has only 1 commit from 1 contributor. Per the review policy, PRs need either 6+ hours of age or 3+ distinct contributors before approval. This will be re-evaluated on the next rotation.
Required Changes
- Consider adding a test for mixed-type primitive arrays (or document the single-element inference behavior)
- Wait for the 6-hour age gate or additional review passes before merge
Automated improvement PR from the Cowork repo-improver rotation (one coherent senior-dev improvement per run; see individual commit messages). Subsequent runs push additional commits to this PR rather than opening new ones.