names
- Add ResultSet::_is_deterministic_value, make new_result filter the
values passed to new to drop values that would generate invalid SQL.
+ - Use Sub::Name to name closures before installing them. Fixes
+ incompatibility with Moose method modifiers on generated methods.
0.08010 2008-03-01 10:30
- Fix t/94versioning.t so it passes with latest SQL::Translator
requires 'Scope::Guard' => 0.03;
requires 'Path::Class' => 0;
requires 'List::Util' => 1.19;
+requires 'Sub::Name' => 0.04;
# Perl 5.8.0 doesn't have utf8::is_utf8()
requires 'Encode' => 0 if ($] <= 5.008000);
use strict;
use warnings;
-
+use Sub::Name ();
use Storable 'dclone';
use base qw/DBIx::Class::Row/;
{
no strict 'refs';
no warnings 'redefine';
- *{$class .'::'. $name} = $accessor;
+ my $fullname = join '::', $class, $name;
+ *$fullname = Sub::Name::subname $fullname, $accessor;
}
$our_accessors{$accessor}++;
use strict;
use warnings;
use DBIx::ContextualFetch;
+use Sub::Name ();
use base qw/DBIx::Class/;
sub set_sql {
my ($class, $name, $sql) = @_;
no strict 'refs';
- *{"${class}::sql_${name}"} =
+ my $sql_name = "sql_${name}";
+ my $full_sql_name = join '::', $class, $sql_name;
+ *$full_sql_name = Sub::Name::subname $full_sql_name,
sub {
my $sql = $sql;
my $class = shift;
return $class->storage->sth($class->transform_sql($sql, @_));
};
if ($sql =~ /select/i) {
- my $meth = "sql_${name}";
- *{"${class}::search_${name}"} =
+ my $search_name = "search_${name}";
+ my $full_search_name = join '::', $class, $search_name;
+ *$full_search_name = Sub::Name::subname $full_search_name,
sub {
my ($class, @args) = @_;
- my $sth = $class->$meth;
+ my $sth = $class->$sql_name;
return $class->sth_to_objects($sth, \@args);
};
}
use strict;
use warnings;
-
+use Sub::Name ();
=head1 NAME
};
no strict 'refs';
- *{$method} = $code;
+ *{$method} = Sub::Name::subname $method, $code;
}
1;
use strict;
use warnings;
-
+use Sub::Name ();
use base qw/Class::Data::Inheritable/;
use Clone;
no strict 'refs';
no warnings 'redefine';
my $post_proc = sub { my $o = shift; $o = $o->$_ for @f_method; $o; };
- *{"${class}::${rel}"} =
+ my $name = join '::', $class, $rel;
+ *$name = Sub::Name::subname $name,
sub {
my $rs = shift->search_related($rel => @_);
$rs->{attrs}{record_filter} = $post_proc;
use strict;
use warnings;
+use Sub::Name ();
+use Class::Inspector ();
sub register_relationship {
my ($class, $rel, $info) = @_;
no strict 'refs';
no warnings 'redefine';
foreach my $meth (keys %meth) {
- *{"${class}::${meth}"} = $meth{$meth};
+ my $name = join '::', $class, $meth;
+ *$name = Sub::Name::subname($name, $meth{$meth});
}
}
}
use strict;
use warnings;
+use Sub::Name ();
sub many_to_many {
my ($class, $meth, $rel, $f_rel, $rel_attrs) = @_;
$rel_attrs->{alias} ||= $f_rel;
- *{"${class}::${meth}_rs"} = sub {
+ my $rs_meth_name = join '::', $class, $rs_meth;
+ *$rs_meth_name = Sub::Name::subname $rs_meth_name, sub {
my $self = shift;
my $attrs = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {};
my @args = ($f_rel, @_ > 0 ? @_ : undef, { %{$rel_attrs||{}}, %$attrs });
return $rs;
};
- *{"${class}::${meth}"} = sub {
+ my $meth_name = join '::', $class, $meth;
+ *$meth_name = Sub::Name::subname $meth_name, sub {
my $self = shift;
my $rs = $self->$rs_meth( @_ );
return (wantarray ? $rs->all : $rs);
};
- *{"${class}::${add_meth}"} = sub {
+ my $add_meth_name = join '::', $class, $add_meth;
+ *$add_meth_name = Sub::Name::subname $add_meth_name, sub {
my $self = shift;
@_ > 0 or $self->throw_exception(
"${add_meth} needs an object or hashref"
return $obj;
};
- *{"${class}::${set_meth}"} = sub {
+ my $set_meth_name = join '::', $class, $set_meth;
+ *$set_meth_name = Sub::Name::subname $set_meth_name, sub {
my $self = shift;
@_ > 0 or $self->throw_exception(
"{$set_meth} needs a list of objects or hashrefs"
$self->$add_meth($_) for (@to_set);
};
- *{"${class}::${remove_meth}"} = sub {
+ my $remove_meth_name = join '::', $class, $remove_meth;
+ *$remove_meth_name = Sub::Name::subname $remove_meth_name, sub {
my $self = shift;
@_ > 0 && ref $_[0] ne 'HASH'
or $self->throw_exception("${remove_meth} needs an object");
use strict;
use warnings;
-
+use Sub::Name ();
use base qw/DBIx::Class/;
sub register_relationship {
no strict 'refs';
no warnings 'redefine';
foreach my $proxy (@proxy) {
- *{"${class}::${proxy}"} =
+ my $name = join '::', $class, $proxy;
+ *$name = Sub::Name::subname $name,
sub {
my $self = shift;
my $val = $self->$rel;
use strict;
use warnings;
use base 'DBIx::Class';
+use Sub::Name ();
use Class::Inspector;
warn "DBIx::Class::ResultSetManager never left experimental status and
if ($attrs->[0] eq 'ResultSet') {
no strict 'refs';
my $resultset_class = $self->_setup_resultset_class;
- *{"$resultset_class\::$meth"} = $self->can($meth);
+ my $name = join '::',$resultset_class, $meth;
+ *$name = Sub::Name::subname $name, $self->can($meth);
delete ${"${self}::"}{$meth};
}
}
use Carp::Clan qw/^DBIx::Class/;
use Scalar::Util qw/weaken/;
use File::Spec;
+use Sub::Name ();
require Module::Find;
use base qw/DBIx::Class/;
my $schema = $self->compose_namespace($target, $base);
{
no strict 'refs';
- *{"${target}::schema"} = sub { $schema };
+ my $name = join '::', $target, 'schema';
+ *$name = Sub::Name::subname $name, sub { $schema };
}
$schema->connection(@info);
no strict 'refs';
no warnings 'redefine';
foreach my $meth (qw/class source resultset/) {
- *{"${target}::${meth}"} =
- sub { shift->schema->$meth(@_) };
+ my $name = join '::', $target, $meth;
+ *$name = Sub::Name::subname $name, sub { shift->schema->$meth(@_) };
}
}
return $schema;