use DBIx::Class::Storage::DBI;
use DBIx::Class::ClassResolver::PassThrough;
use DBI;
-use Scalar::Util;
+use Scalar::Util 'blessed';
+use namespace::clean;
unless ($INC{"DBIx/Class/CDBICompat.pm"}) {
warn "IMPORTANT: DBIx::Class::DB is DEPRECATED AND *WILL* BE REMOVED. DO NOT USE.\n";
}
my($source, $result_class) = @{$class->_result_source_instance};
- return unless Scalar::Util::blessed($source);
+ return unless blessed $source;
if ($result_class ne $class) { # new class
# Give this new class its own source and register it.
use strict;
use warnings;
-use Scalar::Util ();
use base qw/DBIx::Class/;
+
+use Scalar::Util qw/weaken blessed/;
use Try::Tiny;
use namespace::clean;
foreach my $rev_rel (keys %$reverse) {
if ($reverse->{$rev_rel}{attrs}{accessor} && $reverse->{$rev_rel}{attrs}{accessor} eq 'multi') {
$attrs->{related_objects}{$rev_rel} = [ $self ];
- Scalar::Util::weaken($attrs->{related_object}{$rev_rel}[0]);
+ weaken $attrs->{related_object}{$rev_rel}[0];
} else {
$attrs->{related_objects}{$rev_rel} = $self;
- Scalar::Util::weaken($attrs->{related_object}{$rev_rel});
+ weaken $attrs->{related_object}{$rev_rel};
}
}
}
if (defined $f_obj) {
my $f_class = $rel_info->{class};
$self->throw_exception( "Object $f_obj isn't a ".$f_class )
- unless Scalar::Util::blessed($f_obj) and $f_obj->isa($f_class);
+ unless blessed $f_obj and $f_obj->isa($f_class);
}
$self->set_columns(
$self->result_source->_resolve_condition(
use strict;
use warnings;
-use overload
- '0+' => "count",
- 'bool' => "_bool",
- fallback => 1;
+use base qw/DBIx::Class/;
use Carp::Clan qw/^DBIx::Class/;
use DBIx::Class::Exception;
use Data::Page;
use DBIx::Class::ResultSetColumn;
use DBIx::Class::ResultSourceHandle;
use List::Util ();
-use Scalar::Util ();
-use base qw/DBIx::Class/;
+use Scalar::Util 'blessed';
+use namespace::clean;
+
+use overload
+ '0+' => "count",
+ 'bool' => "_bool",
+ fallback => 1;
__PACKAGE__->mk_group_accessors('simple' => qw/_result_class _source_handle/);
my $value = shift;
my $ref_type = ref $value;
return 1 if $ref_type eq '' || $ref_type eq 'SCALAR';
- return 1 if Scalar::Util::blessed($value);
+ return 1 if blessed $value;
return 0;
}
use Carp::Clan qw/^DBIx::Class/;
use DBIx::Class::Exception;
-use List::Util;
+use List::Util ();
+use namespace::clean;
=head1 NAME
use DBIx::Class::Exception;
use Carp::Clan qw/^DBIx::Class/;
use Try::Tiny;
+use List::Util 'first';
use namespace::clean;
use base qw/DBIx::Class/;
-is_single => (
$rel_info->{attrs}{accessor}
&&
- List::Util::first { $rel_info->{attrs}{accessor} eq $_ } (qw/single filter/)
+ first { $rel_info->{attrs}{accessor} eq $_ } (qw/single filter/)
),
-alias => $as,
-relation_chain_depth => $seen->{-relation_chain_depth} || 0,
use base qw/DBIx::Class::ResultSourceProxy/;
use DBIx::Class::ResultSource::Table;
-use Scalar::Util ();
+use Scalar::Util 'blessed';
+use namespace::clean;
__PACKAGE__->mk_classdata(table_class => 'DBIx::Class::ResultSource::Table');
my ($class, $table) = @_;
return $class->result_source_instance->name unless $table;
- unless (Scalar::Util::blessed($table) && $table->isa($class->table_class)) {
+ unless (blessed $table && $table->isa($class->table_class)) {
my $table_class = $class->table_class;
$class->ensure_class_loaded($table_class);
use base qw/DBIx::Class/;
use DBIx::Class::Exception;
-use Scalar::Util ();
+use Scalar::Util 'blessed';
use Try::Tiny;
use namespace::clean;
my $acc_type = $info->{attrs}{accessor} || '';
if ($acc_type eq 'single') {
my $rel_obj = delete $attrs->{$key};
- if(!Scalar::Util::blessed($rel_obj)) {
+ if(!blessed $rel_obj) {
$rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj);
}
my @objects;
foreach my $idx (0 .. $#$others) {
my $rel_obj = $others->[$idx];
- if(!Scalar::Util::blessed($rel_obj)) {
+ if(!blessed $rel_obj) {
$rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj);
}
elsif ($acc_type eq 'filter') {
## 'filter' should disappear and get merged in with 'single' above!
my $rel_obj = delete $attrs->{$key};
- if(!Scalar::Util::blessed($rel_obj)) {
+ if(!blessed $rel_obj) {
$rel_obj = $new->__new_related_find_or_new_helper($key, $rel_obj);
}
if ($rel_obj->in_storage) {
my $rel_obj = $related_stuff{$relname};
if (! $self->{_rel_in_storage}{$relname}) {
- next unless (Scalar::Util::blessed($rel_obj)
- && $rel_obj->isa('DBIx::Class::Row'));
+ next unless (blessed $rel_obj && $rel_obj->isa('DBIx::Class::Row'));
next unless $source->_pk_depends_on(
$relname, { $rel_obj->get_columns }
: $related_stuff{$relname}
;
- if (@cands
- && Scalar::Util::blessed($cands[0])
- && $cands[0]->isa('DBIx::Class::Row')
+ if (@cands && blessed $cands[0] && $cands[0]->isa('DBIx::Class::Row')
) {
my $reverse = $source->reverse_relationship_info($relname);
foreach my $obj (@cands) {
use strict;
use warnings;
use Carp::Clan qw/^DBIx::Class|^SQL::Abstract/;
-use Sub::Name();
+use List::Util 'first';
+use Sub::Name 'subname';
+use namespace::clean;
BEGIN {
# reinstall the carp()/croak() functions imported into SQL::Abstract
for my $f (qw/carp croak/) {
my $orig = \&{"SQL::Abstract::$f"};
- *{"SQL::Abstract::$f"} = Sub::Name::subname "SQL::Abstract::$f" =>
+ *{"SQL::Abstract::$f"} = subname "SQL::Abstract::$f" =>
sub {
if (Carp::longmess() =~ /DBIx::Class::SQLAHacks::[\w]+ .+? called \s at/x) {
__PACKAGE__->can($f)->(@_);
# for possible further chaining)
my (@in_sel, @out_sel, %renamed);
for my $node (@sel) {
- if (List::Util::first { $_ =~ / (?<! $re_alias ) $re_sep /x } ($node->{as}, $node->{unquoted_sql}) ) {
+ if (first { $_ =~ / (?<! $re_alias ) $re_sep /x } ($node->{as}, $node->{unquoted_sql}) ) {
$node->{as} =~ s/ $re_sep /__/xg;
my $quoted_as = $self->_quote($node->{as});
push @in_sel, sprintf '%s AS %s', $node->{sql}, $quoted_as;
use DBIx::Class::Exception;
use Carp::Clan qw/^DBIx::Class/;
use Try::Tiny;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
use File::Spec;
-use Sub::Name ();
+use Sub::Name 'subname';
use Module::Find();
+use Storable();
use namespace::clean;
use base qw/DBIx::Class/;
no strict 'refs';
no warnings 'redefine';
foreach my $meth (qw/class source resultset/) {
- *{"${target}::${meth}"} = Sub::Name::subname "${target}::${meth}" =>
+ *{"${target}::${meth}"} = subname "${target}::${meth}" =>
sub { shift->schema->$meth(@_) };
}
}
$source = $source->new({ %$source, source_name => $moniker });
$source->schema($self);
- Scalar::Util::weaken($source->{schema}) if ref($self);
+ weaken $source->{schema} if ref($self);
my $rs_class = $source->result_class;
{
no strict 'refs';
my $name = join '::', $target, 'schema';
- *$name = Sub::Name::subname $name, sub { $schema };
+ *$name = subname $name, sub { $schema };
}
$schema->connection(@info);
use mro 'c3';
use DBIx::Class::Exception;
-use Scalar::Util();
+use Scalar::Util 'weaken';
use IO::File;
use DBIx::Class::Storage::TxnScopeGuard;
use Try::Tiny;
sub set_schema {
my ($self, $schema) = @_;
$self->schema($schema);
- Scalar::Util::weaken($self->{schema}) if ref $self->{schema};
+ weaken $self->{schema} if ref $self->{schema};
}
=head2 connected
use DBI;
use DBIx::Class::Storage::DBI::Cursor;
use DBIx::Class::Storage::Statistics;
-use Scalar::Util();
-use List::Util();
-use Data::Dumper::Concise();
-use Sub::Name ();
+use Scalar::Util qw/refaddr weaken reftype blessed/;
+use Data::Dumper::Concise 'Dumper';
+use Sub::Name 'subname';
use Try::Tiny;
-use File::Path ();
+use File::Path 'mkpath';
use namespace::clean;
__PACKAGE__->mk_group_accessors('simple' => qw/
no strict qw/refs/;
no warnings qw/redefine/;
- *{__PACKAGE__ ."::$meth"} = Sub::Name::subname $meth => sub {
+ *{__PACKAGE__ ."::$meth"} = subname $meth => sub {
if (not $_[0]->_driver_determined) {
$_[0]->_determine_driver;
goto $_[0]->can($meth);
} else {
# if connect_info is a CODEREF, we have no choice but to connect
if (ref $self->_dbi_connect_info->[0] &&
- Scalar::Util::reftype($self->_dbi_connect_info->[0]) eq 'CODE') {
+ reftype $self->_dbi_connect_info->[0] eq 'CODE') {
$self->_populate_dbh;
$driver = $self->_dbh->{Driver}{Name};
}
unless ($self->unsafe) {
my $weak_self = $self;
- Scalar::Util::weaken($weak_self);
+ weaken $weak_self;
$dbh->{HandleError} = sub {
if ($weak_self) {
$weak_self->throw_exception("DBI Exception: $_[0]");
sub _prep_for_execute {
my ($self, $op, $extra_bind, $ident, $args) = @_;
- if( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ if( blessed $ident && $ident->isa("DBIx::Class::ResultSource") ) {
$ident = $ident->from();
}
$cols->[$col_idx],
do {
local $Data::Dumper::Maxdepth = 1; # don't dump objects, if any
- Data::Dumper::Concise::Dumper({
+ Dumper {
map { $cols->[$_] => $data->[$slice_idx][$_] } (0 .. $#$cols)
- }),
+ },
}
);
};
$self->throw_exception(sprintf "%s for populate slice:\n%s",
($tuple_status->[$i][1] || $err),
- Data::Dumper::Concise::Dumper({
- map { $cols->[$_] => $data->[$i][$_] } (0 .. $#$cols)
- }),
+ Dumper { map { $cols->[$_] => $data->[$i][$_] } (0 .. $#$cols) },
);
}
carp "No directory given, using ./\n";
$dir = './';
} else {
- -d $dir or File::Path::mkpath($dir)
+ -d $dir or mkpath $dir
or $self->throw_exception("create_ddl_dir: $! creating dir '$dir'");
}
use mro 'c3';
use Scope::Guard ();
-use Context::Preserve ();
+use Context::Preserve 'preserve_context';
+use namespace::clean;
__PACKAGE__->mk_group_accessors('simple' => '__last_insert_id');
$self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
});
- return Context::Preserve::preserve_context(sub { $sub->() },
- after => sub { $txn_scope_guard->commit });
+ return preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
}
=head2 connect_call_datetime_setup
use warnings;
use base qw/DBIx::Class::Storage::DBI/;
use mro 'c3';
-use List::Util();
+use List::Util 'first';
use Try::Tiny;
use namespace::clean;
$generator = uc $generator unless $quoted;
return $generator
- if List::Util::first {
+ if first {
$self->sql_maker->quote_char ? ($_ eq $col) : (uc($_) eq uc($col))
} @trig_cols;
}
use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/;
use mro 'c3';
use Try::Tiny;
+use List::Util 'first';
use namespace::clean;
-use List::Util();
-
__PACKAGE__->mk_group_accessors(simple => qw/
_identity _identity_method
/);
my $self = shift;
my ($source, $cols, $data) = @_;
- my $is_identity_insert = (List::Util::first
- { $source->column_info ($_)->{is_auto_increment} }
- (@{$cols})
- )
- ? 1
- : 0;
+ my $is_identity_insert =
+ (first { $source->column_info ($_)->{is_auto_increment} } @{$cols}) ? 1 : 0;
if ($is_identity_insert) {
$self->_set_identity_insert ($source->name);
my $supplied_col_info = $self->_resolve_column_info($source, [keys %$to_insert] );
- my $is_identity_insert = (List::Util::first { $_->{is_auto_increment} } (values %$supplied_col_info) )
- ? 1
- : 0;
+ my $is_identity_insert =
+ (first { $_->{is_auto_increment} } values %$supplied_col_info) ? 1 : 0;
if ($is_identity_insert) {
$self->_set_identity_insert ($source->name);
use base qw/DBIx::Class::Storage::DBI::MSSQL/;
use mro 'c3';
-
-use List::Util();
-use Scalar::Util ();
+use Scalar::Util 'reftype';
use Try::Tiny;
use namespace::clean;
my $dbi_attrs = $self->_dbi_connect_info->[-1];
- unless (ref($dbi_attrs) && Scalar::Util::reftype($dbi_attrs) eq 'HASH') {
+ unless (ref($dbi_attrs) && reftype $dbi_attrs eq 'HASH') {
$dbi_attrs = {};
push @{ $self->_dbi_connect_info }, $dbi_attrs;
}
use strict;
use warnings;
use Scope::Guard ();
-use Context::Preserve ();
+use Context::Preserve 'preserve_context';
use Try::Tiny;
use namespace::clean;
$self->_do_query('alter session set constraints = immediate');
});
- return Context::Preserve::preserve_context(sub { $sub->() },
- after => sub { $txn_scope_guard->commit });
+ return
+ preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
}
=head1 AUTHOR
use DBD::Pg qw(:pg_types);
use Scope::Guard ();
-use Context::Preserve ();
+use Context::Preserve 'preserve_context';
+use namespace::clean;
# Ask for a DBD::Pg with array support
warn __PACKAGE__.": DBD::Pg 2.9.2 or greater is strongly recommended\n"
$self->_do_query('SET CONSTRAINTS ALL IMMEDIATE');
});
- return Context::Preserve::preserve_context(sub { $sub->() },
- after => sub { $txn_scope_guard->commit });
+ return preserve_context { $sub->() } after => sub { $txn_scope_guard->commit };
}
# only used when INSERT ... RETURNING is disabled
use warnings;
use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/;
use mro 'c3';
-use List::Util ();
+use List::Util 'first';
use Try::Tiny;
use namespace::clean;
my $self = shift;
my ($source, $to_insert) = @_;
- my $identity_col = List::Util::first {
- $source->column_info($_)->{is_auto_increment}
- } $source->columns;
+ my $identity_col =
+ first { $source->column_info($_)->{is_auto_increment} } $source->columns;
# user might have an identity PK without is_auto_increment
if (not $identity_col) {
/;
use mro 'c3';
use Carp::Clan qw/^DBIx::Class/;
-use Scalar::Util();
-use List::Util();
+use Scalar::Util 'blessed';
+use List::Util 'first';
use Sub::Name();
-use Data::Dumper::Concise();
+use Data::Dumper::Concise 'Dumper';
use Try::Tiny;
use namespace::clean;
my ($sql, $bind) = $self->next::method (@_);
- my $table = Scalar::Util::blessed($ident) ? $ident->from : $ident;
+ my $table = blessed $ident ? $ident->from : $ident;
my $bind_info = $self->_resolve_column_info(
$ident, [map $_->[0], @{$bind}]
);
- my $bound_identity_col = List::Util::first
- { $bind_info->{$_}{is_auto_increment} }
- (keys %$bind_info)
+ my $bound_identity_col =
+ first { $bind_info->{$_}{is_auto_increment} }
+ keys %$bind_info
;
- my $identity_col = Scalar::Util::blessed($ident) &&
- List::Util::first
- { $ident->column_info($_)->{is_auto_increment} }
- $ident->columns
+ my $identity_col =
+ blessed $ident &&
+ first { $ident->column_info($_)->{is_auto_increment} } $ident->columns
;
if (($op eq 'insert' && $bound_identity_col) ||
my $self = shift;
my ($source, $to_insert) = @_;
- my $identity_col = (List::Util::first
- { $source->column_info($_)->{is_auto_increment} }
- $source->columns) || '';
+ my $identity_col =
+ (first { $source->column_info($_)->{is_auto_increment} } $source->columns)
+ || '';
# check for empty insert
# INSERT INTO foo DEFAULT VALUES -- does not work with Sybase
my $table = $source->name;
- my $identity_col = List::Util::first
- { $source->column_info($_)->{is_auto_increment} }
- $source->columns;
+ my $identity_col =
+ first { $source->column_info($_)->{is_auto_increment} } $source->columns;
my $is_identity_update = $identity_col && defined $fields->{$identity_col};
my $self = shift;
my ($source, $cols, $data) = @_;
- my $identity_col = List::Util::first
- { $source->column_info($_)->{is_auto_increment} }
- $source->columns;
+ my $identity_col =
+ first { $source->column_info($_)->{is_auto_increment} } $source->columns;
- my $is_identity_insert = (List::Util::first
- { $_ eq $identity_col }
- @{$cols}
- ) ? 1 : 0;
+ my $is_identity_insert = (first { $_ eq $identity_col } @{$cols}) ? 1 : 0;
my @source_columns = $source->columns;
if (not $sth) {
$self->throw_exception(
"Could not find row in table '$table' for blob update:\n"
- . Data::Dumper::Concise::Dumper (\%where)
+ . (Dumper \%where)
);
}
DBIx::Class::Storage::DBI::Sybase::ASE
/;
use mro 'c3';
-use List::Util ();
-use Scalar::Util ();
+use List::Util 'first';
+use Scalar::Util 'looks_like_number';
+use namespace::clean;
sub _init {
my $self = shift;
sub _fetch_identity_sql { 'SELECT ' . $_[0]->_identity_method }
-my $number = sub { Scalar::Util::looks_like_number($_[0]) };
+my $number = sub { looks_like_number $_[0] };
my $decimal = sub { $_[0] =~ /^ [-+]? \d+ (?:\.\d*)? \z/x };
return $self->next::method(@_) if not defined $value or not defined $type;
- if (my $key = List::Util::first { $type =~ /$_/i } keys %noquote) {
+ if (my $key = first { $type =~ /$_/i } keys %noquote) {
return 1 if $noquote{$key}->($value);
}
elsif ($self->is_datatype_numeric($type) && $number->($value)) {
use mro 'c3';
use Carp::Clan qw/^DBIx::Class/;
+use List::Util 'first';
+use Scalar::Util 'blessed';
+use namespace::clean;
#
# This code will remove non-selecting/non-restricting joins from
# if a multi-type join was needed in the subquery - add a group_by to simulate the
# collapse in the subq
$inner_attrs->{group_by} ||= $inner_select
- if List::Util::first
- { ! $_->[0]{-is_single} }
- (@{$inner_from}[1 .. $#$inner_from])
- ;
+ if first { ! $_->[0]{-is_single} } (@{$inner_from}[1 .. $#$inner_from]);
# generate the subquery
my $subq = $self->_select_args_to_query (
# the reason this is so contrived is that $ident may be a {from}
# structure, specifying multiple tables to join
- if ( Scalar::Util::blessed($ident) && $ident->isa("DBIx::Class::ResultSource") ) {
+ if ( blessed $ident && $ident->isa("DBIx::Class::ResultSource") ) {
# this is compat mode for insert/update/delete which do not deal with aliases
$alias2source->{me} = $ident;
$rs_alias = 'me';
use Exporter;
use SQL::Translator::Utils qw(debug normalize_name);
use Carp::Clan qw/^SQL::Translator|^DBIx::Class|^Try::Tiny/;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
use Try::Tiny;
use namespace::clean;
sub parse {
# this is a hack to prevent schema leaks due to a retarded SQLT implementation
# DO NOT REMOVE (until SQLT2 is out, the all of this will be rewritten anyway)
- Scalar::Util::weaken ($_[1]) if ref ($_[1]);
+ weaken $_[1] if ref ($_[1]);
my ($tr, $data) = @_;
my $args = $tr->parser_args;
use strict;
use Test::More;
-use List::Util ();
+use List::Util 'first';
use lib qw(t/lib);
use DBICTest;
+use namespace::clean;
# Don't run tests for installs
unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) {
foreach my $module (@modules) {
SKIP: {
- my ($match) = List::Util::first
- { $module =~ $_ }
+ my ($match) =
+ first { $module =~ $_ }
(sort { length $b <=> length $a || $b cmp $a } (keys %$ex_lookup) )
;
use DBICTest;
use DBICTest::Schema;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
+use namespace::clean;
import Test::Memory::Cycle;
my $row = $weak->{row} = $rs->first;
memory_cycle_ok($row, 'No cycles in row');
- Scalar::Util::weaken ($_) for values %$weak;
+ weaken $_ for values %$weak;
memory_cycle_ok($weak, 'No cycles in weak object collection');
}
use strict;
use Test::More;
+use Scalar::Util 'refaddr';
+use namespace::clean;
$| = 1;
BEGIN {
# my bad taste is your bad taste
my $btaste = Film->retrieve('Bad Taste');
my $btaste2 = Film->retrieve('Bad Taste');
- is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste2),
+ is refaddr $btaste, refaddr $btaste2,
"Retrieving twice gives ref to same object";
my ($btaste5) = Film->search(title=>'Bad Taste');
- is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste5),
+ is refaddr $btaste, refaddr $btaste5,
"Searching also gives ref to same object";
$btaste2->remove_from_object_index;
my $btaste3 = Film->retrieve('Bad Taste');
- isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste3),
+ isnt refaddr $btaste2, refaddr $btaste3,
"Removing from object_index and retrieving again gives new object";
$btaste3->clear_object_index;
my $btaste4 = Film->retrieve('Bad Taste');
- isnt Scalar::Util::refaddr($btaste2), Scalar::Util::refaddr($btaste4),
+ isnt refaddr $btaste2, refaddr $btaste4,
"Clearing cache and retrieving again gives new object";
$btaste=Film->insert({
NumExplodingSheep => 2,
});
$btaste2 = Film->retrieve('Bad Taste 2');
- is Scalar::Util::refaddr($btaste), Scalar::Util::refaddr($btaste2),
+ is refaddr $btaste, refaddr $btaste2,
"Creating and retrieving gives ref to same object";
}