diff options
author | ivan <ivan> | 2010-03-30 02:04:01 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-03-30 02:04:01 +0000 |
commit | 8e0d6410715c534f2994167c83e319a625b2ee0d (patch) | |
tree | 73d3200187a0313e24a5b12580e8c206e95df6fc /FS/FS | |
parent | c1e2f536974812f05b8d3534ad2bf9c9ba40c24d (diff) |
fixes for MySQL CAST drain bramage
Diffstat (limited to 'FS/FS')
-rw-r--r-- | FS/FS/part_event/Condition/balance.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/balance_age.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/balance_under.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/cust_bill_has_service.pm | 6 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/cust_bill_owed.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/cust_bill_owed_under.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_event_condition.pm | 6 |
7 files changed, 13 insertions, 9 deletions
diff --git a/FS/FS/part_event/Condition/balance.pm b/FS/FS/part_event/Condition/balance.pm index 65670c0..3b8854a 100644 --- a/FS/FS/part_event/Condition/balance.pm +++ b/FS/FS/part_event/Condition/balance.pm @@ -40,7 +40,7 @@ sub condition_sql { my $balance_sql = FS::cust_main->balance_sql; - "$balance_sql > CAST( $over AS numeric )"; + "$balance_sql > CAST( $over AS DECIMAL(10,2) )"; } diff --git a/FS/FS/part_event/Condition/balance_age.pm b/FS/FS/part_event/Condition/balance_age.pm index f1a9707..fc34612 100644 --- a/FS/FS/part_event/Condition/balance_age.pm +++ b/FS/FS/part_event/Condition/balance_age.pm @@ -38,7 +38,7 @@ sub condition_sql { my $balance_sql = FS::cust_main->balance_date_sql( $age ); - "$balance_sql > CAST( $over AS numeric )"; + "$balance_sql > CAST( $over AS DECIMAL(10,2) )"; } sub order_sql { diff --git a/FS/FS/part_event/Condition/balance_under.pm b/FS/FS/part_event/Condition/balance_under.pm index 9c71590..2002c70 100644 --- a/FS/FS/part_event/Condition/balance_under.pm +++ b/FS/FS/part_event/Condition/balance_under.pm @@ -34,7 +34,7 @@ sub condition_sql { my $balance_sql = FS::cust_main->balance_sql; - "$balance_sql <= CAST( $under AS numeric )"; + "$balance_sql <= CAST( $under AS DECIMAL(10,2) )"; } diff --git a/FS/FS/part_event/Condition/cust_bill_has_service.pm b/FS/FS/part_event/Condition/cust_bill_has_service.pm index 91d75dd..d85af26 100644 --- a/FS/FS/part_event/Condition/cust_bill_has_service.pm +++ b/FS/FS/part_event/Condition/cust_bill_has_service.pm @@ -38,14 +38,16 @@ sub condition { } sub condition_sql { - my( $class, $table ) = @_; + my( $class, $table, %opt ) = @_; + + my $integer = $opt{'driver_name'} =~ /^mysql/ ? 'UNSIGNED INTEGER' : 'INTEGER'; my $servicenum = $class->condition_sql_option('has_service'); my $sql = qq| 0 < ( SELECT COUNT(cs.svcpart) FROM cust_bill_pkg cbp, cust_svc cs WHERE cbp.invnum = cust_bill.invnum AND cs.pkgnum = cbp.pkgnum - AND cs.svcpart = CAST( $servicenum AS integer ) + AND cs.svcpart = CAST( $servicenum AS $integer ) ) |; return $sql; diff --git a/FS/FS/part_event/Condition/cust_bill_owed.pm b/FS/FS/part_event/Condition/cust_bill_owed.pm index 0fd9922..d8c77c7 100644 --- a/FS/FS/part_event/Condition/cust_bill_owed.pm +++ b/FS/FS/part_event/Condition/cust_bill_owed.pm @@ -48,7 +48,7 @@ sub condition_sql { my $owed_sql = FS::cust_bill->owed_sql; - "$owed_sql > CAST( $over AS numeric )"; + "$owed_sql > CAST( $over AS DECIMAL(10,2) )"; } 1; diff --git a/FS/FS/part_event/Condition/cust_bill_owed_under.pm b/FS/FS/part_event/Condition/cust_bill_owed_under.pm index a0bf92f..4eb6439 100644 --- a/FS/FS/part_event/Condition/cust_bill_owed_under.pm +++ b/FS/FS/part_event/Condition/cust_bill_owed_under.pm @@ -43,7 +43,7 @@ sub condition_sql { my $owed_sql = FS::cust_bill->owed_sql; - "$owed_sql <= CAST( $under AS numeric )"; + "$owed_sql <= CAST( $under AS DECIMAL(10,2) )"; } 1; diff --git a/FS/FS/part_event_condition.pm b/FS/FS/part_event_condition.pm index d13e849..32f19a3 100644 --- a/FS/FS/part_event_condition.pm +++ b/FS/FS/part_event_condition.pm @@ -2,7 +2,7 @@ package FS::part_event_condition; use strict; use vars qw( @ISA $DEBUG @SKIP_CONDITION_SQL ); -use FS::UID qw(dbh); +use FS::UID qw( dbh driver_name ); use FS::Record qw( qsearch qsearchs ); use FS::option_Common; use FS::part_event; #for order_conditions_sql... @@ -285,7 +285,9 @@ sub where_conditions_sql { map { my $conditionname = $_; my $coderef = $conditions{$conditionname}->{condition_sql}; - my $sql = &$coderef( $eventtable, 'time'=>$time ); + my $sql = &$coderef( $eventtable, 'time' => $time, + 'driver_name' => driver_name(), + ); die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE'; "( cond_$conditionname.conditionname IS NULL OR $sql )"; } |