2 DBIx::Class::SQLMaker::PostgreSQL;
6 use base qw( DBIx::Class::SQLMaker );
10 my %opts = (ref $_[0] eq 'HASH') ? %{$_[0]} : @_;
12 $self->next::method(\%opts);
17 return map { @{ (delete $self->{"${_}_bind"}) || [] } }
18 (qw/select from where with_recursive group having order limit/);
25 my ($cb_sql, @cb_bind) = $self->_with_recursive($rs_attrs);
26 push @{$self->{with_recursive_bind}}, @cb_bind;
28 my $sql = $self->next::method(@_);
30 return "$cb_sql $sql";
34 # -columns => [ ... ],
35 # -nrt => $blargh->search....
36 # -rt => $blargh->search...
39 my ($self, $attrs) = @_;
44 if ( ref($attrs) eq 'HASH' ) {
45 if ( $attrs->{'with_recursive'} ) {
46 my $with_recursive = $attrs->{'with_recursive'};
47 my @fields = @{$with_recursive->{'-columns'}};
48 my $nrt = $with_recursive->{'-nrt'};
49 my $rt = $with_recursive->{'-rt'};
50 my $union = $with_recursive->{'-union_all'};
51 # my ($wr, @wb) = $self->_recurse_where( $attrs->{'with_recursive'} );
52 my ($with_nrt_sql, @with_nrt_bind) = $nrt->as_query;
53 my ($with_rt_sql, @with_rt_bind) = $rt->as_query;
54 push @bind, @with_nrt_bind;
55 push @bind, @with_rt_bind;
56 $sql .= $self->_sqlcase(' with recursive ') . ' temp_wr_query ' . '(' .
57 join(', ', @fields) . ') ' . $self->_sqlcase('as') . ' ( ';
58 $sql .= $with_nrt_sql;
59 $sql .= $self->_sqlcase(' union all ');
67 return wantarray ? ($sql, @bind) : $sql;