From 31e9f6c5e9ab925ad6f99c64b9c13ed3cc2f2331 Mon Sep 17 00:00:00 2001 From: Mahesh-newt Date: Thu, 12 Jun 2025 15:38:59 +0530 Subject: [PATCH] Handling Case Sensitive in View --- lib/Ora2Pg.pm | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/lib/Ora2Pg.pm b/lib/Ora2Pg.pm index fc8b7c67..f9f5de01 100644 --- a/lib/Ora2Pg.pm +++ b/lib/Ora2Pg.pm @@ -3807,7 +3807,8 @@ sub read_view_from_file $self->{views}{$v_name}{text} = $v_def; $self->{views}{$v_name}{iter} = $tid; # Remove constraint - while ($v_alias =~ s/(,[^,\(]+\(.*)$//) {}; + # while ($v_alias =~ s/(,[^,\(]+\(.*)$//) {}; + while ($v_alias =~ s/(,[^,"\(]+\(.*\))$//) {}; my @aliases = split(/\s*,\s*/, $v_alias); foreach (@aliases) { @@ -5126,6 +5127,22 @@ sub export_view $sql_output .= "CREATE$self->{create_or_replace} VIEW $tmpv ("; my $count = 0; my %col_to_replace = (); + # need to write the condition if views alias as mentioned within "" + if (exists $self->{views}{$view}{alias}) { + my $alias_ref = $self->{views}{$view}{alias}; + + if (ref($alias_ref) eq 'ARRAY') { + my @flattened_alias; + + foreach my $sub_array (@$alias_ref) { + if (ref($sub_array) eq 'ARRAY') { + push @flattened_alias, join(" ", @$sub_array); + } + } + $self->{views}{$view}{alias} = [ map { [$_] } @flattened_alias ]; + + } + } foreach my $d (@{$self->{views}{$view}{alias}}) { if ($count == 0) { @@ -5152,7 +5169,16 @@ sub export_view $cost_value += $cost; $sql_output .= "\n-- Estimed cost of view [ $view ]: " . sprintf("%2.2f", $cost); } - $sql_output .= "\n"; + # $sql_output .= "\n"; + # writing if condition that the fname is like "abc.def" --> handling these kind of strings + if ($fname =~ /"[^"]*?(?:\.\s|\.|)[^"]*?"/) + { + $sql_output .= $fname; + } + else + { + $sql_output .= $self->quote_object_name($fname); + } } if ($self->{force_owner})