with 'Data::Query::Renderer::SQL::Slice::LimitXY';
+has needs_inner_join => (is => 'ro', default => sub { 0 });
+
+around _format_join_keyword => sub {
+ my ($orig, $self) = (shift, shift);
+ my ($dq) = @_;
+ if ($self->needs_inner_join and $dq->{on} and !$dq->{outer}) {
+ return $self->_format_keyword('INNER JOIN');
+ }
+ return $self->$orig(@_);
+};
+
sub _insert_default_values {
my ($self) = @_;
$self->_format_keyword('VALUES'), qw( ( ) );
sub _render_join {
my ($self, $dq) = @_;
my ($left, $right) = @{$dq}{qw(left right)};
- my $join = do {
- if ($dq->{outer}) {
- $self->_format_keyword(uc($dq->{outer}).' JOIN');
- } elsif ($dq->{on}) {
- $self->_format_keyword('JOIN');
- } else {
- ','
- }
- };
my $rhs = $self->_render($right);
[
- $self->_render($left), $join,
+ $self->_render($left), $self->_format_join_keyword($dq),
(is_Join($right) ? ('(', $rhs, ')') : $rhs),
($dq->{on}
? ($self->_format_keyword('ON'), $self->_render($dq->{on}))
];
}
+sub _format_join_keyword {
+ my ($self, $dq) = @_;
+ if ($dq->{outer}) {
+ $self->_format_keyword(uc($dq->{outer}).' JOIN');
+ } elsif ($dq->{on}) {
+ $self->_format_keyword('JOIN');
+ } else {
+ ','
+ }
+}
+
sub _render_where {
my ($self, $dq) = @_;
my ($from, $where) = @{$dq}{qw(from where)};