* Fixes
- Ensure failing on_connect* / on_disconnect* are dealt with properly,
notably on_connect* failures now properly abort the entire connect
+ - Fix incorrect SQL generated with invalid {rows} on complex resultset
+ operations, generally more robust handling of rows/offset attrs
- Make sure exception objects stringifying to '' are properly handled
and warned about (GH#15)
- Fix corner case of stringify-only overloaded objects being used in
$self->throw_exception("Specifying distinct => 1 in conjunction with collapse => 1 is unsupported")
if $attrs->{collapse} and $attrs->{distinct};
+
+ # Sanity check the paging attributes
+ # SQLMaker does it too, but in case of a software_limit we'll never get there
+ if (defined $attrs->{offset}) {
+ $self->throw_exception('A supplied offset attribute must be a non-negative integer')
+ if ( $attrs->{offset} =~ /[^0-9]/ or $attrs->{offset} < 0 );
+ }
+ if (defined $attrs->{rows}) {
+ $self->throw_exception("The rows attribute must be a positive integer if present")
+ if ( $attrs->{rows} =~ /[^0-9]/ or $attrs->{rows} <= 0 );
+ }
+
+
# default selection list
$attrs->{columns} = [ $source->columns ]
unless List::Util::first { exists $attrs->{$_} } qw/columns cols select as/;
where => $where,
};
- # Sanity check the attributes (SQLMaker does it too, but
- # in case of a software_limit we'll never reach there)
- if (defined $attrs->{offset}) {
- $self->throw_exception('A supplied offset attribute must be a non-negative integer')
- if ( $attrs->{offset} =~ /[^0-9]/ or $attrs->{offset} < 0 );
- }
-
- if (defined $attrs->{rows}) {
- $self->throw_exception("The rows attribute must be a positive integer if present")
- if ( $attrs->{rows} =~ /[^0-9]/ or $attrs->{rows} <= 0 );
- }
- elsif ($attrs->{offset}) {
- # MySQL actually recommends this approach. I cringe.
- $attrs->{rows} = $sql_maker->__max_int;
- }
+ # MySQL actually recommends this approach. I cringe.
+ $attrs->{rows} ||= $sql_maker->__max_int
+ if $attrs->{offset};
# see if we will need to tear the prefetch apart to satisfy group_by == select
# this is *extremely tricky* to get right, I am still not sure I did
$tkfks->search ({}, { rows => 1 })->delete;
is ($tkfks->count, $tkfk_cnt -= 1, 'Only one row deleted');
+throws_ok {
+ $tkfks->search ({}, { rows => 0 })->delete
+} qr/rows attribute must be a positive integer/;
+is ($tkfks->count, $tkfk_cnt, 'Nothing deleted');
# check with sql-equality, as sqlite will accept most bad sql just fine
{