# at all. Tell SQLMaker to dequalify idents via a gross hack.
my $cond = do {
my $sqla = $rsrc->storage->sql_maker;
+ local $sqla->{FROM} = $rsrc;
local $sqla->{_dequalify_idents} = 1;
\[ $sqla->_recurse_where($self->{cond}) ];
};
use Devel::GlobalDestruction;
use Try::Tiny;
use List::Util 'first';
-use Scalar::Util qw/blessed weaken isweak/;
+use Scalar::Util qw/blessed weaken isweak refaddr/;
use namespace::clean;
use base qw/DBIx::Class/;
sub from { die 'Virtual method!' }
+use overload
+ '""' => sub { my $name = $_[0]->from; return ref $name ? $$name : $name },
+ '0+' => sub { refaddr($_[0]) },
+ '==' => sub { refaddr($_[0]) == refaddr($_[1]) },
+ fallback => 1;
+
=head2 schema
=over 4
sub _quote {
return undef if not defined $_[1];
- my $col = ( $_[0]{_dequalify_idents} and ! ref $_[1] )
+ my ($col) = ( $_[0]{_dequalify_idents} and ! ref $_[1] )
? $_[1] =~ / ([^\.]+) $ /x
: $_[1]
;
}
sub delete {
+ local $_[0]->{FROM} = $_[1];
shift->next::method(@_);
}
my ($self, $op, $ident, $args) = @_;
my ($sql, @bind) = $self->sql_maker->$op(
- blessed($ident) ? $ident->from : $ident,
+ $ident,
@$args,
);
is_same_sql_bind(
$sql, \@bind,
- "DELETE FROM bad_names_1 WHERE ( me.stupid_name = ? )", ["'2001'"],
+ "DELETE FROM bad_names_1 WHERE ( stupid_name = ? )", ["'2001'"],
'delete'
);