1 package DBIx::Class::SQLMaker::OracleJoins;
6 use base qw( DBIx::Class::SQLMaker::Oracle );
9 my ($self, $table, $fields, $where, $rs_attrs, @rest) = @_;
11 # pull out all join conds as regular WHEREs from all extra tables
12 if (ref($table) eq 'ARRAY') {
13 $where = $self->_oracle_joins($where, @{ $table }[ 1 .. $#$table ]);
16 return $self->next::method($table, $fields, $where, $rs_attrs, @rest);
20 my ($self, $from, @join) = @_;
22 my @sqlf = $self->_from_chunk_to_sql($from);
27 if (ref $to eq 'ARRAY') {
28 push (@sqlf, $self->_recurse_from(@{ $to }));
31 push (@sqlf, $self->_from_chunk_to_sql($to));
35 return join q{, }, @sqlf;
39 my ($self, $where, @join) = @_;
40 my $join_where = $self->_recurse_oracle_joins(@join);
42 if (keys %$join_where) {
43 if (!defined($where)) {
46 if (ref($where) eq 'ARRAY') {
47 $where = { -or => $where };
49 $where = { -and => [ $join_where, $where ] };
55 sub _recurse_oracle_joins {
60 my ($to, $on) = @{ $j };
62 push @where, $self->_recurse_oracle_joins(@{ $to })
63 if (ref $to eq 'ARRAY');
65 my $join_opts = ref $to eq 'ARRAY' ? $to->[0] : $to;
69 if (ref $join_opts eq 'HASH' and my $jt = $join_opts->{-join_type}) {
70 #TODO: Support full outer joins -- this would happen much earlier in
71 #the sequence since oracle 8's full outer join syntax is best
73 $self->throw_exception("Can't handle full outer joins in Oracle 8 yet!\n")
76 $left_join = q{(+)} if $jt =~ /left/i
79 $right_join = q{(+)} if $jt =~ /right/i
83 # FIXME - the code below *UTTERLY* doesn't work with custom conds... sigh
84 # for the time being do not do any processing with the likes of _collapse_cond
85 # instead only unroll the -and hack if present
86 $on = $on->{-and}[0] if (
91 ref $on->{-and} eq 'ARRAY'
97 push @where, map { \do {
98 my ($sql) = $self->_recurse_where({
99 # FIXME - more borkage, more or less a copy of the kludge in ::SQLMaker::_join_condition()
100 $_ => ( length ref $on->{$_}
102 : { -ident => $on->{$_} }
106 $sql =~ s/\s*\=/$left_join =/
114 return { -and => \@where };
123 DBIx::Class::SQLMaker::OracleJoins - Pre-ANSI Joins-via-Where-Clause Syntax
127 This module is used with Oracle < 9.0 due to lack of support for standard
132 Not intended for use directly; used as the sql_maker_class for schemas and components.
136 Implements pre-ANSI joins specified in the where clause. Instead of:
138 SELECT x FROM y JOIN z ON y.id = z.id
142 SELECT x FROM y, z WHERE y.id = z.id
144 It should properly support left joins, and right joins. Full outer joins are
145 not possible due to the fact that Oracle requires the entire query be written
146 to union the results of a left and right join, and by the time this module is
147 called to create the where query and table definition part of the sql query,
148 it's already too late.
156 Overrides DBIx::Class::SQLMaker's select() method, which calls _oracle_joins()
157 to modify the column and table list before calling next::method().
163 Does not support full outer joins (however neither really does DBIC itself)
169 =item L<DBIx::Class::Storage::DBI::Oracle::WhereJoins> - Storage class using this
171 =item L<DBIx::Class::SQLMaker> - Parent module
173 =item L<DBIx::Class> - Duh
177 =head1 FURTHER QUESTIONS?
179 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
181 =head1 COPYRIGHT AND LICENSE
183 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
184 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
185 redistribute it and/or modify it under the same terms as the
186 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.