Kobo driver has error when rating column used for shelves

Bug #1253637 reported by David Forrester
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Unassigned

Bug Description

As reported in http://www.mobileread.com/forums/showthread.php?t=227486. If the rating column is used for a shelf column, then there is an error when building the collection list. The error is because the rating is a number rather than a string. This would also happen for other number columns.

The fix is to convert to a string, but the rating column needs to be divided by 2.

Tags: kobo-driver
Revision history for this message
David Forrester (davidfor) wrote :
Revision history for this message
Kovid Goyal (kovid) wrote : Fixed in master

Fixed in branch master. The fix will be in the next release. calibre is usually released every Friday.

 status fixreleased

Changed in calibre:
status: New → Fix Released
Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1253637

I made some changes to use unicode and ensure float division.

Revision history for this message
David Forrester (davidfor) wrote :

I keep forgetting about unicode :)

But, I'm not so sure about the division change. Calibre only shows and displays integer values between 1 and 5. With this, it means the collection name is "1.0" instead of just "1". I think that is inconsistent. If the plan is to have calibre use half star ratings, then you are right.

Having said that, when I tested it and looked at it on my Glo, the "1.0" version looks a lot better. I will stick with that unless I get to many complaints.

Revision history for this message
Kovid Goyal (kovid) wrote :

Ratings in calibre are stored as floats in the range 0-10. If you want
to always display an int, use int(rating / 2.0). That makes it clear
that you are deliberately converting the float to an int. Otherwise, you
will sometimes get an int and sometimes a float, depending on the value
of rating.

If you wish to follow calibre's system for displaying stars, you can do
u'\u2605'*int(rating / 2.0) assuming the Kobo's are capable of
displaying the unicode star character.

Revision history for this message
David Forrester (davidfor) wrote :

I looked at the database when I made the change and before my earlier reply. The column is defined as "rating INTEGER CHECK(rating > -1 AND rating < 11)". And that seems to be what is in database.py. Have I missed something?

As to the stars, it wouldn't surprise me if they can be displayed. But, the name is used in a couple of ways, so I'm not going to risk it.

Revision history for this message
Kovid Goyal (kovid) wrote :

The problem isn't the db, although IIRC sqlite does not enforce type
constraints, so it is possible to store floats in an integer column.
However, calibre code in general treats ratings as floating points in
many contexts, for example when calculating averag4e ratings in the Tag
Browser. Therefore, it is better to code defensively and explicitly
convert to int, so you can be sure of what you get.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.