Revision history for DBIx::Class
+ - Perl 5.8.1 is now the minimum supported version
+ - might_have/has_one now warn if applied calling class's column
+ has is_nullable set to true.
+ - Fixed regression in deploy() with a {sources} table limit applied
+ (RT#52812)
+ - Cookbook POD fix for add_drop_table instead of add_drop_tables
+ - Views without a view_definition will throw an exception when
+ parsed by SQL::Translator::Parser::DBIx::Class
+ - Schema POD improvement for dclone
+ - Fix regression in context sensitiveness of deployment_statements
+ - Fix regression resulting in overcomplicated query on
+ search_related from prefetching resultsets
- - Better isolation of RNO-limited queries from the rest
- of a prefetching resultset
0.08115 2009-12-10 09:02:00 (CST)
- Real limit/offset support for MSSQL server (via Row_Number)
my $cond = $rsrc->schema->storage->_strip_cond_qualifiers ($self->{cond});
my $needs_group_by_subq = $self->_has_resolved_attr (qw/collapse group_by -join/);
- my $needs_subq = (not defined $cond) || $self->_has_resolved_attr(qw/row offset/);
+ my $needs_subq = $needs_group_by_subq || (not defined $cond) || $self->_has_resolved_attr(qw/row offset/);
if ($needs_group_by_subq or $needs_subq) {
my $attrs = $self->_chain_relationship($rel);
my $join_count = $attrs->{seen_join}{$rel};
- my $alias = ($join_count > 1 ? join('_', $rel, $join_count) : $rel);
+
+ my $alias = $self->result_source->storage
+ ->relname_to_table_alias($rel, $join_count);
#XXX - temp fix for result_class bug. There likely is a more elegant fix -groditi
delete @{$attrs}{qw(result_class alias)};
||
$self->_has_resolved_attr (@force_subq_attrs)
) {
+ # Nuke the prefetch (if any) before the new $rs attrs
+ # are resolved (prefetch is useless - we are wrapping
+ # a subquery anyway).
+ my $rs_copy = $self->search;
+ $rs_copy->{attrs}{join} = $self->_merge_attr (
+ $rs_copy->{attrs}{join},
+ delete $rs_copy->{attrs}{prefetch},
+ );
+
$from = [{
-source_handle => $source->handle,
-alias => $attrs->{alias},
- $attrs->{alias} => $self->as_query,
+ $attrs->{alias} => $rs_copy->as_query,
}];
delete @{$attrs}{@force_subq_attrs, 'where'};
$seen->{-relation_chain_depth} = 0;
}
}
- sub _sth_bind_param {
- my ($self, $sth, $placeholder_index, $data, $attributes) = @_;
-
- $sth->bind_param($placeholder_index, $data, $attributes);
- }
-
sub _dbh_execute {
my ($self, $dbh, $op, $extra_bind, $ident, $bind_attributes, @args) = @_;
my $ref = ref $data;
$data = $ref && $ref ne 'ARRAY' ? ''.$data : $data; # stringify args (except arrayrefs)
- $self->_sth_bind_param($sth, $placeholder_index, $data, $attributes);
+ $sth->bind_param($placeholder_index, $data, $attributes);
$placeholder_index++;
}
}
my @limit;
- # see if we need to tear the prefetch apart (either limited has_many or grouped prefetch)
- # otherwise delegate the limiting to the storage, unless software limit was requested
+ # see if we need to tear the prefetch apart otherwise delegate the limiting to the
+ # storage, unless software limit was requested
if (
+ #limited has_many
( $attrs->{rows} && keys %{$attrs->{collapse}} )
||
+ # limited prefetch with RNO subqueries
+ (
+ $attrs->{rows}
+ &&
+ $sql_maker->limit_dialect eq 'RowNumberOver'
+ &&
+ $attrs->{_prefetch_select}
+ &&
+ @{$attrs->{_prefetch_select}}
+ )
+ ||
+ # grouped prefetch
( $attrs->{group_by}
&&
@{$attrs->{group_by}}
@{$attrs->{_prefetch_select}}
)
) {
-
($ident, $select, $where, $attrs)
= $self->_adjust_select_args_for_complex_prefetch ($ident, $select, $where, $attrs);
}
data => $schema,
);
- my $ret = $tr->translate
- or $self->throw_exception( 'Unable to produce deployment statements: ' . $tr->error);
+ my @ret;
+ my $wa = wantarray;
+ if ($wa) {
+ @ret = $tr->translate;
+ }
+ else {
+ $ret[0] = $tr->translate;
+ }
- return $ret;
+ $self->throw_exception( 'Unable to produce deployment statements: ' . $tr->error)
+ unless (@ret && defined $ret[0]);
+
+ return $wa ? @ret : $ret[0];
}
sub deploy {
sub _sqlt_minimum_version { $minimum_sqlt_version };
}
+ =head2 relname_to_table_alias
+
+ =over 4
+
+ =item Arguments: $relname, $join_count
+
+ =back
+
+ L<DBIx::Class> uses L<DBIx::Class::Relationship> names as table aliases in
+ queries.
+
+ This hook is to allow specific L<DBIx::Class::Storage> drivers to change the
+ way these aliases are named.
+
+ The default behavior is C<"$relname_$join_count" if $join_count > 1>, otherwise
+ C<"$relname">.
+
+ =cut
+
+ sub relname_to_table_alias {
+ my ($self, $relname, $join_count) = @_;
+
+ my $alias = ($join_count && $join_count > 1 ?
+ join('_', $relname, $join_count) : $relname);
+
+ return $alias;
+ }
+
sub DESTROY {
my $self = shift;