X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event%2FCondition.pm;h=b62440750fcbb20f35def0ae90ca332cac5ab188;hb=b79a8cb932946c849328a3c117c35821d9d21e66;hp=9155a7d42ddbcf44cbf6bc5bd7be632a81c99dd7;hpb=b286341305ba302c4a555aeef288f84c7141ccdd;p=freeside.git diff --git a/FS/FS/part_event/Condition.pm b/FS/FS/part_event/Condition.pm index 9155a7d42..b62440750 100644 --- a/FS/FS/part_event/Condition.pm +++ b/FS/FS/part_event/Condition.pm @@ -145,7 +145,7 @@ passed as an argument. This method is used for optimizing event queries. You may want to add indices for any columns referenced. It is acceptable to return an SQL fragment which partially tests the condition; doing so will still reduce the number of -records which much be returned and tested with the B method. +records which must be returned and tested with the B method. =cut @@ -457,7 +457,7 @@ sub age2seconds_sql { } -=item condition_sql_option_integer +=item condition_sql_option_integer OPTION [ DRIVER_NAME ] As I, but cast the option value to an integer so that comparison to other integers is type-correct. @@ -465,8 +465,14 @@ comparison to other integers is type-correct. =cut sub condition_sql_option_integer { - my ($class, $option) = @_; - 'CAST ('.$class->condition_sql_option($option).' AS INTEGER)'; + my ($class, $option, $driver_name) = @_; + + my $integer = ($driver_name =~ /^mysql/) ? 'UNSIGNED INTEGER' : 'INTEGER'; + + 'CAST( + COALESCE('. $class->condition_sql_option($option). + " ,'0') ". + " AS $integer )"; } =head1 NEW CONDITION CLASSES