Revision history for Perl extension DBIx::Class::Schema::Loader
+0.02003 Not yet released
+ - Deprecated arguments: dsn, user, password, options
+ - New argument: connect_info
+
0.02002 Sat Feb 18 19:53:12 UTC 2006
- Added moniker_map and inflect_map
# Always remember to do all digits for the version even if they're 0
# i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
# brain damage and presumably various other packaging systems too
-our $VERSION = '0.02002';
+our $VERSION = '0.02003';
__PACKAGE__->mk_classaccessor('loader');
}
__PACKAGE__->load_from_connection(
- dsn => "dbi:mysql:dbname",
- user => "root",
- password => "",
+ connect_info => [ "dbi:mysql:dbname",
+ "root",
+ "mypassword",
+ { AutoCommit => 1 },
+ ],
additional_classes => [qw/DBIx::Class::Foo/],
additional_base_classes => [qw/My::Stuff/],
left_base_classes => [qw/DBIx::Class::Bar/],
=cut
+# XXX this is DBI-specific, as it peers into the dsn to determine
+# the vendor class to use...
sub load_from_connection {
my ( $class, %args ) = @_;
- croak 'dsn argument is required' if ! $args{dsn};
- my $dsn = $args{dsn};
+ my $dsn;
+
+ if($args{connect_info} && $args{connect_info}->[0]) {
+ $dsn = $args{connect_info}->[0];
+ }
+ elsif($args{dsn}) {
+ warn "dsn argument is deprecated, please use connect_info instead";
+ $dsn = $args{dsn};
+ }
+ else {
+ croak 'connect_info arrayref argument with valid '
+ . 'first element is required';
+ }
+
my ($driver) = $dsn =~ m/^dbi:(\w*?)(?:\((.*?)\))?:/i;
$driver = 'SQLite' if $driver eq 'SQLite2';
my $impl = "DBIx::Class::Schema::Loader::" . $driver;
__PACKAGE__->mk_ro_accessors(qw/
schema
- dsn
- user
- password
- options
+ connect_info
exclude
constraint
additional_classes
Available constructor options are:
+=head2 connect_info
+
+Identical to the connect_info arguments to C<connect> and C<connection>
+that are mentioned in L<DBIx::Class::Schema>.
+
+An arrayref of connection information. For DBI-based Schemas,
+this takes the form:
+
+ connect_info => [ $dsn, $user, $pass, { AutoCommit => 1 } ],
+
=head2 additional_base_classes
List of additional base classes your table classes will use.
Enable debug messages.
-=head2 dsn
-
-DBI Data Source Name.
-
-=head2 password
-
-Password.
-
=head2 relationships
Try to automatically detect/setup has_a and has_many relationships.
a hashref argument, not a coderef. If you set C<inflect> to anything,
that setting will be copied to L</inflect_map>.
+=head2 dsn
+
+DEPRECATED, use L</connect_info> instead.
+
+DBI Data Source Name.
+
=head2 user
+DEPRECATED, use L</connect_info> instead.
+
Username.
+=head2 password
+
+DEPRECATED, use L</connect_info> instead.
+
+Password.
+
+=head2 options
+
+DEPRECATED, use L</connect_info> instead.
+
+DBI connection options hashref, like:
+
+ { AutoCommit => 1 }
+
=head1 METHODS
=cut
additional_base_classes
left_base_classes
components
- resultset_components/);
+ resultset_components
+ connect_info/);
push(@{$self->{components}}, 'ResultSetManager')
if @{$self->{resultset_components}};
# Support deprecated argument name
$self->{inflect_map} ||= $self->{inflect};
+ # Support deprecated connect_info args, even mixed
+ # with a valid partially-filled connect_info
+ $self->{connect_info}->[0] ||= $self->{dsn};
+ $self->{connect_info}->[1] ||= $self->{user};
+ $self->{connect_info}->[2] ||= $self->{password};
+ $self->{connect_info}->[3] ||= $self->{options};
+
$self;
}
sub load {
my $self = shift;
- $self->schema->connection($self->dsn, $self->user,
- $self->password, $self->options);
+ $self->schema->connection(@{$self->connect_info});
warn qq/\### START DBIx::Class::Schema::Loader dump ###\n/
if $self->debug;
my $debug = ($self->{verbose} > 1) ? 1 : 0;
my %loader_opts = (
- dsn => $self->{dsn},
- user => $self->{user},
- password => $self->{password},
+ connect_info => [ $self->{dsn}, $self->{user},
+ $self->{password} ],
constraint => '^(?:\S+\.)?(?i:loader_test)[0-9]+$',
relationships => 1,
additional_classes => 'TestAdditional',