has always_quote => (is => 'ro', default => sub { 0 });
+has collapse_aliases => (is => 'ro', default => sub { 1 });
+
sub _default_simple_ops {
+{
(map +($_ => 'binop'), qw(= > < >= <= != LIKE), 'NOT LIKE' ),
my ($self, $dq, $as) = @_;
# FROM foo foo -> FROM foo
# FROM foo.bar bar -> FROM foo.bar
- if ($dq->{alias}{type} eq DQ_IDENTIFIER) {
- if ($dq->{alias}{elements}[-1] eq $dq->{as}) {
- return $self->_render($dq->{alias});
+ if ($self->collapse_aliases) {
+ if ($dq->{from}{type} eq DQ_IDENTIFIER) {
+ if ($dq->{from}{elements}[-1] eq $dq->{to}) {
+ return $self->_render($dq->{from});
+ }
}
}
return [
- $self->_render($dq->{alias}),
+ $self->_render($dq->{from}),
$as || ' ',
- $self->_render_identifier({ elements => [ $dq->{as} ] })
+ $self->_render_identifier({ elements => [ $dq->{to} ] })
];
}
sub _render_join {
my ($self, $dq) = @_;
- my ($left, $right) = @{$dq->{join}};
+ my ($left, $right) = @{$dq}{qw(left right)};
my $join = do {
if ($dq->{outer}) {
$self->_format_keyword(uc($dq->{outer}).' JOIN');