Revision history for Perl extension DBIx::Class::Schema::Loader
- Fix Pg date/time types with zero fractional second digits
+ - Reduce the number of queries by caching the list of tables
0.07043 2015-05-13
- Fix many_to_many bridges with overlapping foreign keys
sub load {
my $self = shift;
- $self->_load_tables($self->_tables_list);
+ $self->_load_tables($self->__tables_list);
}
=head2 rescan
$self->{schema} = $schema;
$self->_relbuilder->{schema} = $schema;
+ $self->{_cache} = {};
my @created;
- my @current = $self->_tables_list;
+ my @current = $self->__tables_list;
foreach my $table (@current) {
if(!exists $self->_tables->{$table->sql_name}) {
# Returns an array of lower case table names
sub _tables_list { croak "ABSTRACT METHOD" }
+sub __tables_list {
+ my ($self) = @_;
+ return @{$self->{_cache}{_tables_list} ||= [ $self->_tables_list ]};
+}
+
# Execute a constructive DBIC class method, with debug/dump_to_dir hooks.
sub _dbic_stmt {
my $self = shift;
first {
lc($_->name) eq lc($f_table)
&& ((not $f_schema) || lc($_->schema) eq lc($f_schema))
- } $self->_tables_list;
+ } $self->__tables_list;
};
# The table may not be in any database, or it may not have been found by the previous code block for whatever reason.