1 package # hide from pause
2 SQL::Translator::ProducerUtils;
5 use Sub::Quote 'quote_sub';
7 # this should be ro, but I have to modify it in BUILD so bleh
8 has quote_chars => ( is => 'rw' );
12 default => quote_sub q{ '.' },
18 unless (ref($self->quote_chars)) {
19 if ($self->quote_chars) {
20 $self->quote_chars([$self->quote_chars])
22 $self->quote_chars([])
30 my ($self, $label) = @_;
32 return '' unless defined $label;
33 return $$label if ref($label) eq 'SCALAR';
35 my @quote_chars = @{$self->quote_chars};
36 return $label unless scalar @quote_chars;
39 if (@quote_chars == 1) {
40 ($l, $r) = (@quote_chars) x 2;
41 } elsif (@quote_chars == 2) {
42 ($l, $r) = @quote_chars;
44 die 'too many quote chars!';
47 my $sep = $self->name_sep || '';
48 # parts containing * are naturally unquoted
49 join $sep, map "$l$_$r", ( $sep ? split (/\Q$sep\E/, $label ) : $label )