- Allow complex update/delete operations on sources without a
primary key, as long as they have at least one non-nullable
unique constraint
+ - dbicadmin now better supports catalyst-style config files, by
+ unrolling 'config_info' hashkeys
* Fixes
- Fix SkipFirst and FirstSkip limit dialects (Informix and Firebird)
- Fix more cases of $schema leakage in SQLT::Parser::DBIC
- Remove useless vestigial pessimization in Ordered.pm for cases
when the position column is part of a unique constraint
+ - Fix dbicadmin to no longer ignore the documented 'config' option
* Misc
- Centralized leak-checks for all instances of DBICTest::Schema
dyfrgi: Michael Leuchtenburg <michael@slashhome.org>
+edenc: Eden Cardim <edencardim@gmail.com>
+
felliott: Fitz Elliott <fitz.elliott@gmail.com>
freetime: Bill Moseley <moseley@hank.org>
config_file provide a config_file to read connect_info from, if this is provided
config_stanze should also be provided to locate where the connect_info is in the config
-The config file should be in a format readable by Config::General
+The config file should be in a format readable by Config::Any.
=cut
die ("Could not find $stanza in config, $path does not seem to exist.\n");
}
}
+ $cfg = $cfg->{connect_info} if exists $cfg->{connect_info};
return $cfg;
}
['op:s' => 'compatiblity option all of the above can be suppied as --op=<action>'],
['help' => 'display this help', { implies => { schema_class => '__dummy__' } } ],
['selfinject-pod' => 'hidden', { implies => { schema_class => '__dummy__' } } ],
- ], required=> 1 }],
+ ], required => 1 }],
['Arguments'],
+ ["configuration" => hidden => { one_of => [
+ ['config-file|config:s' => 'Supply the config file for parsing by Config::Any', { depends => 'config_stanza'} ],
+ ['connect-info:s%' => 'Supply the connect info as trailing options e.g. --connect-info dsn=<dsn> user=<user> password=<pass>' ],
+ ['connect:s' => 'Supply the connect info as a JSON-encoded structure, e.g. an --connect=["dsn","user","pass"]'],
+ ], required => 1 }],
['schema-class:s' => 'The class of the schema to load', { required => 1 } ],
- ['resultset|resultset-class|class:s' => 'The resultset to operate on for data manipulation' ],
['config-stanza:s' => 'Where in the config to find the connection_info, supply in form MyApp::Model::DB',],
- ['config:s' => 'Supply the config file for parsing by Config::Any', { depends => 'config_stanza'} ],
- ['connect-info:s%' => 'Supply the connect info as additional options ie -I dsn=<dsn> user=<user> password=<pass> '],
- ['connect:s' => 'Supply the connect info as a json string' ],
+ ['resultset|resultset-class|class:s' => 'The resultset to operate on for data manipulation' ],
['sql-dir:s' => 'The directory where sql diffs will be created'],
['sql-type:s' => 'The RDBMs flavour you wish to use'],
['version:i' => 'Supply a version install'],
)
);
-die "please only use one of --config or --connect-info\n" if ($opts->{config} and $opts->{connect_info});
-
if($opts->{selfinject_pod}) {
die "This is an internal method, do not call!!!\n"
}
# option compatability mangle
+# (can not be joined in the spec, one is s% the other is s)
if($opts->{connect}) {
$opts->{connect_info} = delete $opts->{connect};
}
+
my $admin = DBIx::Class::Admin->new( %$opts );
my $action = $opts->{action};
}
my @json_backends = qw/XS JSON DWIW/;
-my $tests_per_run = 5;
-plan tests => ($tests_per_run * @json_backends) + 1;
-
# test the script is setting @INC properly
-test_exec (qw| -It/lib/testinclude --schema=DBICTestAdminInc --insert --connect=[] |);
+test_exec (qw|-It/lib/testinclude --schema=DBICTestAdminInc --connect=[] --insert|);
cmp_ok ( $? >> 8, '==', 70, 'Correct exit code from connecting a custom INC schema' );
+# test that config works properly
+{
+ no warnings 'qw';
+ test_exec(qw|-It/lib/testinclude --schema=DBICTestConfig --create --connect=["klaatu","barada","nikto"]|);
+ cmp_ok( $? >> 8, '==', 71, 'Correct schema loaded via config' ) || exit;
+}
+
+# test that config-file works properly
+test_exec(qw|-It/lib/testinclude --schema=DBICTestConfig --config=t/lib/admincfgtest.json --config-stanza=Model::Gort --deploy|);
+cmp_ok ($? >> 8, '==', 71, 'Correct schema loaded via testconfig');
+
for my $js (@json_backends) {
eval {JSON::Any->import ($js) };
SKIP: {
- skip ("JSON backend $js is not available, skip testing", $tests_per_run) if $@;
+ skip ("JSON backend $js is not available, skip testing", 1) if $@;
$ENV{JSON_ANY_ORDER} = $js;
eval { test_dbicadmin () };
}
}
+done_testing();
+
sub test_dbicadmin {
my $schema = DBICTest->init_schema( sqlite_use_file => 1 ); # reinit a fresh db for every run
--- /dev/null
+{
+ "Model" : {
+ "Gort" : {
+ "connect_info" : [
+ "klaatu",
+ "barada",
+ "nikto"
+ ]
+ }
+ }
+}
--- /dev/null
+package DBICTestConfig;
+use base 'DBIx::Class::Schema';
+
+sub connect {
+ my($self, @opt) = @_;
+ @opt == 4
+ and $opt[0] eq 'klaatu'
+ and $opt[1] eq 'barada'
+ and $opt[2] eq 'nikto'
+ and $opt[3]->{ignore_version}
+ and exit 71; # this is what the test will expect to see
+ exit 1;
+}
+
+1;