1 package # hide from pause
2 SQL::Translator::Generator::Role::Quote;
6 requires qw(quote_chars name_sep);
9 my ($self, $label) = @_;
11 return '' unless defined $label;
12 return $$label if ref($label) eq 'SCALAR';
14 my @quote_chars = @{$self->quote_chars};
15 return $label unless scalar @quote_chars;
18 if (@quote_chars == 1) {
19 ($l, $r) = (@quote_chars) x 2;
20 } elsif (@quote_chars == 2) {
21 ($l, $r) = @quote_chars;
23 die 'too many quote chars!';
26 my $sep = $self->name_sep || '';
27 # parts containing * are naturally unquoted
28 join $sep, map "$l$_$r", ( $sep ? split (/\Q$sep\E/, $label ) : $label )