Skip to content
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

Oracle producer add missing functions #143

Merged
merged 19 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
ca601db
Added support for CURRENT_TIMESTAMP as a default value when parsing O…
hazardv Aug 10, 2022
0d8ce8f
Added tests to verify changes to oracle parser.
hazardv Aug 10, 2022
dbd1da1
Split the creation of contraints out from the creation of the table a…
hazardv Aug 18, 2022
929ae33
Missing a few small things
hazardv Aug 18, 2022
ed59a4d
Added drop_field to Oracle.pm and added alter constraint testing.
hazardv Aug 19, 2022
cdb544f
Added drop_table functionality along with related tests.
hazardv Aug 22, 2022
22a15de
Make sure the sqlt_args actually get passed in to the SQL::Translator…
hazardv Aug 24, 2022
ab42ef8
Removed batch alter stuff from Oracle.pm. It was just complicating th…
hazardv Aug 24, 2022
df7e62f
All quoting is working consistent to how it works for MySQL and SQLSe…
hazardv Aug 25, 2022
c90a599
Fixed issue with drop FK constraint syntax
hazardv Sep 7, 2022
b371f16
Fixed restriction stopping change of NOT NULL to NULL for non CLOB fi…
hazardv Sep 8, 2022
b14da74
Removed commented out section of code.
hazardv Sep 9, 2022
d2d080c
fixed issue with alter_drop_constraint when dropping unnamed primary …
hazardv Sep 26, 2022
2d47b5c
Reverted change to passing of $options and fixed test plan.
hazardv Sep 29, 2022
b4a8ca7
Added debug statements to figure out constraint order issue
hazardv Oct 5, 2022
a32992d
Separated FK_defs out so things would play nice and modified 51-xml-t…
hazardv Oct 5, 2022
090b5b4
Corrected quoting on index fields, updated 51-xml-to-oracle_quoted.t …
hazardv Oct 5, 2022
74c0312
Corrected changes previously made to 55-oracle-producer.t in error.
hazardv Oct 5, 2022
2a66d69
Removed some unnecessary debug comments.
hazardv Oct 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/SQL/Translator/Producer/Oracle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,13 @@ sub alter_field {
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';
if (!$from_field->is_nullable && $to_field->is_nullable) {
if ($from_field->data_type =~ /text/) {
die 'Cannot alter CLOB field in this way';
}
else {
@$field_defs = map { $_ .= ' NULL' } @$field_defs;
}
} elsif (!$from_field->is_nullable && !$to_field->is_nullable) {
@$field_defs = map { s/ NOT NULL//; $_} @$field_defs;
}
Expand Down
2 changes: 1 addition & 1 deletion t/54-oracle-alter-constraint.t
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ like($diff, '/DROP CONSTRAINT other_check/', 'DROP constraint other_check genera

like($diff, '/ADD CONSTRAINT other_check CHECK \(other BETWEEN 100 and 99999\)/', 'ADD check constraint generated');

like($diff, '/ALTER TABLE supplier CONSTRAINT fk_customer/', 'DROP Foreign key constraint generated');
like($diff, '/ALTER TABLE supplier DROP CONSTRAINT fk_customer/', 'DROP Foreign key constraint generated');

like($diff, '/DROP TABLE customer/', 'DROP TABLE customer generated');
2 changes: 1 addition & 1 deletion t/54-oracle-alter-field.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ my $d = SQL::Translator::Diff->new
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\) \)/',
like($diff, '/ALTER TABLE d_operator MODIFY \( name nvarchar2\(10\) NULL \)/',
'Alter table generated.');
like($diff, '/ALTER TABLE d_operator MODIFY \( other nvarchar2\(10\) NOT NULL \)/',
'Alter table generated.');
4 changes: 2 additions & 2 deletions t/54-oracle-sql-diff.t
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ like($diff, '/CREATE TABLE t_group/', 'CREATE TABLE t_group generated');

like($diff, '/ALTER TABLE t_category DROP CONSTRAINT t_category_display_name/', 'DROP constraint t_category_display_name generated');

like($diff, '/ALTER TABLE t_user_groups DROP FOREIGN KEY t_user_groups_group_id_fk/', 'DROP FOREIGN KEY constraint generated');
like($diff, '/ALTER TABLE t_user_groups DROP CONSTRAINT t_user_groups_group_id_fk/', 'DROP FOREIGN KEY constraint generated');

like($diff, '/DROP INDEX t_alert_roles_idx_alert_id/', 'DROP INDEX generated');

Expand All @@ -60,6 +60,6 @@ like($diff, '/CREATE INDEX t_user_groups_idx_user_id ON t_user_groups \(user_id\

like($diff, '/ALTER TABLE t_user_groups ADD CONSTRAINT t_user_groups_group_id_fk FOREIGN KEY \(group_id\) REFERENCES t_group \(group_id\) ON DELETE CASCADE/', 'ADD FOREIGN KEY constraint generated');

like($diff, '/ALTER TABLE t_population_group DROP FOREIGN KEY t_population_group_group_role_fk/', 'DROP FOREIGN KEY before drop table generated');
like($diff, '/ALTER TABLE t_population_group DROP CONSTRAINT t_population_group_group_role_fk/', 'DROP FOREIGN KEY before drop table generated');

like($diff, '/DROP TABLE t_population_group/', 'DROP TABLE generated');
2 changes: 1 addition & 1 deletion t/data/oracle/schema_diff_b.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ schema:
data_type: nvarchar2
default_value: ~
extra: {}
is_nullable: 0
is_nullable: 1
is_primary_key: 0
is_unique: 0
name: name
Expand Down