I've submitted a fix to Kovid.
The specific problem is that the fake metadata for your rating column is text, which can't convert to a number. You can work around the problem until my fix is released by changing
Code:
miVal = field ("#mi_val");
to
Code:
miVal = format_number($#mi_val, 'd');
The format_number() function changes invalid text to the empty string, which is interpreted as 0 in a numeric context.