1 package # hide from pause
2 SQL::Translator::Generator::Role::Quote;
4 # AUTHOR: Arthur Axel fREW Schmidt
5 # Copyright: Same as Perl 5
9 requires qw(quote_chars name_sep);
12 my ($self, $label) = @_;
14 return '' unless defined $label;
15 return $$label if ref($label) eq 'SCALAR';
17 my @quote_chars = @{$self->quote_chars};
18 return $label unless scalar @quote_chars;
21 if (@quote_chars == 1) {
22 ($l, $r) = (@quote_chars) x 2;
23 } elsif (@quote_chars == 2) {
24 ($l, $r) = @quote_chars;
26 die 'too many quote chars!';
29 my $sep = $self->name_sep || '';
30 # parts containing * are naturally unquoted
31 join $sep, map "$l$_$r", ( $sep ? split (/\Q$sep\E/, $label ) : $label )