1 package DBIx::Class::Storage::DBI::Oracle::8;
2 # -*- mode: cperl; cperl-indent-level: 2 -*-
4 use base qw( DBIx::Class::Storage::DBI::Oracle::Generic );
10 package DBIC::SQL::Abstract::Oracle8;
12 use base qw( DBIC::SQL::Abstract );
15 my ($self, $table, $fields, $where, $order, @rest) = @_;
17 $self->_oracle_joins($where, @{ $table });
19 return $self->SUPER::select($table, $fields, $where, $order, @rest);
23 my ($self, $from, @join) = @_;
25 my @sqlf = $self->_make_as($from);
27 foreach my $j (@join) {
28 my ($to, $on) = @{ $j };
30 if (ref $to eq 'ARRAY') {
31 push (@sqlf, $self->_recurse_from(@{ $to }));
34 push (@sqlf, $self->_make_as($to));
38 return join q{, }, @sqlf;
42 my ($self, $where, $from, @join) = @_;
44 foreach my $j (@join) {
45 my ($to, $on) = @{ $j };
47 if (ref $to eq 'ARRAY') {
48 $self->_oracle_joins($where, @{ $to });
51 my $to_jt = ref $to eq 'ARRAY' ? $to->[0] : $to;
55 if (ref $to_jt eq 'HASH' and exists $to_jt->{-join_type}) {
56 #TODO: Support full outer joins -- this would happen much earlier in
57 #the sequence since oracle 8's full outer join syntax is best
59 die "Can't handle full outer joins in Oracle 8 yet!\n"
60 if $to_jt->{-join_type} =~ /full/i;
62 $left_join = q{(+)} if $to_jt->{-join_type} =~ /right/i
63 && $to_jt->{-join_type} !~ /inner/i;
65 $right_join = q{(+)} if $to_jt->{-join_type} =~ /left/i
66 && $to_jt->{-join_type} !~ /inner/i;
69 foreach my $lhs (keys %{ $on }) {
70 $where->{$lhs . $left_join} = \" = $on->{ $lhs }$right_join";
79 unless ($self->_sql_maker) {
81 new DBIC::SQL::Abstract::Oracle8( $self->_sql_maker_args )
85 return $self->_sql_maker;
96 DBIx::Class::Storage::DBI::Oracle::8 - Oracle 8 support (EXPERIMENTAL)
100 When initialising your code in the base DBIx module, simply tell DBIx to use
101 this as a storage class, and you're set:
103 use base qw( DBIx::Class::Schema );
105 __PACKAGE__->load_classes();
109 This class implements support specific to Oracle 8, as Oracle does not support:
111 SELECT x FROM y JOIN z ON y.id = z.id
113 Oracle requires the query by written as:
115 SELECT x FROM y, z WHERE y.id = z.id
117 This module attempts to support that.
119 It should properly support left joins, and right joins. Full outer joins are
120 not possible due to the fact that Oracle 8 requires the entire query be
121 written to union the results of a left and right join, and by the time this
122 module is called to create the where query and table definition part of the
123 sql query, it's already too late.
127 This module replaces a subroutine contained in DBIC::SQL::Abstract:
135 It also creates a new module in its BEGIN { } block called
136 DBIC::SQL::Abstract::Oracle8 which has the following methods:
140 =item select ($\@$;$$@)
142 Replaces DBIC::SQL::Abstract's select() method, which calls _oracle_joins()
143 to modify the column and table list before calling SUPER::select().
145 =item _recurse_from ($$\@)
147 Recursive subroutine that builds the table list.
149 =item _oracle_joins ($$$@)
151 Creates the left/right relationship in the where query.
157 Does not support full outer joins.
164 =item L<DBIC::SQL::Abstract>
172 Justin Wheeler C<< <justin.wheeler@caledoncard.com> >>
176 David Jack Olrik C<< <djo@cpan.org> >>
180 This module is licensed under the same terms as Perl itself.