5 description => "Some rules are not saved when left blank while editing a 'rule' line in smart-rules.pl",
8 my ($dbh, $out) = @$args{qw(dbh out)};
9 my %default_rule_values = (
12 unseen_renewals_allowed => '',
14 decreaseloanholds => '',
16 while (my ($rule_name, $rule_value) = each (%default_rule_values)) {
18 INSERT IGNORE INTO circulation_rules (branchcode, categorycode, itemtype, rule_name, rule_value)
19 SELECT branchcode, categorycode, itemtype, ?, ? FROM circulation_rules cr
21 SELECT * FROM circulation_rules cr2
23 cr2.rule_name="suspension_chargeperiod"
24 AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) )
25 AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) )
26 AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) )
29 SELECT * FROM circulation_rules cr2
32 AND ( (cr2.branchcode=cr.branchcode) OR ( ISNULL(cr2.branchcode) AND ISNULL(cr.branchcode) ) )
33 AND ( (cr2.categorycode=cr.categorycode) OR ( ISNULL(cr2.categorycode) AND ISNULL(cr.categorycode) ) )
34 AND ( (cr2.itemtype=cr.itemtype) OR ( ISNULL(cr2.itemtype) AND ISNULL(cr.itemtype) ) )
36 GROUP BY branchcode, categorycode, itemtype
37 }, undef, $rule_name, $rule_value, $rule_name);
39 say $out "Add default values for blank circulation rules that weren't saved to the database";