Commit 03ebf69
committed
fix: use old column names in SELECT during SQLite table recreate on column rename
When a column rename coincides with a table recreation (e.g., renaming
a column while also changing its type or default), the INSERT INTO...SELECT
statement incorrectly uses the new column name in the SELECT clause.
The old table still has the old column name, causing the migration to fail.
This fix tracks column renames separately in the statement combiner and
injects them into the recreate_table statement. The SQL generator then
uses old column names in the SELECT and new column names in the INSERT.1 parent 273c780 commit 03ebf69
4 files changed
Lines changed: 71 additions & 4 deletions
File tree
- drizzle-kit
- src
- tests/statements-combiner
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| 75 | + | |
75 | 76 | | |
76 | 77 | | |
77 | 78 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3769 | 3769 | | |
3770 | 3770 | | |
3771 | 3771 | | |
3772 | | - | |
| 3772 | + | |
3773 | 3773 | | |
3774 | 3774 | | |
3775 | 3775 | | |
3776 | 3776 | | |
| 3777 | + | |
| 3778 | + | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
| 3783 | + | |
| 3784 | + | |
| 3785 | + | |
| 3786 | + | |
| 3787 | + | |
| 3788 | + | |
3777 | 3789 | | |
3778 | 3790 | | |
3779 | 3791 | | |
| |||
3798 | 3810 | | |
3799 | 3811 | | |
3800 | 3812 | | |
3801 | | - | |
| 3813 | + | |
3802 | 3814 | | |
3803 | 3815 | | |
3804 | 3816 | | |
| |||
3836 | 3848 | | |
3837 | 3849 | | |
3838 | 3850 | | |
3839 | | - | |
| 3851 | + | |
3840 | 3852 | | |
3841 | 3853 | | |
3842 | 3854 | | |
3843 | 3855 | | |
| 3856 | + | |
| 3857 | + | |
| 3858 | + | |
| 3859 | + | |
| 3860 | + | |
| 3861 | + | |
| 3862 | + | |
| 3863 | + | |
| 3864 | + | |
| 3865 | + | |
| 3866 | + | |
| 3867 | + | |
3844 | 3868 | | |
3845 | 3869 | | |
3846 | 3870 | | |
| |||
3864 | 3888 | | |
3865 | 3889 | | |
3866 | 3890 | | |
3867 | | - | |
| 3891 | + | |
3868 | 3892 | | |
3869 | 3893 | | |
3870 | 3894 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
80 | 81 | | |
81 | 82 | | |
82 | 83 | | |
| 84 | + | |
| 85 | + | |
83 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
84 | 95 | | |
85 | 96 | | |
86 | 97 | | |
| |||
293 | 304 | | |
294 | 305 | | |
295 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
296 | 317 | | |
297 | 318 | | |
298 | 319 | | |
| |||
309 | 330 | | |
310 | 331 | | |
311 | 332 | | |
| 333 | + | |
| 334 | + | |
312 | 335 | | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
313 | 344 | | |
314 | 345 | | |
315 | 346 | | |
| |||
436 | 467 | | |
437 | 468 | | |
438 | 469 | | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
439 | 480 | | |
440 | 481 | | |
441 | 482 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
140 | 141 | | |
141 | 142 | | |
142 | 143 | | |
| |||
0 commit comments