my ($field_create, $field_defs, $trigger_defs, $field_comments) =
create_field($to_field, $options, {});
+ # Fix ORA-01442
+ if ($to_field->is_nullable && !$from_field->is_nullable) {
+ die 'Cannot remove NOT NULL from table field';
+ } elsif (!$from_field->is_nullable && !$to_field->is_nullable) {
+ @$field_defs = map { s/ NOT NULL//; $_} @$field_defs;
+ }
+
my $table_name = $to_field->table->name;
my $table_name_ur = unreserve( $table_name );
use SQL::Translator::Diff;
BEGIN {
- maybe_plan(2, 'SQL::Translator::Parser::YAML',
+ maybe_plan(3, 'SQL::Translator::Parser::YAML',
'SQL::Translator::Producer::Oracle');
}
my $diff = $d->compute_differences->produce_diff_sql || die $d->error;
ok($diff, 'Diff generated.');
-like($diff, '/ALTER TABLE d_operator MODIFY \( name nvarchar2\(10\) NOT NULL \)/',
+like($diff, '/ALTER TABLE d_operator MODIFY \( name nvarchar2\(10\) \)/',
+ 'Alter table generated.');
+like($diff, '/ALTER TABLE d_operator MODIFY \( other nvarchar2\(10\) NOT NULL \)/',
'Alter table generated.');