1 package SQL::Translator::Generator::Role::Quote;
7 SQL::Translator::Generator::Role::Quote - Role for dealing with identifier
12 I<documentation volunteers needed>
16 requires qw(quote_chars name_sep);
22 default => sub { $_[0]->quote_chars->[-1] },
26 my ($self, $label) = @_;
28 return '' unless defined $label;
29 return $$label if ref($label) eq 'SCALAR';
31 my @quote_chars = @{$self->quote_chars};
32 return $label unless scalar @quote_chars;
35 if (@quote_chars == 1) {
36 ($l, $r) = (@quote_chars) x 2;
37 } elsif (@quote_chars == 2) {
38 ($l, $r) = @quote_chars;
40 die 'too many quote chars!';
43 my $sep = $self->name_sep || '';
44 my $esc = $self->escape_char;
46 # parts containing * are naturally unquoted
47 join $sep, map { (my $n = $_) =~ s/\Q$r/$esc$r/g; "$l$n$r" } ( $sep ? split (/\Q$sep\E/, $label ) : $label )
54 See the included AUTHORS file:
55 L<http://search.cpan.org/dist/SQL-Translator/AUTHORS>
59 Copyright (c) 2012 the SQL::Translator L</AUTHORS> as listed above.
63 This code is free software and may be distributed under the same terms as Perl