From: ivan Date: Wed, 3 Sep 2003 18:46:57 +0000 (+0000) Subject: turn vfieldpart_hashref into a method, not a subroutine X-Git-Tag: NET_WHOIS_RAW_0_31~439 X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=commitdiff_plain;h=16d3d97fb10e7067cd9a7e82a37f384703207bed turn vfieldpart_hashref into a method, not a subroutine another fix to support running 1.5.0 virtual field code on 1.4.x databases --- diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 1fe51e065..07554481b 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -664,7 +664,7 @@ sub insert { if (@virtual_fields) { my %v_values = map { $_, $self->getfield($_) } @virtual_fields; - my $vfieldpart = vfieldpart_hashref($table); + my $vfieldpart = $self->vfieldpart_hashref; my $v_statement = "INSERT INTO virtual_field(recnum, vfieldpart, value) ". "VALUES (?, ?, ?)"; @@ -753,7 +753,7 @@ sub delete { my $primary_key = $self->dbdef_table->primary_key; my $v_sth; my @del_vfields; - my $vfp = vfieldpart_hashref($self->table); + my $vfp = $self->vfieldpart_hashref; foreach($self->virtual_fields) { next if $self->getfield($_) eq ''; unless(@del_vfields) { @@ -870,7 +870,7 @@ sub replace { my $v_rep_sth; my $v_del_sth; my (@add_vfields, @rep_vfields, @del_vfields); - my $vfp = vfieldpart_hashref($old->table); + my $vfp = $old->vfieldpart_hashref; foreach(grep { exists($diff{$_}) } $new->virtual_fields) { if($diff{$_} eq '') { # Delete @@ -1511,9 +1511,11 @@ TABLE. =cut sub vfieldpart_hashref { - my ($table) = @_; + my $self = shift; + my $table = $self->table; + + return {} unless $self->dbdef->table('part_virtual_field'); - return () unless $table; my $dbh = dbh; my $statement = "SELECT vfieldpart, name FROM part_virtual_field WHERE ". "dbtable = '$table'";