X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fh_Common.pm;h=d55da8cfb3c529d36ab5a97a75a6dbd39a7aca23;hb=e96a3fd1c8ee8c711a7e119c0937da6866bbd4f0;hp=a7bb937e575ee021e97e91b75e3100ddde012e00;hpb=8f11e2a03067829dc5f8cd6ae7fa0e3f249d61c1;p=freeside.git diff --git a/FS/FS/h_Common.pm b/FS/FS/h_Common.pm index a7bb937e5..d55da8cfb 100644 --- a/FS/FS/h_Common.pm +++ b/FS/FS/h_Common.pm @@ -2,6 +2,7 @@ package FS::h_Common; use strict; use FS::Record qw(dbdef); +use Carp qw(confess); =head1 NAME @@ -39,8 +40,13 @@ sub sql_h_search { my( $self, $end ) = ( shift, shift ); my $table = $self->table; - my $pkey = dbdef->table($table)->primary_key - or die "can't (yet) search history table $table without a primary key"; + my $real_table = ($table =~ /^h_(.*)$/) ? $1 : $table; + my $pkey = dbdef->table($real_table)->primary_key + or die "can't (yet) search history table $real_table without a primary key"; + + unless ($end) { + confess 'Called sql_h_search without END_TIMESTAMP'; + } my $notcancelled = ''; if ( scalar(@_) && $_[0] ) { @@ -64,7 +70,7 @@ sub sql_h_search { '', - 'maintable', + 'AS maintable', ); }