| 1 | use 5.014; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | package # hide from PAUSE | ||
| 5 | DBIx::DBO::DBD::Oracle; | ||
| 6 | use Carp 'croak'; | ||
| 7 | |||
| 8 | sub _build_limit { | ||
| 9 | ''; | ||
| 10 | } | ||
| 11 | |||
| 12 | sub _build_sql_select { | ||
| 13 | my($class, $me) = @_; | ||
| 14 | my $sql = $class->SUPER::_build_sql_select($me); | ||
| 15 | return $sql unless defined(my $limoff = $me->{build_data}{limit}); | ||
| 16 | return 'SELECT * FROM ('.$sql.') WHERE ROWNUM <= '.$limoff->[0] unless $limoff->[1]; | ||
| 17 | # If we have an offset then we must add the "_DBO_ROWNUM_" column to the result set | ||
| 18 | return 'SELECT * FROM (SELECT A.*, ROWNUM AS "_DBO_ROWNUM_" FROM ('.$sql.') A WHERE ROWNUM <= '.($limoff->[0] + $limoff->[1]).') WHERE "_DBO_ROWNUM_" > '.$limoff->[1]; | ||
| 19 | } | ||
| 20 | |||
| 21 | sub _alias_preference { | ||
| 22 | my($class, $me, $method) = @_; | ||
| 23 | # Oracle doesn't allow the use of aliases in GROUP BY or HAVING | ||
| 24 | return 0 if $method eq 'join_on' or $method eq 'group_by' or $method eq 'having'; | ||
| 25 | return 1; | ||
| 26 | } | ||
| 27 | |||
| 28 | # Query | ||
| 29 | sub _calc_found_rows { | ||
| 30 | my($class, $me) = @_; | ||
| 31 | local $me->{build_data}{limit}; | ||
| 32 | $me->{Found_Rows} = $me->count_rows; | ||
| 33 | } | ||
| 34 | |||
| 35 | 1; |