1 package DBIx::Class::Schema::Loader::Base;
5 use base qw/Class::Accessor::Fast Class::C3::Componentised/;
7 use Carp::Clan qw/^DBIx::Class/;
8 use DBIx::Class::Schema::Loader::RelBuilder;
9 use Data::Dump qw/ dump /;
14 use Lingua::EN::Inflect::Number qw//;
19 our $VERSION = '0.04999_10';
21 __PACKAGE__->mk_ro_accessors(qw/
28 additional_base_classes
43 default_resultset_class
54 __PACKAGE__->mk_accessors(qw/
60 DBIx::Class::Schema::Loader::Base - Base DBIx::Class::Schema::Loader Implementation.
64 See L<DBIx::Class::Schema::Loader>
68 This is the base class for the storage-specific C<DBIx::Class::Schema::*>
69 classes, and implements the common functionality between them.
71 =head1 CONSTRUCTOR OPTIONS
73 These constructor options are the base options for
74 L<DBIx::Class::Schema::Loader/loader_options>. Available constructor options are:
76 =head2 skip_relationships
78 Skip setting up relationships. The default is to attempt the loading
83 Static schemas (ones dumped to disk) will, by default, use the new-style 0.05XXX
84 relationship names and singularized Results, unless you're overwriting an
85 existing dump made by a 0.04XXX version of L<DBIx::Class::Schema::Loader>, in
86 which case the backward compatible RelBuilder will be activated, and
87 singularization will be turned off.
93 will disable the backward-compatible RelBuilder and use
94 the new-style relationship names along with singularized Results, even when
95 overwriting a dump made with an earlier version.
97 The option also takes a hashref:
99 naming => { relationships => 'v5', results => 'v4' }
107 Latest default style, whatever that happens to be.
111 Version 0.05XXX style.
115 Version 0.04XXX style.
119 Dynamic schemas will always default to the 0.04XXX relationship names and won't
120 singularize Results for backward compatibility, to activate the new RelBuilder
121 and singularization put this in your C<Schema.pm> file:
123 __PACKAGE__->naming('current');
125 Or if you prefer to use 0.05XXX features but insure that nothing breaks in the
126 next major version upgrade:
128 __PACKAGE__->naming('v5');
132 If set to true, each constructive L<DBIx::Class> statement the loader
133 decides to execute will be C<warn>-ed before execution.
137 Set the name of the schema to load (schema in the sense that your database
138 vendor means it). Does not currently support loading more than one schema
143 Only load tables matching regex. Best specified as a qr// regex.
147 Exclude tables matching regex. Best specified as a qr// regex.
151 Overrides the default table name to moniker translation. Can be either
152 a hashref of table keys and moniker values, or a coderef for a translator
153 function taking a single scalar table name argument and returning
154 a scalar moniker. If the hash entry does not exist, or the function
155 returns a false value, the code falls back to default behavior
158 The default behavior is: C<join '', map ucfirst, split /[\W_]+/, lc $table>,
159 which is to say: lowercase everything, split up the table name into chunks
160 anywhere a non-alpha-numeric character occurs, change the case of first letter
161 of each chunk to upper case, and put the chunks back together. Examples:
163 Table Name | Moniker Name
164 ---------------------------
166 luser_group | LuserGroup
167 luser-opts | LuserOpts
169 =head2 inflect_plural
171 Just like L</moniker_map> above (can be hash/code-ref, falls back to default
172 if hash key does not exist or coderef returns false), but acts as a map
173 for pluralizing relationship names. The default behavior is to utilize
174 L<Lingua::EN::Inflect::Number/to_PL>.
176 =head2 inflect_singular
178 As L</inflect_plural> above, but for singularizing relationship names.
179 Default behavior is to utilize L<Lingua::EN::Inflect::Number/to_S>.
181 =head2 schema_base_class
183 Base class for your schema classes. Defaults to 'DBIx::Class::Schema'.
185 =head2 result_base_class
187 Base class for your table classes (aka result classes). Defaults to 'DBIx::Class'.
189 =head2 additional_base_classes
191 List of additional base classes all of your table classes will use.
193 =head2 left_base_classes
195 List of additional base classes all of your table classes will use
196 that need to be leftmost.
198 =head2 additional_classes
200 List of additional classes which all of your table classes will use.
204 List of additional components to be loaded into all of your table
205 classes. A good example would be C<ResultSetManager>.
207 =head2 resultset_components
209 List of additional ResultSet components to be loaded into your table
210 classes. A good example would be C<AlwaysRS>. Component
211 C<ResultSetManager> will be automatically added to the above
212 C<components> list if this option is set.
214 =head2 use_namespaces
216 Generate result class names suitable for
217 L<DBIx::Class::Schema/load_namespaces> and call that instead of
218 L<DBIx::Class::Schema/load_classes>. When using this option you can also
219 specify any of the options for C<load_namespaces> (i.e. C<result_namespace>,
220 C<resultset_namespace>, C<default_resultset_class>), and they will be added
221 to the call (and the generated result class names adjusted appropriately).
223 =head2 dump_directory
225 This option is designed to be a tool to help you transition from this
226 loader to a manually-defined schema when you decide it's time to do so.
228 The value of this option is a perl libdir pathname. Within
229 that directory this module will create a baseline manual
230 L<DBIx::Class::Schema> module set, based on what it creates at runtime
233 The created schema class will have the same classname as the one on
234 which you are setting this option (and the ResultSource classes will be
235 based on this name as well).
237 Normally you wouldn't hard-code this setting in your schema class, as it
238 is meant for one-time manual usage.
240 See L<DBIx::Class::Schema::Loader/dump_to_dir> for examples of the
241 recommended way to access this functionality.
243 =head2 dump_overwrite
245 Deprecated. See L</really_erase_my_files> below, which does *not* mean
246 the same thing as the old C<dump_overwrite> setting from previous releases.
248 =head2 really_erase_my_files
250 Default false. If true, Loader will unconditionally delete any existing
251 files before creating the new ones from scratch when dumping a schema to disk.
253 The default behavior is instead to only replace the top portion of the
254 file, up to and including the final stanza which contains
255 C<# DO NOT MODIFY THIS OR ANYTHING ABOVE!>
256 leaving any customizations you placed after that as they were.
258 When C<really_erase_my_files> is not set, if the output file already exists,
259 but the aforementioned final stanza is not found, or the checksum
260 contained there does not match the generated contents, Loader will
261 croak and not touch the file.
263 You should really be using version control on your schema classes (and all
264 of the rest of your code for that matter). Don't blame me if a bug in this
265 code wipes something out when it shouldn't have, you've been warned.
269 None of these methods are intended for direct invocation by regular
270 users of L<DBIx::Class::Schema::Loader>. Anything you can find here
271 can also be found via standard L<DBIx::Class::Schema> methods somehow.
275 # ensure that a peice of object data is a valid arrayref, creating
276 # an empty one or encapsulating whatever's there.
277 sub _ensure_arrayref {
282 $self->{$_} = [ $self->{$_} ]
283 unless ref $self->{$_} eq 'ARRAY';
289 Constructor for L<DBIx::Class::Schema::Loader::Base>, used internally
290 by L<DBIx::Class::Schema::Loader>.
295 my ( $class, %args ) = @_;
297 my $self = { %args };
299 bless $self => $class;
301 $self->_ensure_arrayref(qw/additional_classes
302 additional_base_classes
308 push(@{$self->{components}}, 'ResultSetManager')
309 if @{$self->{resultset_components}};
311 $self->{monikers} = {};
312 $self->{classes} = {};
314 $self->{schema_class} ||= ( ref $self->{schema} || $self->{schema} );
315 $self->{schema} ||= $self->{schema_class};
317 croak "dump_overwrite is deprecated. Please read the"
318 . " DBIx::Class::Schema::Loader::Base documentation"
319 if $self->{dump_overwrite};
321 $self->{dynamic} = ! $self->{dump_directory};
322 $self->{temp_directory} ||= File::Temp::tempdir( 'dbicXXXX',
327 $self->{dump_directory} ||= $self->{temp_directory};
329 $self->version_to_dump($DBIx::Class::Schema::Loader::VERSION);
331 $self->_check_back_compat;
336 sub _check_back_compat {
339 # dynamic schemas will always be in 0.04006 mode
340 if ($self->dynamic) {
342 my $class = ref $self || $self;
343 require DBIx::Class::Schema::Loader::Compat::v0_040;
344 unshift @{"${class}::ISA"},
345 'DBIx::Class::Schema::Loader::Compat::v0_040';
346 Class::C3::reinitialize;
347 # just in case, though no one is likely to dump a dynamic schema
348 $self->version_to_dump('0.04006');
352 # otherwise check if we need backcompat mode for a static schema
353 my $filename = $self->_get_dump_filename($self->schema_class);
354 return unless -e $filename;
356 open(my $fh, '<', $filename)
357 or croak "Cannot open '$filename' for reading: $!";
360 if (/^# Created by DBIx::Class::Schema::Loader v((\d+)\.(\d+))/) {
362 my $ver = "v${2}_${3}";
364 my $compat_class = "DBIx::Class::Schema::Loader::Compat::${ver}";
365 if ($self->load_optional_class($compat_class)) {
367 my $class = ref $self || $self;
368 unshift @{"${class}::ISA"}, $compat_class;
369 Class::C3::reinitialize;
370 $self->version_to_dump($real_ver);
373 $ver =~ s/\d\z// or last;
381 sub _find_file_in_inc {
382 my ($self, $file) = @_;
384 foreach my $prefix (@INC) {
385 my $fullpath = File::Spec->catfile($prefix, $file);
386 return $fullpath if -f $fullpath
387 and Cwd::abs_path($fullpath) ne
388 Cwd::abs_path(File::Spec->catfile($self->dump_directory, $file)) || '';
395 my ($self, $class) = @_;
397 my $class_path = $class;
398 $class_path =~ s{::}{/}g;
399 $class_path .= '.pm';
404 sub _find_class_in_inc {
405 my ($self, $class) = @_;
407 return $self->_find_file_in_inc($self->_class_path($class));
411 my ($self, $class) = @_;
413 my $real_inc_path = $self->_find_class_in_inc($class);
415 return if !$real_inc_path;
417 # If we make it to here, we loaded an external definition
418 warn qq/# Loaded external class definition for '$class'\n/
421 open(my $fh, '<', $real_inc_path)
422 or croak "Failed to open '$real_inc_path' for reading: $!";
423 $self->_ext_stmt($class,
424 qq|# These lines were loaded from '$real_inc_path' found in \@INC.\n|
425 .qq|# They are now part of the custom portion of this file\n|
426 .qq|# for you to hand-edit. If you do not either delete\n|
427 .qq|# this section or remove that file from \@INC, this section\n|
428 .qq|# will be repeated redundantly when you re-create this\n|
429 .qq|# file again via Loader!\n|
433 $self->_ext_stmt($class, $_);
435 $self->_ext_stmt($class,
436 qq|# End of lines loaded from '$real_inc_path' |
439 or croak "Failed to close $real_inc_path: $!";
448 Does the actual schema-construction work.
455 $self->_load_tables($self->_tables_list);
462 Rescan the database for newly added tables. Does
463 not process drops or changes. Returns a list of
464 the newly added table monikers.
466 The schema argument should be the schema class
467 or object to be affected. It should probably
468 be derived from the original schema_class used
474 my ($self, $schema) = @_;
476 $self->{schema} = $schema;
477 $self->_relbuilder->{schema} = $schema;
480 my @current = $self->_tables_list;
481 foreach my $table ($self->_tables_list) {
482 if(!exists $self->{_tables}->{$table}) {
483 push(@created, $table);
487 my $loaded = $self->_load_tables(@created);
489 return map { $self->monikers->{$_} } @$loaded;
495 return if $self->{skip_relationships};
497 $self->{relbuilder} ||= DBIx::Class::Schema::Loader::RelBuilder->new(
498 $self->schema, $self->inflect_plural, $self->inflect_singular
503 my ($self, @tables) = @_;
505 # First, use _tables_list with constraint and exclude
506 # to get a list of tables to operate on
508 my $constraint = $self->constraint;
509 my $exclude = $self->exclude;
511 @tables = grep { /$constraint/ } @tables if $constraint;
512 @tables = grep { ! /$exclude/ } @tables if $exclude;
514 # Save the new tables to the tables list
516 $self->{_tables}->{$_} = 1;
519 $self->_make_src_class($_) for @tables;
520 $self->_setup_src_meta($_) for @tables;
522 if(!$self->skip_relationships) {
523 # The relationship loader needs a working schema
525 local $self->{dump_directory} = $self->{temp_directory};
526 $self->_reload_classes(\@tables);
527 $self->_load_relationships($_) for @tables;
530 # Remove that temp dir from INC so it doesn't get reloaded
531 @INC = grep { $_ ne $self->{dump_directory} } @INC;
534 $self->_load_external($_)
535 for map { $self->classes->{$_} } @tables;
537 # Reload without unloading first to preserve any symbols from external
539 $self->_reload_classes(\@tables, 0);
541 # Drop temporary cache
542 delete $self->{_cache};
547 sub _reload_classes {
548 my ($self, $tables, $unload) = @_;
550 my @tables = @$tables;
551 $unload = 1 unless defined $unload;
553 # so that we don't repeat custom sections
554 @INC = grep $_ ne $self->dump_directory, @INC;
556 $self->_dump_to_dir(map { $self->classes->{$_} } @tables);
558 unshift @INC, $self->dump_directory;
561 my %have_source = map { $_ => $self->schema->source($_) }
562 $self->schema->sources;
564 for my $table (@tables) {
565 my $moniker = $self->monikers->{$table};
566 my $class = $self->classes->{$table};
569 no warnings 'redefine';
570 local *Class::C3::reinitialize = sub {};
573 Class::Unload->unload($class) if $unload;
574 my ($source, $resultset_class);
576 ($source = $have_source{$moniker})
577 && ($resultset_class = $source->resultset_class)
578 && ($resultset_class ne 'DBIx::Class::ResultSet')
580 my $has_file = Class::Inspector->loaded_filename($resultset_class);
581 Class::Unload->unload($resultset_class) if $unload;
582 $self->_reload_class($resultset_class) if $has_file;
584 $self->_reload_class($class);
586 push @to_register, [$moniker, $class];
589 Class::C3->reinitialize;
591 $self->schema->register_class(@$_);
595 # We use this instead of ensure_class_loaded when there are package symbols we
598 my ($self, $class) = @_;
600 my $class_path = $self->_class_path($class);
601 delete $INC{ $class_path };
602 eval "require $class;";
605 sub _get_dump_filename {
606 my ($self, $class) = (@_);
609 return $self->dump_directory . q{/} . $class . q{.pm};
612 sub _ensure_dump_subdirs {
613 my ($self, $class) = (@_);
615 my @name_parts = split(/::/, $class);
616 pop @name_parts; # we don't care about the very last element,
617 # which is a filename
619 my $dir = $self->dump_directory;
622 mkdir($dir) or croak "mkdir('$dir') failed: $!";
624 last if !@name_parts;
625 $dir = File::Spec->catdir($dir, shift @name_parts);
630 my ($self, @classes) = @_;
632 my $schema_class = $self->schema_class;
633 my $schema_base_class = $self->schema_base_class || 'DBIx::Class::Schema';
635 my $target_dir = $self->dump_directory;
636 warn "Dumping manual schema for $schema_class to directory $target_dir ...\n"
637 unless $self->{dynamic} or $self->{quiet};
640 qq|package $schema_class;\n\n|
641 . qq|# Created by DBIx::Class::Schema::Loader\n|
642 . qq|# DO NOT MODIFY THE FIRST PART OF THIS FILE\n\n|
643 . qq|use strict;\nuse warnings;\n\n|
644 . qq|use base '$schema_base_class';\n\n|;
646 if ($self->use_namespaces) {
647 $schema_text .= qq|__PACKAGE__->load_namespaces|;
648 my $namespace_options;
649 for my $attr (qw(result_namespace
651 default_resultset_class)) {
653 $namespace_options .= qq| $attr => '| . $self->$attr . qq|',\n|
656 $schema_text .= qq|(\n$namespace_options)| if $namespace_options;
657 $schema_text .= qq|;\n|;
660 $schema_text .= qq|__PACKAGE__->load_classes;\n|;
663 $self->_write_classfile($schema_class, $schema_text);
665 my $result_base_class = $self->result_base_class || 'DBIx::Class';
667 foreach my $src_class (@classes) {
669 qq|package $src_class;\n\n|
670 . qq|# Created by DBIx::Class::Schema::Loader\n|
671 . qq|# DO NOT MODIFY THE FIRST PART OF THIS FILE\n\n|
672 . qq|use strict;\nuse warnings;\n\n|
673 . qq|use base '$result_base_class';\n\n|;
675 $self->_write_classfile($src_class, $src_text);
678 warn "Schema dump completed.\n" unless $self->{dynamic} or $self->{quiet};
683 my ($self, $version, $ts) = @_;
684 return qq|\n\n# Created by DBIx::Class::Schema::Loader|
687 . qq|\n# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:|;
690 sub _write_classfile {
691 my ($self, $class, $text) = @_;
693 my $filename = $self->_get_dump_filename($class);
694 $self->_ensure_dump_subdirs($class);
696 if (-f $filename && $self->really_erase_my_files) {
697 warn "Deleting existing file '$filename' due to "
698 . "'really_erase_my_files' setting\n" unless $self->{quiet};
702 my ($custom_content, $old_md5, $old_ver, $old_ts) = $self->_get_custom_content($class, $filename);
705 for @{$self->{_dump_storage}->{$class} || []};
707 # Check and see if the dump is infact differnt
711 $compare_to = $text . $self->_sig_comment($old_ver, $old_ts);
714 if (Digest::MD5::md5_base64($compare_to) eq $old_md5) {
719 $text .= $self->_sig_comment(
720 $self->version_to_dump,
721 POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
724 open(my $fh, '>', $filename)
725 or croak "Cannot open '$filename' for writing: $!";
727 # Write the top half and its MD5 sum
728 print $fh $text . Digest::MD5::md5_base64($text) . "\n";
730 # Write out anything loaded via external partial class file in @INC
732 for @{$self->{_ext_storage}->{$class} || []};
734 # Write out any custom content the user has added
735 print $fh $custom_content;
738 or croak "Error closing '$filename': $!";
741 sub _default_custom_content {
742 return qq|\n\n# You can replace this text with custom|
743 . qq| content, and it will be preserved on regeneration|
747 sub _get_custom_content {
748 my ($self, $class, $filename) = @_;
750 return ($self->_default_custom_content) if ! -f $filename;
752 open(my $fh, '<', $filename)
753 or croak "Cannot open '$filename' for reading: $!";
756 qr{^(# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:)([A-Za-z0-9/+]{22})\n};
759 my ($md5, $ts, $ver);
761 if(!$md5 && /$mark_re/) {
765 # Pull out the previous version and timestamp
766 ($ver, $ts) = $buffer =~ m/# Created by DBIx::Class::Schema::Loader v(.*?) @ (.*?)$/s;
769 croak "Checksum mismatch in '$filename'"
770 if Digest::MD5::md5_base64($buffer) ne $md5;
779 croak "Cannot not overwrite '$filename' without 'really_erase_my_files',"
780 . " it does not appear to have been generated by Loader"
783 # Default custom content:
784 $buffer ||= $self->_default_custom_content;
786 return ($buffer, $md5, $ver, $ts);
794 warn "$target: use $_;" if $self->debug;
795 $self->_raw_stmt($target, "use $_;");
802 my $schema_class = $self->schema_class;
804 my $blist = join(q{ }, @_);
805 warn "$target: use base qw/ $blist /;" if $self->debug && @_;
806 $self->_raw_stmt($target, "use base qw/ $blist /;") if @_;
809 # Create class with applicable bases, setup monikers, etc
810 sub _make_src_class {
811 my ($self, $table) = @_;
813 my $schema = $self->schema;
814 my $schema_class = $self->schema_class;
816 my $table_moniker = $self->_table2moniker($table);
817 my @result_namespace = ($schema_class);
818 if ($self->use_namespaces) {
819 my $result_namespace = $self->result_namespace || 'Result';
820 if ($result_namespace =~ /^\+(.*)/) {
821 # Fully qualified namespace
822 @result_namespace = ($1)
826 push @result_namespace, $result_namespace;
829 my $table_class = join(q{::}, @result_namespace, $table_moniker);
831 my $table_normalized = lc $table;
832 $self->classes->{$table} = $table_class;
833 $self->classes->{$table_normalized} = $table_class;
834 $self->monikers->{$table} = $table_moniker;
835 $self->monikers->{$table_normalized} = $table_moniker;
837 $self->_use ($table_class, @{$self->additional_classes});
838 $self->_inject($table_class, @{$self->left_base_classes});
840 $self->_dbic_stmt($table_class, 'load_components', @{$self->components}, 'Core');
842 $self->_dbic_stmt($table_class, 'load_resultset_components', @{$self->resultset_components})
843 if @{$self->resultset_components};
844 $self->_inject($table_class, @{$self->additional_base_classes});
847 # Set up metadata (cols, pks, etc)
848 sub _setup_src_meta {
849 my ($self, $table) = @_;
851 my $schema = $self->schema;
852 my $schema_class = $self->schema_class;
854 my $table_class = $self->classes->{$table};
855 my $table_moniker = $self->monikers->{$table};
857 my $table_name = $table;
858 my $name_sep = $self->schema->storage->sql_maker->name_sep;
860 if ($name_sep && $table_name =~ /\Q$name_sep\E/) {
861 $table_name = \ $self->_quote_table_name($table_name);
864 $self->_dbic_stmt($table_class,'table',$table_name);
866 my $cols = $self->_table_columns($table);
868 eval { $col_info = $self->_columns_info_for($table) };
870 $self->_dbic_stmt($table_class,'add_columns',@$cols);
873 if ($self->_is_case_sensitive) {
874 for my $col (keys %$col_info) {
875 $col_info->{$col}{accessor} = lc $col
879 $col_info = { map { lc($_), $col_info->{$_} } keys %$col_info };
882 my $fks = $self->_table_fk_info($table);
884 for my $fkdef (@$fks) {
885 for my $col (@{ $fkdef->{local_columns} }) {
886 $col_info->{$col}{is_foreign_key} = 1;
892 map { $_, ($col_info->{$_}||{}) } @$cols
896 my %uniq_tag; # used to eliminate duplicate uniqs
898 my $pks = $self->_table_pk_info($table) || [];
899 @$pks ? $self->_dbic_stmt($table_class,'set_primary_key',@$pks)
900 : carp("$table has no primary key");
901 $uniq_tag{ join("\0", @$pks) }++ if @$pks; # pk is a uniq
903 my $uniqs = $self->_table_uniq_info($table) || [];
905 my ($name, $cols) = @$_;
906 next if $uniq_tag{ join("\0", @$cols) }++; # skip duplicates
907 $self->_dbic_stmt($table_class,'add_unique_constraint', $name, $cols);
914 Returns a sorted list of loaded tables, using the original database table
922 return keys %{$self->_tables};
925 # Make a moniker from a table
926 sub _default_table2moniker {
927 my ($self, $table) = @_;
929 return join '', map ucfirst, split /[\W_]+/,
930 Lingua::EN::Inflect::Number::to_S(lc $table);
934 my ( $self, $table ) = @_;
938 if( ref $self->moniker_map eq 'HASH' ) {
939 $moniker = $self->moniker_map->{$table};
941 elsif( ref $self->moniker_map eq 'CODE' ) {
942 $moniker = $self->moniker_map->($table);
945 $moniker ||= $self->_default_table2moniker($table);
950 sub _load_relationships {
951 my ($self, $table) = @_;
953 my $tbl_fk_info = $self->_table_fk_info($table);
954 foreach my $fkdef (@$tbl_fk_info) {
955 $fkdef->{remote_source} =
956 $self->monikers->{delete $fkdef->{remote_table}};
958 my $tbl_uniq_info = $self->_table_uniq_info($table);
960 my $local_moniker = $self->monikers->{$table};
961 my $rel_stmts = $self->_relbuilder->generate_code($local_moniker, $tbl_fk_info, $tbl_uniq_info);
963 foreach my $src_class (sort keys %$rel_stmts) {
964 my $src_stmts = $rel_stmts->{$src_class};
965 foreach my $stmt (@$src_stmts) {
966 $self->_dbic_stmt($src_class,$stmt->{method},@{$stmt->{args}});
971 # Overload these in driver class:
973 # Returns an arrayref of column names
974 sub _table_columns { croak "ABSTRACT METHOD" }
976 # Returns arrayref of pk col names
977 sub _table_pk_info { croak "ABSTRACT METHOD" }
979 # Returns an arrayref of uniqs [ [ foo => [ col1, col2 ] ], [ bar => [ ... ] ] ]
980 sub _table_uniq_info { croak "ABSTRACT METHOD" }
982 # Returns an arrayref of foreign key constraints, each
983 # being a hashref with 3 keys:
984 # local_columns (arrayref), remote_columns (arrayref), remote_table
985 sub _table_fk_info { croak "ABSTRACT METHOD" }
987 # Returns an array of lower case table names
988 sub _tables_list { croak "ABSTRACT METHOD" }
990 # Execute a constructive DBIC class method, with debug/dump_to_dir hooks.
997 $args = '(' . $args . ')' if @_ < 2;
998 my $stmt = $method . $args . q{;};
1000 warn qq|$class\->$stmt\n| if $self->debug;
1001 $self->_raw_stmt($class, '__PACKAGE__->' . $stmt);
1004 # Store a raw source line for a class (for dumping purposes)
1006 my ($self, $class, $stmt) = @_;
1007 push(@{$self->{_dump_storage}->{$class}}, $stmt);
1010 # Like above, but separately for the externally loaded stuff
1012 my ($self, $class, $stmt) = @_;
1013 push(@{$self->{_ext_storage}->{$class}}, $stmt);
1016 sub _quote_table_name {
1017 my ($self, $table) = @_;
1019 my $qt = $self->schema->storage->sql_maker->quote_char;
1021 return $table unless $qt;
1024 return $qt->[0] . $table . $qt->[1];
1027 return $qt . $table . $qt;
1030 sub _is_case_sensitive { 0 }
1034 Returns a hashref of loaded table to moniker mappings. There will
1035 be two entries for each table, the original name and the "normalized"
1036 name, in the case that the two are different (such as databases
1037 that like uppercase table names, or preserve your original mixed-case
1038 definitions, or what-have-you).
1042 Returns a hashref of table to class mappings. In some cases it will
1043 contain multiple entries per table for the original and normalized table
1044 names, as above in L</monikers>.
1048 L<DBIx::Class::Schema::Loader>
1052 See L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
1056 This library is free software; you can redistribute it and/or modify it under
1057 the same terms as Perl itself.