[DBIx-Class-Devel] [sql-translator] fix Producer::SQLite::batch_alter_table rename field (#39)

Dagfinn Ilmari Mannsåker notifications at github.com
Wed Aug 20 12:21:32 GMT 2014


> @@ -471,13 +481,62 @@ sub batch_alter_table {
>      %temp_table_fields = map { $_ => 1} $table->get_fields;
>    };
>  
> -  push @sql, "INSERT INTO @{[_generator()->quote($table_name.'_temp_alter')]}( @{[ join(', ', map _generator()->quote($_), grep { $temp_table_fields{$_} } $old_table->get_fields)]}) SELECT @{[ join(', ', map _generator()->quote($_), grep { $temp_table_fields{$_} } $old_table->get_fields)]} FROM @{[_generator()->quote($old_table)]}",
> -             "DROP TABLE @{[_generator()->quote($old_table)]}",
> -             create_table($table, { no_comments => 1 }),
> -             "INSERT INTO @{[_generator()->quote($table_name)]} SELECT @{[ join(', ', map _generator()->quote($_), $table->get_fields)]} FROM @{[_generator()->quote($table_name.'_temp_alter')]}",
> -             "DROP TABLE @{[_generator()->quote($table_name.'_temp_alter')]}";
> -  return @sql;
> -#  return join("", @sql, "");
> +  # record renamed fields for later
> +  my %rename_field;
> +  if ( @{$diffs->{rename_field}} ) {
> +    foreach my $rf_diff ( @{$diffs->{rename_field}} ) {

No need for the if here, the for loop will just execute zero times if the array is empty.

---
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/pull/39/files#r16471950
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20140820/380f7b06/attachment.htm>


More information about the DBIx-Class-Devel mailing list