Avoid a FC5 performance hit by using a named hash and then blessing it.
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultSet.pm
index 7e94eab..39611eb 100644 (file)
@@ -95,14 +95,24 @@ sub new {
 
   $attrs->{alias} ||= 'me';
 
-  bless {
+  # XXXX
+  # Use a named hash here and bless afterwards to avoid a huge performance hit
+  # in perl 5.8.8-5+ FC5 and later, and possibly other distributions.
+  #
+  # See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=196836 for more
+  # information.
+  my $self = {
     result_source => $source,
     result_class => $attrs->{result_class} || $source->result_class,
     cond => $attrs->{where},
     count => undef,
     pager => undef,
     attrs => $attrs
-  }, $class;
+  };
+
+  bless $self, $class;
+
+  return $self;
 }
 
 =head2 search
@@ -129,6 +139,8 @@ call it as C<search(undef, \%attrs)>.
     columns => [qw/name artistid/],
   });
 
+For a list of attributes that can be passed to C<search>, see L</ATTRIBUTES>. For more examples of using this function, see L<Searching|DBIx::Class::Manual::Cookbook/Searching>.
+
 =cut
 
 sub search {
@@ -1566,7 +1578,8 @@ sub _resolved_attrs {
 
 sub _merge_attr {
   my ($self, $a, $b) = @_;
-  return $b unless $a;
+  return $b unless defined($a);
+  return $a unless defined($b);
   
   if (ref $b eq 'HASH' && ref $a eq 'HASH') {
     foreach my $key (keys %{$b}) {
@@ -1750,9 +1763,15 @@ use C<get_column> instead:
 You can create your own accessors if required - see
 L<DBIx::Class::Manual::Cookbook> for details.
 
-Please note: This will NOT insert an C<AS employee_count> into the SQL statement
-produced, it is used for internal access only. Thus attempting to use the accessor
-in an C<order_by> clause or similar will fail misrably.
+Please note: This will NOT insert an C<AS employee_count> into the SQL
+statement produced, it is used for internal access only. Thus
+attempting to use the accessor in an C<order_by> clause or similar
+will fail miserably.
+
+To get around this limitation, you can supply literal SQL to your
+C<select> attibute that contains the C<AS alias> text, eg:
+
+  select => [\'myfield AS alias']
 
 =head2 join