From: Peter Rabbitson Date: Thu, 16 Jul 2009 04:28:44 +0000 (+0000) Subject: A couple of typos, and general whitespace cleanup (ick) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d4daee7b54e38e4b3d3d0a77759bddc1a4ede6e5;p=dbsrgits%2FDBIx-Class-Historic.git A couple of typos, and general whitespace cleanup (ick) --- diff --git a/lib/DBIx/Class/CDBICompat.pm b/lib/DBIx/Class/CDBICompat.pm index ec063a9..835adfe 100644 --- a/lib/DBIx/Class/CDBICompat.pm +++ b/lib/DBIx/Class/CDBICompat.pm @@ -11,7 +11,7 @@ my @Extra_Modules = qw( DBIx::ContextualFetch Clone ); - + my @didnt_load; for my $module (@Extra_Modules) { push @didnt_load, $module unless eval qq{require $module}; @@ -149,13 +149,13 @@ Relationships between tables (has_a, has_many...) must be delcared after all tab package Foo; use base qw(Class::DBI); - + Foo->table("foo"); Foo->columns( All => qw(this that bar) ); package Bar; use base qw(Class::DBI); - + Bar->table("bar"); Bar->columns( All => qw(up down) ); diff --git a/lib/DBIx/Class/CDBICompat/ColumnCase.pm b/lib/DBIx/Class/CDBICompat/ColumnCase.pm index d6db87b..eb4b0c0 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnCase.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnCase.pm @@ -16,10 +16,10 @@ sub add_columns { sub has_a { my($self, $col, @rest) = @_; - + $self->_declare_has_a(lc $col, @rest); $self->_mk_inflated_column_accessor($col); - + return 1; } diff --git a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm index cbc1124..3a026b2 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnGroups.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnGroups.pm @@ -73,7 +73,7 @@ sub _register_column_group { sub _has_custom_accessor { my($class, $name) = @_; - + no strict 'refs'; my $existing_accessor = *{$class .'::'. $name}{CODE}; return $existing_accessor && !$our_accessors{$existing_accessor}; @@ -90,7 +90,7 @@ sub _register_column_group { my $fullname = join '::', $class, $name; *$fullname = Sub::Name::subname $fullname, $accessor; } - + $our_accessors{$accessor}++; return 1; @@ -120,7 +120,7 @@ sub _mk_group_accessors { # warn " $field $alias\n"; { no strict 'refs'; - + $class->_deploy_accessor($name, $accessor); $class->_deploy_accessor($alias, $accessor); } diff --git a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm index 7b81f09..291db64 100644 --- a/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm +++ b/lib/DBIx/Class/CDBICompat/ColumnsAsHash.pm @@ -39,16 +39,16 @@ sub inflate_result { my $class = shift; my $new = $class->next::method(@_); - + $new->_make_columns_as_hash; - + return $new; } sub _make_columns_as_hash { my $self = shift; - + for my $col ($self->columns) { if( exists $self->{$col} ) { warn "Skipping mapping $col to a hash key because it exists"; diff --git a/lib/DBIx/Class/CDBICompat/Copy.pm b/lib/DBIx/Class/CDBICompat/Copy.pm index ed42d95..ffd5381 100644 --- a/lib/DBIx/Class/CDBICompat/Copy.pm +++ b/lib/DBIx/Class/CDBICompat/Copy.pm @@ -25,7 +25,7 @@ Emulates C<copy($new_id)>>. sub copy { my($self, $arg) = @_; return $self->next::method($arg) if ref $arg; - + my @primary_columns = $self->primary_columns; croak("Need hash-ref to edit copied column values") if @primary_columns > 1; diff --git a/lib/DBIx/Class/CDBICompat/ImaDBI.pm b/lib/DBIx/Class/CDBICompat/ImaDBI.pm index db844e8..49fc1e0 100644 --- a/lib/DBIx/Class/CDBICompat/ImaDBI.pm +++ b/lib/DBIx/Class/CDBICompat/ImaDBI.pm @@ -59,7 +59,7 @@ __PACKAGE__->mk_classdata('_transform_sql_handlers' => $rel_obj->{cond}, $to, $from) ); return $join; } - + } ); sub db_Main { @@ -115,7 +115,7 @@ sub sth_to_objects { sub transform_sql { my ($class, $sql, @args) = @_; - + my $tclass = $class->sql_transformer_class; $class->ensure_class_loaded($tclass); my $t = $tclass->new($class, $sql, @args); diff --git a/lib/DBIx/Class/CDBICompat/Iterator.pm b/lib/DBIx/Class/CDBICompat/Iterator.pm index 80e788c..3e93154 100644 --- a/lib/DBIx/Class/CDBICompat/Iterator.pm +++ b/lib/DBIx/Class/CDBICompat/Iterator.pm @@ -25,7 +25,7 @@ The CDBI iterator returns true if there were any results, false otherwise. The sub _init_result_source_instance { my $class = shift; - + my $table = $class->next::method(@_); $table->resultset_class("DBIx::Class::CDBICompat::Iterator::ResultSet"); diff --git a/lib/DBIx/Class/CDBICompat/LazyLoading.pm b/lib/DBIx/Class/CDBICompat/LazyLoading.pm index e07579a..0817ef2 100644 --- a/lib/DBIx/Class/CDBICompat/LazyLoading.pm +++ b/lib/DBIx/Class/CDBICompat/LazyLoading.pm @@ -16,12 +16,12 @@ sub resultset_instance { # request in case the database modifies the new value (say, via a trigger) sub update { my $self = shift; - + my @dirty_columns = keys %{$self->{_dirty_columns}}; - + my $ret = $self->next::method(@_); $self->_clear_column_data(@dirty_columns); - + return $ret; } @@ -30,12 +30,12 @@ sub update { sub create { my $class = shift; my($data) = @_; - + my @columns = keys %$data; - + my $obj = $class->next::method(@_); return $obj unless defined $obj; - + my %primary_cols = map { $_ => 1 } $class->primary_columns; my @data_cols = grep !$primary_cols{$_}, @columns; $obj->_clear_column_data(@data_cols); @@ -46,7 +46,7 @@ sub create { sub _clear_column_data { my $self = shift; - + delete $self->{_column_data}{$_} for @_; delete $self->{_inflated_column}{$_} for @_; } @@ -71,7 +71,7 @@ sub copy { for my $col ($self->primary_columns) { $changes->{$col} = undef unless exists $changes->{$col}; } - + return $self->next::method($changes); } diff --git a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm index a461a13..f05eff7 100644 --- a/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm +++ b/lib/DBIx/Class/CDBICompat/LiveObjectIndex.pm @@ -20,9 +20,9 @@ __PACKAGE__->mk_classdata('__nocache' => 0); sub nocache { my $class = shift; - + return $class->__nocache(@_) if @_; - + return 1 if $Class::DBI::Weaken_Is_Available == 0; return $class->__nocache; } @@ -74,9 +74,9 @@ sub insert { sub inflate_result { my ($class, @rest) = @_; my $new = $class->next::method(@rest); - + return $new if $new->nocache; - + if (my $key = $new->ID) { #warn "Key $key"; my $live = $class->live_object_index; diff --git a/lib/DBIx/Class/CDBICompat/Relationship.pm b/lib/DBIx/Class/CDBICompat/Relationship.pm index 5d71924..b0c10fa 100644 --- a/lib/DBIx/Class/CDBICompat/Relationship.pm +++ b/lib/DBIx/Class/CDBICompat/Relationship.pm @@ -25,7 +25,7 @@ my %method2key = ( sub new { my($class, $args) = @_; - + return bless $args, $class; } @@ -34,7 +34,7 @@ for my $method (keys %method2key) { my $code = sub { $_[0]->{$key}; }; - + no strict 'refs'; *{$method} = Sub::Name::subname $method, $code; } diff --git a/lib/DBIx/Class/CDBICompat/Relationships.pm b/lib/DBIx/Class/CDBICompat/Relationships.pm index 7572870..58b29e0 100644 --- a/lib/DBIx/Class/CDBICompat/Relationships.pm +++ b/lib/DBIx/Class/CDBICompat/Relationships.pm @@ -24,10 +24,10 @@ Emulate C, C, C and C. sub has_a { my($self, $col, @rest) = @_; - + $self->_declare_has_a($col, @rest); $self->_mk_inflated_column_accessor($col); - + return 1; } @@ -37,7 +37,7 @@ sub _declare_has_a { $self->throw_exception( "No such column ${col}" ) unless $self->has_column($col); $self->ensure_class_loaded($f_class); - + my $rel_info; if ($args{'inflate'} || $args{'deflate'}) { # Non-database has_a @@ -50,7 +50,7 @@ sub _declare_has_a { $args{'deflate'} = sub { shift->$meth; }; } $self->inflate_column($col, \%args); - + $rel_info = { class => $f_class }; @@ -59,9 +59,9 @@ sub _declare_has_a { $self->belongs_to($col, $f_class); $rel_info = $self->result_source_instance->relationship_info($col); } - + $rel_info->{args} = \%args; - + $self->_extend_meta( has_a => $col, $rel_info @@ -72,7 +72,7 @@ sub _declare_has_a { sub _mk_inflated_column_accessor { my($class, $col) = @_; - + return $class->mk_group_accessors('inflated_column' => $col); } @@ -137,7 +137,7 @@ sub has_many { sub might_have { my ($class, $rel, $f_class, @columns) = @_; - + my $ret; if (ref $columns[0] || !defined $columns[0]) { $ret = $class->next::method($rel, $f_class, @columns); @@ -153,7 +153,7 @@ sub might_have { might_have => $rel, $rel_info ); - + return $ret; } diff --git a/lib/DBIx/Class/CDBICompat/Retrieve.pm b/lib/DBIx/Class/CDBICompat/Retrieve.pm index e701cfc..34be5f3 100644 --- a/lib/DBIx/Class/CDBICompat/Retrieve.pm +++ b/lib/DBIx/Class/CDBICompat/Retrieve.pm @@ -74,7 +74,7 @@ sub construct { my $class = shift; my $obj = $class->resultset_instance->new_result(@_); $obj->in_storage(1); - + return $obj; } diff --git a/lib/DBIx/Class/CDBICompat/TempColumns.pm b/lib/DBIx/Class/CDBICompat/TempColumns.pm index f5b60d4..428719e 100644 --- a/lib/DBIx/Class/CDBICompat/TempColumns.pm +++ b/lib/DBIx/Class/CDBICompat/TempColumns.pm @@ -11,7 +11,7 @@ __PACKAGE__->mk_classdata('_temp_columns' => { }); sub _add_column_group { my ($class, $group, @cols) = @_; - + return $class->next::method($group, @cols) unless $group eq 'TEMP'; my %new_cols = map { $_ => 1 } @cols; @@ -61,11 +61,11 @@ sub find_column { sub set { my($self, %data) = @_; - + my $temp_data = $self->_extract_temp_data(\%data); - + $self->set_temp($_, $temp_data->{$_}) for keys %$temp_data; - + return $self->next::method(%data); } diff --git a/lib/DBIx/Class/DB.pm b/lib/DBIx/Class/DB.pm index 57381d0..93e4472 100644 --- a/lib/DBIx/Class/DB.pm +++ b/lib/DBIx/Class/DB.pm @@ -174,7 +174,7 @@ sub _maybe_attach_source_to_schema { sub result_source_instance { my $class = shift; $class = ref $class || $class; - + if (@_) { my $source = $_[0]; $class->_result_source_instance([$source, $class]); diff --git a/lib/DBIx/Class/Exception.pm b/lib/DBIx/Class/Exception.pm index 85c08b2..e8e9ff7 100644 --- a/lib/DBIx/Class/Exception.pm +++ b/lib/DBIx/Class/Exception.pm @@ -61,7 +61,7 @@ sub throw { else { $msg = Carp::longmess($msg); } - + my $self = { msg => $msg }; bless $self => $class; diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index fbdccbc..cf5e28c 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -40,13 +40,13 @@ use inflate_datetime or inflate_date: __PACKAGE__->add_columns( starts_when => { data_type => 'varchar', inflate_datetime => 1 } ); - + __PACKAGE__->add_columns( starts_when => { data_type => 'varchar', inflate_date => 1 } ); It's also possible to explicitly skip inflation: - + __PACKAGE__->add_columns( starts_when => { data_type => 'datetime', inflate_datetime => 0 } ); @@ -86,7 +86,7 @@ directly called by end users. In the case of an invalid date, L will throw an exception. To bypass these exceptions and just have the inflation return undef, use the C option in the column info: - + "broken_date", { data_type => "datetime", @@ -135,7 +135,7 @@ sub register_column { "please put it directly into the '$column' column definition."; $locale = $info->{extra}{locale}; } - + $locale = $info->{locale} if defined $info->{locale}; $timezone = $info->{timezone} if defined $info->{timezone}; diff --git a/lib/DBIx/Class/InflateColumn/File.pm b/lib/DBIx/Class/InflateColumn/File.pm index 78e316b..1901187 100644 --- a/lib/DBIx/Class/InflateColumn/File.pm +++ b/lib/DBIx/Class/InflateColumn/File.pm @@ -58,7 +58,7 @@ sub delete { sub insert { my $self = shift; - + # cache our file columns so we can write them to the fs # -after- we have a PK my %file_column; @@ -114,7 +114,7 @@ DBIx::Class::InflateColumn::File - map files from the Database to the filesyste In your L table class: __PACKAGE__->load_components( "PK::Auto", "InflateColumn::File", "Core" ); - + # define your columns __PACKAGE__->add_columns( "id", @@ -136,7 +136,7 @@ In your L table class: size => 255, }, ); - + In your L class: @@ -152,15 +152,15 @@ name as name. body => '....' }); $c->stash->{entry}=$entry; - + And Place the following in your TT template - + Article Subject: [% entry.subject %] Uploaded File: File Body: [% entry.body %] - + The file will be stored on the filesystem for later retrieval. Calling delete on your resultset will delete the file from the filesystem. Retrevial of the record automatically inflates the column back to the set hash with the diff --git a/lib/DBIx/Class/Ordered.pm b/lib/DBIx/Class/Ordered.pm index 6303b44..9f2e253 100644 --- a/lib/DBIx/Class/Ordered.pm +++ b/lib/DBIx/Class/Ordered.pm @@ -60,20 +60,20 @@ That's it, now you can change the position of your objects. #!/use/bin/perl use My::Item; - + my $item = My::Item->create({ name=>'Matt S. Trout' }); # If using grouping_column: my $item = My::Item->create({ name=>'Matt S. Trout', group_id=>1 }); - + my $rs = $item->siblings(); my @siblings = $item->siblings(); - + my $sibling; $sibling = $item->first_sibling(); $sibling = $item->last_sibling(); $sibling = $item->previous_sibling(); $sibling = $item->next_sibling(); - + $item->move_previous(); $item->move_next(); $item->move_first(); diff --git a/lib/DBIx/Class/PK.pm b/lib/DBIx/Class/PK.pm index f282924..5be4833 100644 --- a/lib/DBIx/Class/PK.pm +++ b/lib/DBIx/Class/PK.pm @@ -42,16 +42,16 @@ sub discard_changes { my ($self, $attrs) = @_; delete $self->{_dirty_columns}; return unless $self->in_storage; # Don't reload if we aren't real! - + if( my $current_storage = $self->get_from_storage($attrs)) { - + # Set $self to the current. %$self = %$current_storage; - + # Avoid a possible infinite loop with # sub DESTROY { $_[0]->discard_changes } bless $current_storage, 'Do::Not::Exist'; - + return $self; } else { $self->in_storage(0); diff --git a/lib/DBIx/Class/Relationship.pm b/lib/DBIx/Class/Relationship.pm index 67e4f68..e3b812b 100644 --- a/lib/DBIx/Class/Relationship.pm +++ b/lib/DBIx/Class/Relationship.pm @@ -106,7 +106,7 @@ L. All helper methods are called similar to the following template: __PACKAGE__->$method_name('relname', 'Foreign::Class', \%cond | \@cond, \%attrs); - + Both C<$cond> and C<$attrs> are optional. Pass C for C<$cond> if you want to use the default value for it, but still want to set C<\%attrs>. @@ -297,7 +297,7 @@ OR condition. 'My::DBIC::Schema::Book', { 'foreign.author_id' => 'self.id' }, ); - + # OR (similar result, assuming related_class is storing our PK, in "author") # (the "author" is guessed at from "Author" in the class namespace) My::DBIC::Schema::Author->has_many( diff --git a/lib/DBIx/Class/Relationship/Base.pm b/lib/DBIx/Class/Relationship/Base.pm index 8f02598..7cd3214 100644 --- a/lib/DBIx/Class/Relationship/Base.pm +++ b/lib/DBIx/Class/Relationship/Base.pm @@ -83,18 +83,18 @@ command immediately before C. An arrayref containing a list of accessors in the foreign class to create in the main class. If, for example, you do the following: - + MyDB::Schema::CD->might_have(liner_notes => 'MyDB::Schema::LinerNotes', undef, { proxy => [ qw/notes/ ], }); - + Then, assuming MyDB::Schema::LinerNotes has an accessor named notes, you can do: my $cd = MyDB::Schema::CD->find(1); $cd->notes('Notes go here'); # set notes -- LinerNotes object is # created if it doesn't exist - + =item accessor Specifies the type of accessor that should be created for the relationship. @@ -179,7 +179,7 @@ sub related_resultset { my $rel_info = $self->relationship_info($rel); $self->throw_exception( "No such relationship ${rel}" ) unless $rel_info; - + return $self->{related_resultsets}{$rel} ||= do { my $attrs = (@_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}); $attrs = { %{$rel_info->{attrs} || {}}, %$attrs }; diff --git a/lib/DBIx/Class/Relationship/HasMany.pm b/lib/DBIx/Class/Relationship/HasMany.pm index 936238a..d74a9a4 100644 --- a/lib/DBIx/Class/Relationship/HasMany.pm +++ b/lib/DBIx/Class/Relationship/HasMany.pm @@ -40,7 +40,7 @@ sub has_many { $class->throw_exception( "No such column ${f_key} on foreign class ${f_class} ($guess)" ) if $f_class_loaded && !$f_class->has_column($f_key); - + $cond = { "foreign.${f_key}" => "self.${pri}" }; } diff --git a/lib/DBIx/Class/ResultSetColumn.pm b/lib/DBIx/Class/ResultSetColumn.pm index 1596e53..4f48d33 100644 --- a/lib/DBIx/Class/ResultSetColumn.pm +++ b/lib/DBIx/Class/ResultSetColumn.pm @@ -338,7 +338,7 @@ value. Produces the following SQL: sub func { my ($self,$function) = @_; my $cursor = $self->func_rs($function)->cursor; - + if( wantarray ) { return map { $_->[ 0 ] } $cursor->all; } @@ -373,9 +373,9 @@ sub func_rs { =head2 throw_exception See L for details. - + =cut - + sub throw_exception { my $self=shift; if (ref $self && $self->{_parent_resultset}) { diff --git a/lib/DBIx/Class/ResultSourceHandle.pm b/lib/DBIx/Class/ResultSourceHandle.pm index 7531954..4a402e9 100644 --- a/lib/DBIx/Class/ResultSourceHandle.pm +++ b/lib/DBIx/Class/ResultSourceHandle.pm @@ -77,7 +77,7 @@ sub STORABLE_freeze { my ($self, $cloning) = @_; my $to_serialize = { %$self }; - + my $class = $self->schema->class($self->source_moniker); $to_serialize->{schema} = $class; return (Storable::freeze($to_serialize)); diff --git a/lib/DBIx/Class/ResultSourceProxy/Table.pm b/lib/DBIx/Class/ResultSourceProxy/Table.pm index 5cfe4f3..a983ce1 100644 --- a/lib/DBIx/Class/ResultSourceProxy/Table.pm +++ b/lib/DBIx/Class/ResultSourceProxy/Table.pm @@ -67,7 +67,7 @@ Adds columns to the current class and creates accessors for them. =head2 table __PACKAGE__->table('tbl_name'); - + Gets or sets the table name. =cut diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index bf2d76e..5ec6020 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -755,7 +755,7 @@ i.e., [ 2, 'Indie Band' ], ... ]); - + 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 @@ -806,10 +806,10 @@ Overload C to change the behaviour of C. sub connection { my ($self, @info) = @_; return $self if !@info && $self->storage; - + 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 if $storage_class =~ m/^::/; eval "require ${storage_class};"; @@ -1146,7 +1146,7 @@ sub ddl_filename { $filename =~ s/::/-/g; $filename = File::Spec->catfile($dir, "$filename-$version-$type.sql"); $filename =~ s/$version/$preversion-$version/ if($preversion); - + return $filename; } @@ -1372,7 +1372,7 @@ more information. $self->throw_exception ("No arguments to load_classes and couldn't load ${base} ($@)") if $@; - + if ($self eq $target) { # Pathological case, largely caused by the docs on early C::M::DBIC::Plain foreach my $moniker ($self->sources) { @@ -1385,14 +1385,14 @@ more information. $self->connection(@info); return $self; } - + my $schema = $self->compose_namespace($target, $base); { no strict 'refs'; my $name = join '::', $target, 'schema'; *$name = Sub::Name::subname $name, sub { $schema }; } - + $schema->connection(@info); foreach my $moniker ($schema->sources) { my $source = $schema->source($moniker); diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 49baa57..0874167 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -308,7 +308,7 @@ sub upgrade # here to be sure. # XXX - just fix it $self->storage->sqlt_type; - + my $upgrade_file = $self->ddl_filename( $self->storage->sqlt_type, $self->schema_version, diff --git a/lib/DBIx/Class/StartupCheck.pm b/lib/DBIx/Class/StartupCheck.pm index 6a34606..30bc51f 100644 --- a/lib/DBIx/Class/StartupCheck.pm +++ b/lib/DBIx/Class/StartupCheck.pm @@ -7,7 +7,7 @@ DBIx::Class::StartupCheck - Run environment checks on startup =head1 SYNOPSIS use DBIx::Class::StartupCheck; - + =head1 DESCRIPTION This module used to check for, and if necessary issue a warning for, a diff --git a/lib/DBIx/Class/Storage/DBI/DB2.pm b/lib/DBIx/Class/Storage/DBI/DB2.pm index 7b48741..b36ab13 100644 --- a/lib/DBIx/Class/Storage/DBI/DB2.pm +++ b/lib/DBIx/Class/Storage/DBI/DB2.pm @@ -21,11 +21,11 @@ sub datetime_parser_type { "DateTime::Format::DB2"; } sub _sql_maker_opts { my ( $self, $opts ) = @_; - + if ( $opts ) { $self->{_sql_maker_opts} = { %$opts }; } - + return { limit_dialect => 'RowNumberOver', %{$self->{_sql_maker_opts}||{}} }; } diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm b/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm index c951903..1b1909a 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/ACCESS.pm @@ -40,11 +40,11 @@ sub last_insert_id { sub bind_attribute_by_data_type { my $self = shift; - + my ( $data_type ) = @_; - + return { TYPE => $data_type } if $data_type == DBI::SQL_LONGVARCHAR; - + return; } diff --git a/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm b/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm index 33a4e7a..1bed7f5 100644 --- a/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm +++ b/lib/DBIx/Class/Storage/DBI/ODBC/DB2_400_SQL.pm @@ -23,7 +23,7 @@ sub _dbh_last_insert_id { sub _sql_maker_opts { my ($self) = @_; - + $self->dbh_do(sub { my ($self, $dbh) = @_; diff --git a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm index 2f35cbd..ac1a3a1 100644 --- a/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm +++ b/lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm @@ -139,7 +139,7 @@ Returns the sequence name for an autoincrement column sub get_autoinc_seq { my ($self, $source, $col) = @_; - + $self->dbh_do('_dbh_get_autoinc_seq', $source, $col); } @@ -210,7 +210,7 @@ sub connect_call_datetime_setup { sub _svp_begin { my ($self, $name) = @_; - + $self->dbh->do("SAVEPOINT $name"); } diff --git a/lib/DBIx/Class/Storage/DBI/Pg.pm b/lib/DBIx/Class/Storage/DBI/Pg.pm index 3fcd550..3935a49 100644 --- a/lib/DBIx/Class/Storage/DBI/Pg.pm +++ b/lib/DBIx/Class/Storage/DBI/Pg.pm @@ -50,7 +50,7 @@ sub _dbh_get_autoinc_seq { sub get_autoinc_seq { my ($self,$source,$col) = @_; - + my @pri = $source->primary_columns; my ($schema,$table) = $source->name =~ /^(.+)\.(.+)$/ ? ($1,$2) : (undef,$source->name); @@ -71,7 +71,7 @@ sub bind_attribute_by_data_type { bytea => { pg_type => DBD::Pg::PG_BYTEA }, blob => { pg_type => DBD::Pg::PG_BYTEA }, }; - + if( defined $bind_attributes->{$data_type} ) { return $bind_attributes->{$data_type}; } diff --git a/lib/DBIx/Class/Storage/DBI/Replicated.pm b/lib/DBIx/Class/Storage/DBI/Replicated.pm index c583c6e..ea16af9 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated.pm @@ -2,10 +2,10 @@ package DBIx::Class::Storage::DBI::Replicated; BEGIN { use Carp::Clan qw/^DBIx::Class/; - + ## Modules required for Replication support not required for general DBIC ## use, so we explicitly test for these. - + my %replication_required = ( 'Moose' => '0.77', 'MooseX::AttributeHelpers' => '0.12', @@ -13,17 +13,17 @@ BEGIN { 'namespace::clean' => '0.11', 'Hash::Merge' => '0.11' ); - + my @didnt_load; - + for my $module (keys %replication_required) { eval "use $module $replication_required{$module}"; push @didnt_load, "$module $replication_required{$module}" if $@; } - + croak("@{[ join ', ', @didnt_load ]} are missing and are required for Replication") - if @didnt_load; + if @didnt_load; } use Moose; @@ -49,29 +49,29 @@ storage type, add some replicated (readonly) databases, and perform reporting tasks. You should set the 'storage_type attribute to a replicated type. You should -also defined you arguments, such as which balancer you want and any arguments +also define your arguments, such as which balancer you want and any arguments that the Pool object should get. $schema->storage_type( ['::DBI::Replicated', {balancer=>'::Random'}] ); - + 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. - + $schema->storage->connect_replicants( [$dsn1, $user, $pass, \%opts], [$dsn2, $user, $pass, \%opts], [$dsn3, $user, $pass, \%opts], ); - + Now, just use the $schema as you normally would. Automatically all reads will be delegated to the replicants, while writes to the master. $schema->resultset('Source')->search({name=>'etc'}); - + You can force a given query to use a particular storage using the search 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 @@ -86,7 +86,7 @@ same time, since your replicants will often lag a bit behind the master. See L for more help and walkthroughs. - + =head1 DESCRIPTION Warning: This class is marked BETA. This has been running a production @@ -125,7 +125,7 @@ Replicated Storage has additional requirements not currently part of L 0.10 namespace::clean => 0.11 Hash::Merge => 0.11 - + You will need to install these modules manually via CPAN or make them part of the Makefile for your distribution. @@ -411,7 +411,7 @@ bits get put into the correct places. sub BUILDARGS { my ($class, $schema, $storage_type_args, @args) = @_; - + return { schema=>$schema, %$storage_type_args, @@ -568,24 +568,24 @@ inserted something and need to get a resultset including it, etc. sub execute_reliably { my ($self, $coderef, @args) = @_; - + unless( ref $coderef eq 'CODE') { $self->throw_exception('Second argument must be a coderef'); } - + ##Get copy of master storage my $master = $self->master; - + ##Get whatever the current read hander is my $current = $self->read_handler; - + ##Set the read handler to master $self->read_handler($master); - + ## do whatever the caller needs my @result; my $want_array = wantarray; - + eval { if($want_array) { @result = $coderef->(@args); @@ -595,13 +595,13 @@ sub execute_reliably { $coderef->(@args); } }; - + ##Reset to the original state $self->read_handler($current); - + ##Exception testing has to come last, otherwise you might leave the ##read_handler set to master. - + if($@) { $self->throw_exception("coderef returned an error: $@"); } else { @@ -613,14 +613,14 @@ sub execute_reliably { Sets the current $schema to be 'reliable', that is all queries, both read and write are sent to the master - + =cut sub set_reliable_storage { my $self = shift @_; my $schema = $self->schema; my $write_handler = $self->schema->storage->write_handler; - + $schema->storage->read_handler($write_handler); } @@ -628,14 +628,14 @@ sub set_reliable_storage { Sets the current $schema to be use the for all reads, while all writea are sent to the master only - + =cut sub set_balanced_storage { my $self = shift @_; my $schema = $self->schema; my $balanced_handler = $self->schema->storage->balancer; - + $schema->storage->read_handler($balanced_handler); } @@ -811,7 +811,7 @@ sub cursor_class { } $self->master->cursor_class; } - + =head1 GOTCHAS Due to the fact that replicants can lag behind a master, you must take care to @@ -845,7 +845,7 @@ using the Schema clone method. my $new_schema = $schema->clone; $new_schema->set_reliable_storage; - + ## $new_schema will use only the Master storage for all reads/writes while ## the $schema object will use replicated storage. diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm index d7a8769..0925dec 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm @@ -14,7 +14,7 @@ DBIx::Class::Storage::DBI::Replicated::Balancer - A Software Load Balancer =head1 SYNOPSIS This role is used internally by L. - + =head1 DESCRIPTION Given a pool (L) of replicated diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm index b230346..d40fb63 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/First.pm @@ -12,7 +12,7 @@ DBIx::Class::Storage::DBI::Replicated::Balancer::First - Just get the First Bala This class is used internally by L. You shouldn't need to create instances of this class. - + =head1 DESCRIPTION Given a pool (L) of replicated diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm index f23db75..1fc7b94 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Balancer/Random.pm @@ -13,7 +13,7 @@ DBIx::Class::Storage::DBI::Replicated::Balancer::Random - A 'random' Balancer This class is used internally by L. You shouldn't need to create instances of this class. - + =head1 DESCRIPTION Given a pool (L) of replicated diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod b/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod index d31417c..c48f2a1 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Introduction.pod @@ -69,7 +69,7 @@ and canonical option. =head1 PARTS OF REPLICATED STORAGE A replicated storage contains several parts. First, there is the replicated -storage itself (L). A replicated storage takes a pool of replicants (L) and a software balancer (L). The balancer does the job of splitting up all the read traffic amongst each diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm index e22f0a9..79f1a20 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Pool.pm @@ -18,7 +18,7 @@ DBIx::Class::Storage::DBI::Replicated::Pool - Manage a pool of replicants This class is used internally by L. You shouldn't need to create instances of this class. - + =head1 DESCRIPTION In a replicated storage type, there is at least one replicant to handle the @@ -89,11 +89,11 @@ A hashref of replicant, with the key being the dsn and the value returning the actual replicant storage. For example if the $dsn element is something like: "dbi:SQLite:dbname=dbfile" - + You could access the specific replicant via: $schema->storage->replicants->{'dbname=dbfile'} - + This attributes also supports the following helper methods: =over 4 @@ -129,11 +129,11 @@ has 'replicants' => ( default=>sub {{}}, provides => { 'set' => 'set_replicant', - 'get' => 'get_replicant', + 'get' => 'get_replicant', 'empty' => 'has_replicants', 'count' => 'num_replicants', 'delete' => 'delete_replicant', - 'values' => 'all_replicant_storages', + 'values' => 'all_replicant_storages', }, ); @@ -152,7 +152,7 @@ and store it in the L attribute. sub connect_replicants { my $self = shift @_; my $schema = shift @_; - + my @newly_created = (); foreach my $connect_info (@_) { $connect_info = [ $connect_info ] @@ -170,7 +170,7 @@ sub connect_replicants { $self->set_replicant( $key => $replicant); push @newly_created, $replicant; } - + return @newly_created; } diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm b/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm index 9c9f1c2..2e9f9dd 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm @@ -14,7 +14,7 @@ DBIx::Class::Storage::DBI::Replicated::Replicant - A replicated DBI Storage Role =head1 SYNOPSIS This class is used internally by L. - + =head1 DESCRIPTION Replicants are DBI Storages that follow a master DBI Storage. Typically this diff --git a/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm b/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm index 405d157..6025739 100644 --- a/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm +++ b/lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm @@ -13,7 +13,7 @@ information in trace output =head1 SYNOPSIS This class is used internally by L. - + =head1 DESCRIPTION This role adds C info to storage debugging output. diff --git a/lib/DBIx/Class/UTF8Columns.pm b/lib/DBIx/Class/UTF8Columns.pm index f060f81..cc18743 100644 --- a/lib/DBIx/Class/UTF8Columns.pm +++ b/lib/DBIx/Class/UTF8Columns.pm @@ -25,7 +25,7 @@ DBIx::Class::UTF8Columns - Force UTF8 (Unicode) flag on columns package Artist; __PACKAGE__->load_components(qw/UTF8Columns Core/); __PACKAGE__->utf8_columns(qw/name description/); - + # then belows return strings with utf8 flag $artist->name; $artist->get_column('description'); diff --git a/lib/SQL/Translator/Parser/DBIx/Class.pm b/lib/SQL/Translator/Parser/DBIx/Class.pm index 0966562..85a1028 100644 --- a/lib/SQL/Translator/Parser/DBIx/Class.pm +++ b/lib/SQL/Translator/Parser/DBIx/Class.pm @@ -337,7 +337,7 @@ from a DBIx::Class::Schema instance ## Standalone use MyApp::Schema; use SQL::Translator; - + my $schema = MyApp::Schema->connect; my $trans = SQL::Translator->new ( parser => 'SQL::Translator::Parser::DBIx::Class', diff --git a/lib/SQL/Translator/Producer/DBIx/Class/File.pm b/lib/SQL/Translator/Producer/DBIx/Class/File.pm index 4132c73..5099a13 100644 --- a/lib/SQL/Translator/Producer/DBIx/Class/File.pm +++ b/lib/SQL/Translator/Producer/DBIx/Class/File.pm @@ -128,7 +128,7 @@ __PACKAGE__->table('${tname}'); $tableextras{$table->name} .= "\n__PACKAGE__->belongs_to('" . $cont->fields->[0]->name . "', '" . "${dbixschema}::" . $cont->reference_table . "');\n"; - + my $other = "\n__PACKAGE__->has_many('" . "get_" . $table->name. "', '" . "${dbixschema}::" . $table->name. "', '" .