Revision history for DBIx::Class
- fixups to ORDER BY, tweaks to deepen some copies in ResultSet
+ - fixup for RowNum limit syntax with functions
0.06999_07 2006-07-12 20:58:05
- fix issue with from attr copying introduced in last release
sub select {
my ($self, $table, $fields, $where, $order, @rest) = @_;
$table = $self->_quote($table) unless ref($table);
+ local $self->{rownum_hack_count} = 1
+ if (defined $rest[0] && $self->{limit_dialect} eq 'RowNum');
@rest = (-1) unless defined $rest[0];
die "LIMIT 0 Does Not Compute" if $rest[0] == 0;
# and anyway, SQL::Abstract::Limit will cause a barf if we don't first
return $$fields if $ref eq 'SCALAR';
if ($ref eq 'ARRAY') {
- return join(', ', map { $self->_recurse_fields($_) } @$fields);
+ return join(', ', map {
+ $self->_recurse_fields($_)
+ .(exists $self->{rownum_hack_count}
+ ? ' AS col'.$self->{rownum_hack_count}++
+ : '')
+ } @$fields);
} elsif ($ref eq 'HASH') {
foreach my $func (keys %$fields) {
return $self->_sqlcase($func)
return $self->SUPER::_quote($label);
}
-sub _RowNum {
- my $self = shift;
- my $c;
- $_[0] =~ s/SELECT (.*?) FROM/
- 'SELECT '.join(', ', map { $_.' AS col'.++$c } split(', ', $1)).' FROM'/e;
- $self->SUPER::_RowNum(@_);
-}
-
sub limit_dialect {
my $self = shift;
$self->{limit_dialect} = shift if @_;
$sa->limit_dialect('RowNum');
is($sa->select('rubbish',
- [ 'foo.id', 'bar.id' ],
+ [ 'foo.id', 'bar.id', \'TO_CHAR(foo.womble, "blah")' ],
undef, undef, 1, 3),
'SELECT * FROM
(
SELECT A.*, ROWNUM r FROM
(
- SELECT foo.id AS col1, bar.id AS col2 FROM rubbish
+ SELECT foo.id AS col1, bar.id AS col2, TO_CHAR(foo.womble, "blah") AS col3 FROM rubbish
) A
WHERE ROWNUM < 5
) B