fix: preserve char(n) space padding in snapshot/subset queries#4044
fix: preserve char(n) space padding in snapshot/subset queries#4044magnetised merged 11 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
In PostgreSQL, casting bpchar (char(n)) to text strips trailing spaces. This caused inconsistency between data from PG replication (correctly space-padded) and data from snapshot/subset SQL queries (incorrectly trimmed). The fix uses pg_typeof() at runtime to detect bpchar columns and uses concat() instead of ::text to preserve the padding. concat() converts its argument to text without trimming trailing spaces. Fixes #4039 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add second row with NULL char(n) column to verify NULL handling - Add blank line between function definitions for consistency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Code ReviewSummaryThe PR is nearly ready. The Important issue from previous reviews ( What's Working Well
Issues FoundImportant (Should Fix)None remaining. Suggestions (Nice to Have)1. The files are gone from this branch, but 2.
3. The open-questions file acknowledged this limitation. No tracking issue has been filed. Low priority, but worth filing before the PR merges so it isn't forgotten. Issue ConformanceNo change from previous reviews. Implementation directly addresses the Previous Review Status
Review iteration: 3 | 2026-03-27 |
|
test |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4044 +/- ##
==========================================
+ Coverage 85.78% 88.67% +2.88%
==========================================
Files 51 25 -26
Lines 3399 2438 -961
Branches 611 612 +1
==========================================
- Hits 2916 2162 -754
+ Misses 481 274 -207
Partials 2 2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Claude Code ReviewSummaryThis PR fixes a real inconsistency bug: What's Working Well
Issues FoundImportant (Should Fix)1. Files: The PR includes 5 agent working files (planning notes, progress logs, self-review) as tracked repository files. These are ephemeral task artifacts — they don't belong in git history and Suggested fix: Either add 2. Missing blank line between File: The closing Suggestions (Nice to Have)3. A The open-questions file acknowledges this but there's no linked follow-up issue. Given 4. Test: The new test only exercises 5. Test: bare
Issue ConformanceThe linked issue (#4039) clearly describes the bug with reproduction steps and actual vs. expected behavior. The implementation directly addresses the Note: the issue also mentions booleans being represented as Previous Review StatusNo previous Claude review exists for this PR. Review iteration: 1 | 2026-03-23 |
Verify that char(n) space padding is preserved when rows are returned via the query_move_in code path with char(n) join columns. Addresses review note 4 from review-round-1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Verify that char(n) space padding is preserved in both values and keys when the table has no explicit PK constraint and all columns (including char(n)) are treated as primary keys. Also includes a NULL char(n) value in the pk-less table to verify NULL handling in the join_primary_keys path. Addresses review note 6 from review-round-1. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary
char(n)(bpchar) column values being trimmed of trailing spaces in snapshot and subset queries::textcast inpg_cast_column_to_text/1was stripping space padding fromchar(n)columns, causing inconsistency with values from PG replication which correctly preserve paddingpg_typeof()at runtime to detect bpchar columns andconcat()to preserve padding without trimmingTest plan
CHAR(8)PK andCHAR(10)column verifying space padding is preservedchar(n)column to verify NULL handling is correctFixes #4039
🤖 Generated with Claude Code