X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FStorage%2FDBI%2FSQLAnywhere.pm;h=85b5614e6d219d699fabe2b536a4a90c9cf19062;hb=e9657379908899b73ff92948a4cd19b6f875e10f;hp=16adca42430130ff4467a03f3c2e65fe76c21a6e;hpb=7da56142c171e61e6bec750e80dbb26f595f777e;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm index 16adca4..85b5614 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm @@ -4,7 +4,9 @@ use strict; 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; __PACKAGE__->mk_group_accessors(simple => qw/ _identity @@ -41,9 +43,8 @@ sub insert { 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) { @@ -62,8 +63,8 @@ sub insert { my $table_name = $source->from; $table_name = $$table_name if ref $table_name; - my ($identity) = eval { - local $@; $dbh->selectrow_array("SELECT GET_IDENTITY('$table_name')") + my ($identity) = try { + $dbh->selectrow_array("SELECT GET_IDENTITY('$table_name')") }; if (defined $identity) { @@ -114,8 +115,13 @@ sub _sql_maker_opts { sub build_datetime_parser { my $self = shift; my $type = "DateTime::Format::Strptime"; - eval "use ${type}"; - $self->throw_exception("Couldn't load ${type}: $@") if $@; + try { + eval "require ${type}" + } + catch { + $self->throw_exception("Couldn't load ${type}: $_"); + }; + return $type->new( pattern => '%Y-%m-%d %H:%M:%S.%6N' ); }