This commit was generated by cvs2svn to compensate for changes in r11022,
[freeside.git] / FS / FS / part_event / Condition.pm
index 90b8385..efe0d3c 100644 (file)
@@ -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<condition> method.
+records which must be returned and tested with the B<condition> method.
 
 =cut
 
@@ -457,6 +457,21 @@ sub age2seconds_sql {
 
 }
 
+=item condition_sql_option_integer OPTION [ DRIVER_NAME ]
+
+As I<condition_sql_option>, but cast the option value to an integer so that
+comparison to other integers is type-correct.
+
+=cut
+
+sub condition_sql_option_integer {
+  my ($class, $option, $driver_name) = @_;
+
+  my $integer = ($driver_name =~ /^mysql/) ? 'UNSIGNED INTEGER' : 'INTEGER';
+
+  'CAST('. $class->condition_sql_option($option). " AS $integer )";
+}
+
 =head1 NEW CONDITION CLASSES
 
 A module should be added in FS/FS/part_event/Condition/ which implements the