1 package # Hide from PAUSE
2 DBIx::Class::SQLMaker::OracleJoins;
7 use base qw( DBIx::Class::SQLMaker::Oracle );
10 my ($self, $table, $fields, $where, $rs_attrs, @rest) = @_;
12 # pull out all join conds as regular WHEREs from all extra tables
13 if (ref($table) eq 'ARRAY') {
14 $where = $self->_oracle_joins($where, @{ $table }[ 1 .. $#$table ]);
17 return $self->next::method($table, $fields, $where, $rs_attrs, @rest);
21 my ($self, $from, @join) = @_;
23 my @sqlf = $self->_from_chunk_to_sql($from);
28 if (ref $to eq 'ARRAY') {
29 push (@sqlf, $self->_recurse_from(@{ $to }));
32 push (@sqlf, $self->_from_chunk_to_sql($to));
36 return join q{, }, @sqlf;
40 my ($self, $where, @join) = @_;
41 my $join_where = $self->_recurse_oracle_joins(@join);
43 if (keys %$join_where) {
44 if (!defined($where)) {
47 if (ref($where) eq 'ARRAY') {
48 $where = { -or => $where };
50 $where = { -and => [ $join_where, $where ] };
56 sub _recurse_oracle_joins {
61 my ($to, $on) = @{ $j };
63 push @where, $self->_recurse_oracle_joins(@{ $to })
64 if (ref $to eq 'ARRAY');
66 my $join_opts = ref $to eq 'ARRAY' ? $to->[0] : $to;
70 if (ref $join_opts eq 'HASH' and my $jt = $join_opts->{-join_type}) {
71 #TODO: Support full outer joins -- this would happen much earlier in
72 #the sequence since oracle 8's full outer join syntax is best
74 $self->throw_exception("Can't handle full outer joins in Oracle 8 yet!\n")
77 $left_join = q{(+)} if $jt =~ /left/i
80 $right_join = q{(+)} if $jt =~ /right/i
84 # sadly SQLA treats where($scalar) as literal, so we need to jump some hoops
85 push @where, map { \sprintf ('%s%s = %s%s',
86 ref $_ ? $self->_recurse_where($_) : $self->_quote($_),
88 ref $on->{$_} ? $self->_recurse_where($on->{$_}) : $self->_quote($on->{$_}),
93 return { -and => \@where };
102 DBIx::Class::SQLMaker::OracleJoins - Pre-ANSI Joins-via-Where-Clause Syntax
106 This module is used with Oracle < 9.0 due to lack of support for standard
111 Not intended for use directly; used as the sql_maker_class for schemas and components.
115 Implements pre-ANSI joins specified in the where clause. Instead of:
117 SELECT x FROM y JOIN z ON y.id = z.id
121 SELECT x FROM y, z WHERE y.id = z.id
123 It should properly support left joins, and right joins. Full outer joins are
124 not possible due to the fact that Oracle requires the entire query be written
125 to union the results of a left and right join, and by the time this module is
126 called to create the where query and table definition part of the sql query,
127 it's already too late.
135 Overrides DBIx::Class::SQLMaker's select() method, which calls _oracle_joins()
136 to modify the column and table list before calling next::method().
142 Does not support full outer joins (however neither really does DBIC itself)
148 =item L<DBIx::Class::Storage::DBI::Oracle::WhereJoins> - Storage class using this
150 =item L<DBIx::Class::SQLMaker> - Parent module
152 =item L<DBIx::Class> - Duh
158 Justin Wheeler C<< <jwheeler@datademons.com> >>
162 David Jack Olrik C<< <djo@cpan.org> >>
166 This module is licensed under the same terms as Perl itself.