From: Arthur Axel "fREW" Schmidt Date: Mon, 31 May 2010 15:11:51 +0000 (+0000) Subject: use namespace::clean w/ Try::Tiny X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fd323bf1046faa7de5a8c985268d80ec5b703361;p=dbsrgits%2FDBIx-Class-Historic.git use namespace::clean w/ Try::Tiny --- diff --git a/lib/DBIx/Class/Exception.pm b/lib/DBIx/Class/Exception.pm index 401bbcd..46a85f6 100644 --- a/lib/DBIx/Class/Exception.pm +++ b/lib/DBIx/Class/Exception.pm @@ -6,6 +6,7 @@ use warnings; use Carp::Clan qw/^DBIx::Class|^Try::Tiny/; use Scalar::Util qw/blessed/; use Try::Tiny; +use namespace::clean; use overload '""' => sub { shift->{msg} }, diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index 609df1e..0c5fa92 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -5,6 +5,7 @@ use warnings; use base qw/DBIx::Class/; use Carp::Clan qw/^DBIx::Class/; use Try::Tiny; +use namespace::clean; =head1 NAME @@ -12,7 +13,7 @@ DBIx::Class::InflateColumn::DateTime - Auto-create DateTime objects from date an =head1 SYNOPSIS -Load this component and then declare one or more +Load this component and then declare one or more columns to be of the datetime, timestamp or date datatype. package Event; @@ -63,9 +64,9 @@ use C thusly: =head1 DESCRIPTION -This module figures out the type of DateTime::Format::* class to -inflate/deflate with based on the type of DBIx::Class::Storage::DBI::* -that you are using. If you switch from one database to a different +This module figures out the type of DateTime::Format::* class to +inflate/deflate with based on the type of DBIx::Class::Storage::DBI::* +that you are using. If you switch from one database to a different one your code should continue to work without modification (though note that this feature is new as of 0.07, so it may not be perfect yet - bug reports to the list very much welcome). @@ -296,11 +297,11 @@ use the old way you'll see a warning - please fix your code then! =over 4 -=item More information about the add_columns method, and column metadata, +=item More information about the add_columns method, and column metadata, can be found in the documentation for L. =item Further discussion of problems inherent to the Floating timezone: - L + L and L<< $dt->set_time_zone|DateTime/"Set" Methods >> =back diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 53dc14c..d6563f4 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -6,6 +6,7 @@ use warnings; use Scalar::Util (); use base qw/DBIx::Class/; use Try::Tiny; +use namespace::clean; =head1 NAME @@ -119,7 +120,7 @@ created, which calls C for the relationship. =item is_foreign_key_constraint If you are using L to create SQL for you and you find that it -is creating constraints where it shouldn't, or not creating them where it +is creating constraints where it shouldn't, or not creating them where it should, set this attribute to a true or false value to override the detection of when to create constraints. @@ -127,8 +128,8 @@ of when to create constraints. If C is true on a C relationship for an object, then when you copy the object all the related objects will -be copied too. To turn this behaviour off, pass C<< cascade_copy => 0 >> -in the C<$attr> hashref. +be copied too. To turn this behaviour off, pass C<< cascade_copy => 0 >> +in the C<$attr> hashref. The behaviour defaults to C<< cascade_copy => 1 >> for C relationships. @@ -137,7 +138,7 @@ relationships. By default, DBIx::Class cascades deletes across C, C and C relationships. You can disable this -behaviour on a per-relationship basis by supplying +behaviour on a per-relationship basis by supplying C<< cascade_delete => 0 >> in the relationship attributes. The cascaded operations are performed after the requested delete, @@ -160,14 +161,14 @@ you must arrange to do this yourself. =item on_delete / on_update If you are using L to create SQL for you, you can use these -attributes to explicitly set the desired C or C constraint -type. If not supplied the SQLT parser will attempt to infer the constraint type by +attributes to explicitly set the desired C or C constraint +type. If not supplied the SQLT parser will attempt to infer the constraint type by interrogating the attributes of the B relationship. For any 'multi' -relationship with C<< cascade_delete => 1 >>, the corresponding belongs_to -relationship will be created with an C constraint. For any +relationship with C<< cascade_delete => 1 >>, the corresponding belongs_to +relationship will be created with an C constraint. For any relationship bearing C<< cascade_copy => 1 >> the resulting belongs_to constraint will be C. If you wish to disable this autodetection, and just -use the RDBMS' default constraint type, pass C<< on_delete => undef >> or +use the RDBMS' default constraint type, pass C<< on_delete => undef >> or C<< on_delete => '' >>, and the same for C respectively. =item is_deferrable @@ -305,7 +306,7 @@ sub search_related { ( $objects_rs ) = $rs->search_related_rs('relname', $cond, $attrs); -This method works exactly the same as search_related, except that +This method works exactly the same as search_related, except that it guarantees a resultset, even in list context. =cut @@ -335,9 +336,9 @@ sub count_related { my $new_obj = $obj->new_related('relname', \%col_data); Create a new item of the related foreign class. If called on a -L object, it will magically -set any foreign key columns of the new object to the related primary -key columns of the source object for you. The newly created item will +L object, it will magically +set any foreign key columns of the new object to the related primary +key columns of the source object for you. The newly created item will not be saved into your storage until you call L on it. @@ -532,7 +533,7 @@ B relationships.> =back my $actor = $schema->resultset('Actor')->find(1); - my @roles = $schema->resultset('Role')->search({ role => + my @roles = $schema->resultset('Role')->search({ role => { '-in' => ['Fred', 'Barney'] } } ); $actor->set_roles(\@roles); diff --git a/lib/DBIx/Class/Relationship/BelongsTo.pm b/lib/DBIx/Class/Relationship/BelongsTo.pm index 050c1e4..0f19bd2 100644 --- a/lib/DBIx/Class/Relationship/BelongsTo.pm +++ b/lib/DBIx/Class/Relationship/BelongsTo.pm @@ -7,8 +7,9 @@ package # hide from PAUSE use strict; use warnings; use Try::Tiny; +use namespace::clean; -our %_pod_inherit_config = +our %_pod_inherit_config = ( class_map => { 'DBIx::Class::Relationship::BelongsTo' => 'DBIx::Class::Relationship' } ); @@ -17,7 +18,7 @@ sub belongs_to { my ($class, $rel, $f_class, $cond, $attrs) = @_; # assume a foreign key contraint unless defined otherwise - $attrs->{is_foreign_key_constraint} = 1 + $attrs->{is_foreign_key_constraint} = 1 if not exists $attrs->{is_foreign_key_constraint}; $attrs->{undef_on_null_fk} = 1 if not exists $attrs->{undef_on_null_fk}; diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index d8e651d..21e637d 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -4,8 +4,9 @@ package # hide from PAUSE use strict; use warnings; use Try::Tiny; +use namespace::clean; -our %_pod_inherit_config = +our %_pod_inherit_config = ( class_map => { 'DBIx::Class::Relationship::HasMany' => 'DBIx::Class::Relationship' } ); @@ -15,7 +16,7 @@ sub has_many { unless (ref $cond) { $class->ensure_class_loaded($f_class); - my ($pri, $too_many) = try { $class->_pri_cols } + my ($pri, $too_many) = try { $class->_pri_cols } catch { $class->throw_exception("Can't infer join condition for ${rel} on ${class}: $_"); }; diff --git a/lib/DBIx/Class/Relationship/HasOne.pm b/lib/DBIx/Class/Relationship/HasOne.pm index dddf4e5..3f1160d 100644 --- a/lib/DBIx/Class/Relationship/HasOne.pm +++ b/lib/DBIx/Class/Relationship/HasOne.pm @@ -5,8 +5,9 @@ use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; use Try::Tiny; +use namespace::clean; -our %_pod_inherit_config = +our %_pod_inherit_config = ( class_map => { 'DBIx::Class::Relationship::HasOne' => 'DBIx::Class::Relationship' } ); diff --git a/lib/DBIx/Class/ResultSource.pm b/lib/DBIx/Class/ResultSource.pm index 6ac8538..492720c 100644 --- a/lib/DBIx/Class/ResultSource.pm +++ b/lib/DBIx/Class/ResultSource.pm @@ -9,6 +9,7 @@ use DBIx::Class::ResultSourceHandle; use DBIx::Class::Exception; use Carp::Clan qw/^DBIx::Class/; use Try::Tiny; +use namespace::clean; use base qw/DBIx::Class/; @@ -143,7 +144,7 @@ by supplying an L in the column_info hash. If a column name beginning with a plus sign ('+col1') is provided, the attributes provided will be merged with any existing attributes for the column, with the new attributes taking precedence in the case that an -attribute already exists. Using this without a hashref +attribute already exists. Using this without a hashref (C<< $source->add_columns(qw/+col1 +col2/) >>) is legal, but useless -- it does the same thing it would do without the plus. @@ -175,7 +176,7 @@ the name of the column will be used. This contains the column type. It is automatically filled if you use the L producer, or the -L module. +L module. Currently there is no standard set of values for the data_type. Use whatever your database supports. @@ -899,7 +900,7 @@ clause contents. my $schema = $source->schema(); -Returns the L object that this result source +Returns the L object that this result source belongs to. =head2 storage @@ -1478,7 +1479,7 @@ sub _resolve_prefetch { keys %{$rel_info->{cond}}; my @ord = (ref($rel_info->{attrs}{order_by}) eq 'ARRAY' ? @{$rel_info->{attrs}{order_by}} - + : (defined $rel_info->{attrs}{order_by} ? ($rel_info->{attrs}{order_by}) : ())); @@ -1536,7 +1537,7 @@ sub related_class { =head2 handle -Obtain a new handle to this source. Returns an instance of a +Obtain a new handle to this source. Returns an instance of a L. =cut diff --git a/lib/DBIx/Class/Row.pm b/lib/DBIx/Class/Row.pm index cf4c24c..1faee57 100644 --- a/lib/DBIx/Class/Row.pm +++ b/lib/DBIx/Class/Row.pm @@ -8,6 +8,7 @@ use base qw/DBIx::Class/; use DBIx::Class::Exception; use Scalar::Util (); use Try::Tiny; +use namespace::clean; ### ### Internal method @@ -1115,7 +1116,7 @@ sub inflate_result { if ($source->isa('DBIx::Class::ResultSourceHandle')) { $source = $source_handle->resolve - } + } else { $source_handle = $source->handle } diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index c6974c1..b493d6c 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -10,6 +10,7 @@ use Scalar::Util (); use File::Spec; use Sub::Name (); use Module::Find(); +use namespace::clean; use base qw/DBIx::Class/; @@ -99,7 +100,7 @@ are no matching Result classes like this: If a Result class is found to already have a ResultSet class set using L to some other class, you will be warned like this: - We found ResultSet class '$rs_class' for '$result', but it seems + We found ResultSet class '$rs_class' for '$result', but it seems that you had already set '$result' to use '$rs_set' instead Both of the sub-namespaces are configurable if you don't like the defaults, @@ -320,7 +321,7 @@ need to add C before your load_classes call. If any classes found do not appear to be Result class files, you will get the following warning: - Failed to load $comp_class. Can't find source_name method. Is + Failed to load $comp_class. Can't find source_name method. Is $comp_class really a full DBIC result class? Fix it, move it elsewhere, or make your load_classes call more specific. @@ -480,11 +481,11 @@ is true. =back -An optional sub which you can declare in your own Schema class that will get +An optional sub which you can declare in your own Schema class that will get passed the L object when you deploy the schema via L or L. -For an example of what you can do with this, see +For an example of what you can do with this, see L. Note that sqlt_deploy_hook is called by L, which in turn @@ -656,7 +657,7 @@ sub txn_do { =head2 txn_scope_guard -Runs C on the schema's storage. See +Runs C on the schema's storage. See L. =cut @@ -742,7 +743,7 @@ found in L. Pass this method a resultsource name, and an arrayref of arrayrefs. The arrayrefs should contain a list of column names, -followed by one or many sets of matching data for the given columns. +followed by one or many sets of matching data for the given columns. In void context, C in L is used to insert the data, as this is a fast method. However, insert_bulk currently @@ -762,16 +763,16 @@ e.g. ... ]); -Since wantarray context is basically the same as looping over $rs->create(...) +Since wantarray context is basically the same as looping over $rs->create(...) you won't see any performance benefits and in this case the method is more for convenience. Void context sends the column information directly to storage -using s bulk insert method. So the performance will be much better for +using s bulk insert method. So the performance will be much better for storages that support this method. -Because of this difference in the way void context inserts rows into your +Because of this difference in the way void context inserts rows into your database you need to note how this will effect any loaded components that -override or augment insert. For example if you are using a component such -as L to populate your primary keys you MUST use +override or augment insert. For example if you are using a component such +as L to populate your primary keys you MUST use wantarray context if you want the PKs automatically created. =cut @@ -785,7 +786,7 @@ sub populate { $rs->populate($data); } } else { - $self->throw_exception("$name is not a resultset"); + $self->throw_exception("$name is not a resultset"); } } @@ -813,7 +814,7 @@ sub connection { my ($self, @info) = @_; return $self if !@info && $self->storage; - my ($storage_class, $args) = ref $self->storage_type ? + my ($storage_class, $args) = ref $self->storage_type ? ($self->_normalize_storage_type($self->storage_type),{}) : ($self->storage_type, {}); $storage_class = 'DBIx::Class::Storage'.$storage_class @@ -934,7 +935,7 @@ sub setup_connection_class { =head2 svp_begin -Creates a new savepoint (does nothing outside a transaction). +Creates a new savepoint (does nothing outside a transaction). Equivalent to calling $schema->storage->svp_begin. See L for more information. @@ -951,7 +952,7 @@ sub svp_begin { =head2 svp_release -Releases a savepoint (does nothing outside a transaction). +Releases a savepoint (does nothing outside a transaction). Equivalent to calling $schema->storage->svp_release. See L for more information. @@ -968,7 +969,7 @@ sub svp_release { =head2 svp_rollback -Rollback to a savepoint (does nothing outside a transaction). +Rollback to a savepoint (does nothing outside a transaction). Equivalent to calling $schema->storage->svp_rollback. See L for more information. @@ -1052,8 +1053,8 @@ to have the SQL produced include a C statement for each table created. For quoting purposes supply C and C. -Additionally, the DBIx::Class parser accepts a C parameter as a hash -ref or an array ref, containing a list of source to deploy. If present, then +Additionally, the DBIx::Class parser accepts a C parameter as a hash +ref or an array ref, containing a list of source to deploy. If present, then only the sources listed will get deployed. Furthermore, you can use the C parser parameter to prevent the parser from creating an index for each FK. @@ -1100,7 +1101,7 @@ sub deployment_statements { =back -A convenient shortcut to +A convenient shortcut to C<< $self->storage->create_ddl_dir($self, @args) >>. Creates an SQL file based on the Schema, for each of the specified @@ -1141,7 +1142,7 @@ format. my $filename = $table->ddl_filename($type, $dir, $version, $preversion) In recent versions variables $dir and $version were reversed in order to - bring the signature in line with other Schema/Storage methods. If you + bring the signature in line with other Schema/Storage methods. If you really need to maintain backward compatibility, you can do the following in any overriding methods: @@ -1162,7 +1163,7 @@ sub ddl_filename { =head2 thaw -Provided as the recommended way of thawing schema objects. You can call +Provided as the recommended way of thawing schema objects. You can call C directly if you wish, but the thawed objects will not have a reference to any schema, so are rather useless. @@ -1239,7 +1240,7 @@ sub schema_version { =back -This method is called by L and L to install the found classes into your Schema. You should be using those instead of this one. +This method is called by L and L to install the found classes into your Schema. You should be using those instead of this one. You will only need this method if you have your Result classes in files which are not named after the packages (or all in the same @@ -1304,7 +1305,7 @@ sub unregister_source { =back -As L but should be used if the result class already +As L but should be used if the result class already has a source and you want to register an extra one. =cut @@ -1349,7 +1350,7 @@ sub _register_source { sub _unregister_source { my ($self, $moniker) = @_; - my %reg = %{$self->source_registrations}; + my %reg = %{$self->source_registrations}; my $source = delete $reg{$moniker}; $self->source_registrations(\%reg); diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 8aa9b6a..1e8f39a 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -183,6 +183,7 @@ use base 'DBIx::Class::Schema'; use Carp::Clan qw/^DBIx::Class/; use Time::HiRes qw/gettimeofday/; use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_classdata('_filedata'); __PACKAGE__->mk_classdata('upgrade_directory'); @@ -683,13 +684,13 @@ sub _set_db_version { # This is necessary since there are legitimate cases when upgrades can happen # back to back within the same second. This breaks things since we relay on the # ability to sort by the 'installed' value. The logical choice of an autoinc - # is not possible, as it will break multiple legacy installations. Also it is + # is not possible, as it will break multiple legacy installations. Also it is # not possible to format the string sanely, as the column is a varchar(20). # The 'v' character is added to the front of the string, so that any version # formatted by this new function will sort _after_ any existing 200... strings. my @tm = gettimeofday(); my @dt = gmtime ($tm[0]); - my $o = $vtable->create({ + my $o = $vtable->create({ version => $version, installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f", $dt[5] + 1900, diff --git a/lib/DBIx/Class/Storage.pm b/lib/DBIx/Class/Storage.pm index c4997d5..e8bc77b 100644 --- a/lib/DBIx/Class/Storage.pm +++ b/lib/DBIx/Class/Storage.pm @@ -11,6 +11,7 @@ use Scalar::Util(); use IO::File; use DBIx::Class::Storage::TxnScopeGuard; use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_group_accessors('simple' => qw/debug debugobj schema/); __PACKAGE__->mk_group_accessors('inherited' => 'cursor_class'); @@ -479,8 +480,8 @@ If the value is of the form C<1=/path/name> then the trace output is written to the file C. This environment variable is checked when the storage object is first -created (when you call connect on your schema). So, run-time changes -to this environment variable will not take effect unless you also +created (when you call connect on your schema). So, run-time changes +to this environment variable will not take effect unless you also re-connect on your schema. =head2 DBIX_CLASS_STORAGE_DBI_DEBUG diff --git a/lib/DBIx/Class/Storage/DBI.pm b/lib/DBIx/Class/Storage/DBI.pm index 1320f16..1bc266e 100644 --- a/lib/DBIx/Class/Storage/DBI.pm +++ b/lib/DBIx/Class/Storage/DBI.pm @@ -17,6 +17,7 @@ use Data::Dumper::Concise(); use Sub::Name (); use Try::Tiny; use File::Path (); +use namespace::clean; __PACKAGE__->mk_group_accessors('simple' => qw/_connect_info _dbi_connect_info _dbh _sql_maker _sql_maker_opts _conn_pid @@ -1680,7 +1681,7 @@ sub _execute_array { $sth->finish } catch { - $err = shift unless defined $err + $err = shift unless defined $err }; }; diff --git a/lib/DBIx/Class/Storage/DBI/ADO.pm b/lib/DBIx/Class/Storage/DBI/ADO.pm index 83d2a09..aa9fb5d 100644 --- a/lib/DBIx/Class/Storage/DBI/ADO.pm +++ b/lib/DBIx/Class/Storage/DBI/ADO.pm @@ -3,6 +3,7 @@ package # hide from PAUSE use base 'DBIx::Class::Storage::DBI'; use Try::Tiny; +use namespace::clean; sub _rebless { my $self = shift; diff --git a/lib/DBIx/Class/Storage/DBI/Cursor.pm b/lib/DBIx/Class/Storage/DBI/Cursor.pm index 352ba08..a73eb52 100644 --- a/lib/DBIx/Class/Storage/DBI/Cursor.pm +++ b/lib/DBIx/Class/Storage/DBI/Cursor.pm @@ -6,6 +6,7 @@ use warnings; use base qw/DBIx::Class::Cursor/; use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_group_accessors('simple' => qw/sth/ diff --git a/lib/DBIx/Class/Storage/DBI/InterBase.pm b/lib/DBIx/Class/Storage/DBI/InterBase.pm index 4c4217a..4af0ddd 100644 --- a/lib/DBIx/Class/Storage/DBI/InterBase.pm +++ b/lib/DBIx/Class/Storage/DBI/InterBase.pm @@ -6,6 +6,7 @@ use base qw/DBIx::Class::Storage::DBI/; use mro 'c3'; use List::Util(); use Try::Tiny; +use namespace::clean; =head1 NAME @@ -40,13 +41,13 @@ sub _sequence_fetch { } $self->throw_exception('No sequence to fetch') unless $sequence; - + my ($val) = $self->_get_dbh->selectrow_array( 'SELECT GEN_ID(' . $self->sql_maker->_quote($sequence) . ', 1) FROM rdb$database'); return $val; -} +} sub _dbh_get_autoinc_seq { my ($self, $dbh, $source, $col) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/MSSQL.pm b/lib/DBIx/Class/Storage/DBI/MSSQL.pm index 0b1e57e..ea4b079 100644 --- a/lib/DBIx/Class/Storage/DBI/MSSQL.pm +++ b/lib/DBIx/Class/Storage/DBI/MSSQL.pm @@ -6,6 +6,7 @@ use warnings; use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/; use mro 'c3'; use Try::Tiny; +use namespace::clean; use List::Util(); @@ -162,7 +163,7 @@ sub _select_args_to_query { if ( $sql !~ /^ \s* SELECT \s+ TOP \s+ \d+ \s+ /xi && - scalar $self->_parse_order_by ($attrs->{order_by}) + scalar $self->_parse_order_by ($attrs->{order_by}) ) { $self->throw_exception( 'An ordered subselect encountered - this is not safe! Please see "Ordered Subselects" in DBIx::Class::Storage::DBI::MSSQL @@ -197,7 +198,7 @@ sub _svp_rollback { sub datetime_parser_type { 'DBIx::Class::Storage::DBI::MSSQL::DateTime::Format' -} +} sub sqlt_type { 'SQLServer' } @@ -253,7 +254,7 @@ sub _ping { package # hide from PAUSE DBIx::Class::Storage::DBI::MSSQL::DateTime::Format; -my $datetime_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T +my $datetime_format = '%Y-%m-%d %H:%M:%S.%3N'; # %F %T my $smalldatetime_format = '%Y-%m-%d %H:%M:%S'; my ($datetime_parser, $smalldatetime_parser); diff --git a/lib/DBIx/Class/Storage/DBI/ODBC.pm b/lib/DBIx/Class/Storage/DBI/ODBC.pm index 8f2642c..7a20900 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC.pm @@ -5,6 +5,7 @@ use warnings; use base qw/DBIx::Class::Storage::DBI/; use mro 'c3'; use Try::Tiny; +use namespace::clean; sub _rebless { my ($self) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm index ff60369..694520f 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/Microsoft_SQL_Server.pm @@ -8,6 +8,7 @@ use mro 'c3'; use List::Util(); use Scalar::Util (); use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_group_accessors(simple => qw/ _using_dynamic_cursors diff --git a/lib/DBIx/Class/Storage/DBI/Oracle.pm b/lib/DBIx/Class/Storage/DBI/Oracle.pm index b977ec6..bf50bcc 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle.pm @@ -6,6 +6,7 @@ use warnings; use base qw/DBIx::Class::Storage::DBI/; use mro 'c3'; use Try::Tiny; +use namespace::clean; sub _rebless { my ($self) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 68325bc..933de9d 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -5,6 +5,7 @@ use warnings; use Scope::Guard (); use Context::Preserve (); use Try::Tiny; +use namespace::clean; =head1 NAME @@ -355,7 +356,7 @@ sub with_deferred_fk_checks { my $txn_scope_guard = $self->txn_scope_guard; $self->_do_query('alter session set constraints = deferred'); - + my $sg = Scope::Guard->new(sub { $self->_do_query('alter session set constraints = immediate'); }); diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index 783d334..ae81b73 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -17,6 +17,7 @@ use Scalar::Util 'reftype'; use Hash::Merge; use List::Util qw/min max reduce/; use Try::Tiny; +use namespace::clean; use namespace::clean -except => 'meta'; @@ -38,7 +39,7 @@ that the Pool object should get. $schema->storage_type( ['::DBI::Replicated', {balancer=>'::Random'}] ); $schema->connection(...); -Next, you need to add in the Replicants. Basically this is an array of +Next, you need to add in the Replicants. Basically this is an array of arrayrefs, where each arrayref is database connect information. Think of these arguments as what you'd pass to the 'normal' $schema->connect method. @@ -59,7 +60,7 @@ attribute 'force_pool'. For example: my $RS = $schema->resultset('Source')->search(undef, {force_pool=>'master'}); Now $RS will force everything (both reads and writes) to use whatever was setup -as the master storage. 'master' is hardcoded to always point to the Master, +as the master storage. 'master' is hardcoded to always point to the Master, but you can also use any Replicant name. Please see: L and the replicants attribute for more. @@ -124,7 +125,7 @@ has 'schema' => ( =head2 pool_type -Contains the classname which will instantiate the L object. Defaults +Contains the classname which will instantiate the L object. Defaults to: L. =cut @@ -206,7 +207,7 @@ has 'pool' => ( =head2 balancer -Is a or derived class. This +Is a or derived class. This is a class that takes a pool () =cut @@ -236,7 +237,7 @@ has 'master' => ( =head1 ATTRIBUTES IMPLEMENTING THE DBIx::Storage::DBI INTERFACE -The following methods are delegated all the methods required for the +The following methods are delegated all the methods required for the L interface. =head2 read_handler @@ -253,7 +254,7 @@ has 'read_handler' => ( select select_single columns_info_for - _dbh_columns_info_for + _dbh_columns_info_for _select /], ); @@ -467,7 +468,7 @@ bits get put into the correct places. =cut sub BUILDARGS { - my ($class, $schema, $storage_type_args, @args) = @_; + my ($class, $schema, $storage_type_args, @args) = @_; return { schema=>$schema, @@ -620,7 +621,7 @@ Example: my $reliably = sub { my $name = shift @_; $schema->resultset('User')->create({name=>$name}); - my $user_rs = $schema->resultset('User')->find({name=>$name}); + my $user_rs = $schema->resultset('User')->find({name=>$name}); return $user_rs; }; @@ -918,7 +919,7 @@ sub lag_behind_master { my $self = shift; return max map $_->lag_behind_master, $self->replicants; -} +} =head2 is_replicating @@ -966,7 +967,7 @@ sub _determine_driver { sub _driver_determined { my $self = shift; - + if (@_) { $_->_driver_determined(@_) for $self->all_storages; } @@ -976,19 +977,19 @@ sub _driver_determined { sub _init { my $self = shift; - + $_->_init for $self->all_storages; } sub _run_connection_actions { my $self = shift; - + $_->_run_connection_actions for $self->all_storages; } sub _do_connection_actions { my $self = shift; - + if (@_) { $_->_do_connection_actions(@_) for $self->all_storages; } @@ -1029,7 +1030,7 @@ sub _server_info { if (not $self->_server_info_hash) { my $min_version_info = ( - reduce { $a->[0] < $b->[0] ? $a : $b } + reduce { $a->[0] < $b->[0] ? $a : $b } map [ $numify_ver->($_->{dbms_version}), $_ ], map $_->_server_info, $self->all_storages )->[1]; diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm b/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm index 50f4f8b..f26eb3c 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm @@ -4,8 +4,8 @@ use Moose::Role; use Scalar::Util 'reftype'; requires qw/_query_start/; -use namespace::clean -except => 'meta'; use Try::Tiny; +use namespace::clean -except => 'meta'; =head1 NAME diff --git a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm index 0837554..5d9170d 100644 --- a/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm +++ b/lib/DBIx/Class/Storage/DBI/SQLAnywhere.pm @@ -6,6 +6,7 @@ use base qw/DBIx::Class::Storage::DBI::UniqueIdentifier/; use mro 'c3'; use List::Util (); use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_group_accessors(simple => qw/ _identity @@ -43,7 +44,7 @@ sub insert { my ($source, $to_insert) = @_; my $identity_col = List::Util::first { - $source->column_info($_)->{is_auto_increment} + $source->column_info($_)->{is_auto_increment} } $source->columns; # user might have an identity PK without is_auto_increment diff --git a/lib/DBIx/Class/Storage/DBI/Sybase.pm b/lib/DBIx/Class/Storage/DBI/Sybase.pm index 9b1214c..abf15bf 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase.pm @@ -3,6 +3,7 @@ package DBIx::Class::Storage::DBI::Sybase; use strict; use warnings; use Try::Tiny; +use namespace::clean; use base qw/DBIx::Class::Storage::DBI/; diff --git a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm index 47e0aca..16d204d 100644 --- a/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm +++ b/lib/DBIx/Class/Storage/DBI/Sybase/ASE.pm @@ -14,6 +14,7 @@ use List::Util(); use Sub::Name(); use Data::Dumper::Concise(); use Try::Tiny; +use namespace::clean; __PACKAGE__->mk_group_accessors('simple' => qw/_identity _blob_log_on_update _writer_storage _is_extra_storage diff --git a/lib/DBIx/Class/Storage/TxnScopeGuard.pm b/lib/DBIx/Class/Storage/TxnScopeGuard.pm index 2014e1d..7f93113 100644 --- a/lib/DBIx/Class/Storage/TxnScopeGuard.pm +++ b/lib/DBIx/Class/Storage/TxnScopeGuard.pm @@ -4,6 +4,7 @@ use strict; use warnings; use Carp::Clan qw/^DBIx::Class/; use Try::Tiny; +use namespace::clean; sub new { my ($class, $storage) = @_; @@ -78,7 +79,7 @@ DBIx::Class::Storage::TxnScopeGuard - Scope-based transaction handling =head1 DESCRIPTION An object that behaves much like L, but hardcoded to do the -right thing with transactions in DBIx::Class. +right thing with transactions in DBIx::Class. =head1 METHODS diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index ca25aa2..e4e480a 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -17,6 +17,7 @@ use SQL::Translator::Utils qw(debug normalize_name); use Carp::Clan qw/^SQL::Translator|^DBIx::Class|^Try::Tiny/; use Scalar::Util (); use Try::Tiny; +use namespace::clean; use base qw(Exporter); @@ -64,7 +65,7 @@ sub parse { $dbicschema->throw_exception ("'sources' parameter must be an array or hash ref") unless( $ref eq 'ARRAY' || ref eq 'HASH' ); - # limit monikers to those specified in + # limit monikers to those specified in my $sources; if ($ref eq 'ARRAY') { $sources->{$_} = 1 for (@$limit_sources); @@ -170,7 +171,7 @@ sub parse { # Force the order of @cond to match the order of ->add_columns my $idx; my %other_columns_idx = map {'foreign.'.$_ => ++$idx } $relsource->columns; - my @cond = sort { $other_columns_idx{$a} cmp $other_columns_idx{$b} } keys(%{$rel_info->{cond}}); + my @cond = sort { $other_columns_idx{$a} cmp $other_columns_idx{$b} } keys(%{$rel_info->{cond}}); # Get the key information, mapping off the foreign/self markers my @refkeys = map {/^\w+\.(\w+)$/} @cond;