Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Dancer-Plugin-DBIC CPAN distribution.

Report information
The Basics
Id: 61130
Status: resolved
Priority: 0/
Queue: Dancer-Plugin-DBIC

People
Owner: Nobody in particular
Requestors: DAMS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.01
Fixed in: (no value)



Subject: don't force discovering schema from database
First of all : nice plugin. The issue : The plugin insists on using make_schema_at(), to rediscover the schema from the database each time. It's good in some case, but in other cases (like mine), I have already generated the DBIx Classes files. So I'd like the plugin to just connect, and not try to discoverthe chema fomr the DB. I propose a trivial patch, that adds an option in the config file, to specify if the plugin should discover the schema from the database or not. You may want to do the opposite of the patch, so that the schema is discovered by default
Subject: discover_schema.patch
--- DBIC.pm.old 2010-09-07 11:00:26.000000000 +0200 +++ DBIC.pm 2010-09-07 11:35:51.000000000 +0200 @@ -23,13 +23,20 @@ push @dsn, $cfg->{$keyword}->{dsn} if $cfg->{$keyword}->{dsn}; push @dsn, $cfg->{$keyword}->{user} if $cfg->{$keyword}->{user}; push @dsn, $cfg->{$keyword}->{pass} if $cfg->{$keyword}->{pass}; - - make_schema_at( - $cfg->{$keyword}->{pckg}, - {}, - [ @dsn ], - ); - + + if ($cfg->{$keyword}->{discover_schema}) { + make_schema_at( + $cfg->{$keyword}->{pckg}, + {}, + [ @dsn ], + ); + } else { + my $path = $cfg->{$keyword}->{pckg}; + $path =~ s!::|'!/!g; + $path .= '.pm'; + require $path; + } + push @dsn, $cfg->{$keyword}->{options} if $cfg->{$keyword}->{options}; my $package = $cfg->{$keyword}->{pckg}; @@ -58,6 +65,7 @@ DBIC: foo: pckg: "Foo-Bar" + discover_schema: 1 dsn: "dbi:mysql:db_foo" user: "root" pass: "****" @@ -101,6 +109,7 @@ DBIC: foo: pckg: "Foo" + discover_schema: 1 dsn: "dbi:mysql:db_foo" user: "root" pass: "****" @@ -117,14 +126,21 @@ Each database configuration *must* have a dsn and pckg option. The dsn option should be the L<DBI> driver connection string less the optional user/pass and arguments options. The pckg option should be a proper Perl package name that -Dancer::Plugin::DBIC will use as a DBIx::Class schema class. Optionally a database -configuation may have user, pass and options paramters which are appended to the -dsn in list form, i.e. dbi:SQLite:dbname=./foo.db, $user, $pass, $options. +Dancer::Plugin::DBIC will use as a DBIx::Class schema class. The +discover_schema should be a boolean. If true, the schema will be created on the +fly from the database. If not, the plugin will assume that the schema classes +have already been created and are in @INC. Optionally a database configuation +may have user, pass and options paramters which are appended to the dsn in list +form, i.e. dbi:SQLite:dbname=./foo.db, $user, $pass, $options. =head1 AUTHOR Al Newkirk <awncorp@cpan.org> +=head1 CONTRIBUTOR + +Damien Krotkine <dams@cpan.org> + =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2010 by awncorp.
On Tue Sep 07 05:37:31 2010, DAMS wrote: Show quoted text
> > I propose a trivial patch, that adds an option in the config file, to > specify if the plugin should discover the schema from the database or not.
I support this! While many new developers prefer to use the auto discover, experienced developers (or simply production-safe environments) define their schemas and just want to work with them. Auto discover should be a feature to enable for the beginners, not disable for the experienced.
The autogeneration policy has been reversed in version 0.12 now on CPAN and GitHub.