use BUILD's $args instead of %$self
[catagits/Catalyst-Model-DBIC-Schema.git] / lib / Catalyst / Helper / Model / DBIC / Schema.pm
index 3567c9f..026e6f4 100644 (file)
@@ -1,9 +1,10 @@
 package Catalyst::Helper::Model::DBIC::Schema;
 
+use namespace::autoclean;
 use Moose;
 no warnings 'uninitialized';
 
-our $VERSION = '0.24';
+our $VERSION = '0.26';
 
 use Carp;
 use Tie::IxHash ();
@@ -15,8 +16,6 @@ use Moose::Autobox;
 use List::MoreUtils 'firstidx';
 use Scalar::Util 'looks_like_number';
 
-use namespace::clean -except => 'meta';
-
 =head1 NAME
 
 Catalyst::Helper::Model::DBIC::Schema - Helper for DBIC Schema Models
@@ -190,7 +189,12 @@ sub BUILD {
 
             $helper->{loader_args} = $self->_build_helper_loader_args;
 
-            if (first { /^dbi:/i } @args) {
+            my $dbi_dsn_part;
+            if (first { ($dbi_dsn_part) = /^(dbi):/i } @args) {
+                die
+qq{DSN must start with 'dbi:' not '$dbi_dsn_part' (case matters!)}
+                    if $dbi_dsn_part ne 'dbi';
+
                 $helper->{setup_connect_info} = 1;
 
                 $helper->{connect_info} =
@@ -270,7 +274,7 @@ sub _read_loader_args {
 
     my %loader_args;
 
-    while (@$args && $args->[0] !~ /^dbi:/) {
+    while (@$args && $args->[0] !~ /^dbi:/i) {
         my ($key, $val) = split /=/, shift(@$args), 2;
 
         if ($self->_is_struct($val)) {
@@ -401,7 +405,7 @@ sub _get_dsn_user_pass {
 
     if ($dsn =~ /sqlite/i) {
         ($user, $password) = ('', '');
-        shift @$connect_info while $connect_info->[0] eq '';
+        shift @$connect_info while @$connect_info and $connect_info->[0] eq '';
     } else {
         ($user, $password) = splice @$connect_info, 0, 2;
     }