Commit 75260d8
fix: Fix PostgreSQL migration SQL parsing with dollar-quoted strings
This release fixes critical bugs in the PostgreSQL migration runner that were
causing "unterminated dollar-quoted string" errors when executing migrations
containing PL/pgSQL functions with dollar-quoted string literals.
## Key Fixes
### Enhanced SQL Parsing Logic
- Fixed `split_sql_respecting_quotes` function to properly handle empty dollar tags (`$$...$$`)
- Improved comment filtering to distinguish SQL statements from comment-only blocks
- Enhanced parsing of complex nested structures in dollar-quoted contexts
### Migration 014 Fix
- Resolved "unterminated dollar-quoted string" error in migration 014
- Fixed parsing of PL/pgSQL function definitions with dollar-quoted bodies
- Ensured proper trigger and function creation statements are executed correctly
### Comprehensive Test Coverage
- Added `test_migration_012_sql_parsing` to validate complex transaction parsing
- Added `test_migration_014_sql_parsing` to validate dollar-quoted function parsing
- Added `test_dollar_quoted_string_parsing` for general dollar-quote validation
- Ensured `sqlparser-rs` integration works correctly with PostgreSQL features
## Validation
- All 22 statements in migration 012 now parse correctly
- All 5 statements in migration 014 now parse correctly including PL/pgSQL functions
- Complex SQL features validated: CASE expressions, subqueries, UUID arrays, constraints
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>1 parent 478a3d8 commit 75260d8
File tree
6 files changed
+348
-19
lines changed- hammerwork-web/src/api
- src/migrations
- tests
6 files changed
+348
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
10 | 22 | | |
11 | 23 | | |
12 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
406 | 406 | | |
407 | 407 | | |
408 | 408 | | |
409 | | - | |
410 | | - | |
411 | | - | |
412 | | - | |
413 | | - | |
| 409 | + | |
414 | 410 | | |
415 | 411 | | |
416 | 412 | | |
| |||
481 | 477 | | |
482 | 478 | | |
483 | 479 | | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
| 480 | + | |
488 | 481 | | |
489 | 482 | | |
490 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| |||
0 commit comments