Commit 144d985
Refactor: Address high-priority code quality issues in charset validation
**Code Quality Improvements:**
- **FIXED DRY Violation**: Extracted duplicated invalid byte detection logic
to reusable `formatInvalidByteForError()` helper function (22 lines → 1 function)
- **ELIMINATED Circular Dependency**: Replaced string parsing in insert.go with
structured `GetCharsetErrorInvalidByte()` approach
- **ADDED Constants**: Replaced magic numbers with named constants
- 127 → `asciiMax`
- "\\x%02X" → `invalidByteFormat`
- "\\x00" → `fallbackInvalidByte`
**MySQL Compatibility Verified:**
- ✅ MySQL: `ERROR 1366: Incorrect string value: '\xAE' for column 'name' at row 1`
- ✅ Dolt: `error: Incorrect string value: '\xAE' for column 'name' at row 1`
- ✅ **PERFECT MATCH** (excluding error code per CLAUDE.md requirements)
**Testing:**
- All existing charset validation tests pass
- Behavior identical to MySQL comparison server
- No functional changes, only code structure improvements
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent 7d60064 commit 144d985
2 files changed
+48
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
158 | 155 | | |
159 | 156 | | |
160 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
45 | 51 | | |
46 | 52 | | |
47 | 53 | | |
| |||
484 | 490 | | |
485 | 491 | | |
486 | 492 | | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 493 | + | |
| 494 | + | |
499 | 495 | | |
500 | 496 | | |
501 | 497 | | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 498 | + | |
| 499 | + | |
514 | 500 | | |
515 | 501 | | |
516 | 502 | | |
517 | 503 | | |
518 | 504 | | |
519 | 505 | | |
520 | 506 | | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
521 | 541 | | |
522 | 542 | | |
523 | 543 | | |
| |||
0 commit comments