View Single Post
Old 04-07-2012, 03:44 PM   #317
ScuttleSE
Junior Member
ScuttleSE began at the beginning.
 
Posts: 2
Karma: 10
Join Date: Apr 2012
Device: Kindle
I've been tearing my hair out trying to get Calibre to search for authors/titles in all upper/lowercase without much success. Today I made a discovery though.

I went directly to the database and queried the tables themselves, and these were the results:

All the authors are stored in a table called... well, "authors"

If I do a query like this:

Code:
select * from authors where name = "George R.R. Martin"
I get one line with a result, which is just as it is supposed to be

Not that difficult. Now when I do this query:

Code:
select * from authors where name = "GEORGE R.R. MARTIN"
I get the same result. meaning that the database ignores the case when doing a search. "GeOrGe r.r. MartIN" is the same as "George R.R. Martin".

I found out a way to counteract this however. If I do this search:


Code:
select * from authors where name = "GEORGE R.R. MARTIN" collate binary
I get no hits. The query now takes case into account.
With this information I could now create this query to find all authors that were in all caps:

Code:
select * from authors where name = upper(name) collate binary
And for book titles, the query looks almost identical:

Code:
select * from books where title = upper(title) collate binary
For lowercase titles/authors you make a similar query

Code:
select * from books where title = lower(title) collate binary
select * from authors where name = lower(name) collate binary
So... would it be possible for you to implement these searches in the plugin? Authors and titles that are in all upper/lowercase?
ScuttleSE is offline   Reply With Quote