Fix syntax error in example
[dbsrgits/SQL-Abstract.git] / lib / SQL / Abstract.pm
index 4954643..8150396 100644 (file)
@@ -2,7 +2,6 @@ package SQL::Abstract; # see doc at end of file
 
 use strict;
 use warnings;
-use Module::Runtime ();
 use Carp ();
 use List::Util ();
 use Scalar::Util ();
@@ -28,7 +27,7 @@ BEGIN {
 # GLOBALS
 #======================================================================
 
-our $VERSION  = '1.90_02';
+our $VERSION  = '2.000001';
 
 # This would confuse some packagers
 $VERSION = eval $VERSION if $VERSION =~ /_/; # numify for warning-free dev releases
@@ -352,8 +351,8 @@ sub new {
   }
 
   if ($opt{lazy_join_sql_parts}) {
-    my $mod = Module::Runtime::use_module('SQL::Abstract::Parts');
-    $opt{join_sql_parts} ||= sub { $mod->new(@_) };
+    require SQL::Abstract::Parts;
+    $opt{join_sql_parts} ||= sub { SQL::Abstract::Parts->new(@_) };
   }
 
   $opt{join_sql_parts} ||= sub { join $_[0], @_[1..$#_] };
@@ -1049,7 +1048,7 @@ sub _expand_hashpair_ident {
     return $self->sqlfalse unless @$v;
     $self->_debug("ARRAY($k) means distribute over elements");
     my $logic = lc(
-      $v->[0] =~ /^-(and|or)$/i
+      ($v->[0]||'') =~ /^-(and|or)$/i
         ? (shift(@{$v = [ @$v ]}), $1)
         : lc($self->{logic} || 'OR')
     );
@@ -1284,8 +1283,11 @@ sub _expand_ident {
   unless (defined($body) or (ref($body) and ref($body) eq 'ARRAY')) {
     puke "-ident requires a single plain scalar argument (a quotable identifier) or an arrayref of identifier parts";
   }
-  my @parts = map split(/\Q${\($self->{name_sep}||'.')}\E/, $_),
-                ref($body) ? @$body : $body;
+  my ($sep) = map +(defined() ? $_ : '.') , $self->{name_sep};
+  my @parts = map +($sep
+                     ? map split(/\Q${sep}\E/, $_), @$_
+                     : @$_
+                   ), ref($body) ? $body : [ $body ];
   return { -ident => $parts[-1] } if $self->{_dequalify_idents};
   unless ($self->{quote_char}) {
     $self->_assert_pass_injection_guard($_) for @parts;
@@ -2873,7 +2875,7 @@ into an C<AND> of its elements:
 
 To get an OR instead, you can combine it with the arrayref idea:
 
-    my %where => (
+    my %where = (
          user => 'nwiger',
          priority => [ { '=', 2 }, { '>', 5 } ]
     );