-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix Producer::SQLite::batch_alter_table rename field #39
fix Producer::SQLite::batch_alter_table rename field #39
Conversation
Further testing with my new DBIC distro ::Versioned::Inline has proved that this is a real bug so reopening. Will hopefully have time in the next few days to add some useful test to prove this. |
Further explanation on the issue: SQLT::Diff works fine for SQLite with column renames as long as there are no rows in the table and produces perfectly good SQL for creating the replacement table. The problem is that the code for moving the data from old to new table is completely broken. That is what this patch set tries to fix. |
Could you write a test that fails before the patch and passes after? That would help. |
I've rehacked this into a single commit + supplied test that fails against master. |
55e4835
to
05c9b80
Compare
I've removed some unnecessary changes from the diff which makes it much cleaner and rebased against master. I'm using this updated batch_alter_table method botched into DBIx::Class::Schema::Versioned::Inline to fixup SQLite upgrade problems which adds quite a few more tests in addition to the SQLT ones and all is well there. |
Will look at this later today I hope to see if we can get it merged. -frew |
# record renamed fields for later | ||
my %rename_field; | ||
if ( @{$diffs->{rename_field}} ) { | ||
foreach my $rf_diff ( @{$diffs->{rename_field}} ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the if here, the for loop will just execute zero times if the array is empty.
05c9b80
to
768f5d9
Compare
Unnecessary ifs removed and loops replaced with map and delete hash slice. |
768f5d9
to
0ce3181
Compare
ilmari> SysPete: I just noticed, you're quoting $temp_table_name twice |
rename_field is ignored by Producer::SQLite and the existing tests have:
SELECT ... physical_description FROM person"
which should be:
SELECT ... description FROM person"
Patches address this and try to make some of the code (mostly inside batch_alter_table) more readable.