From 37a9d8ef20ea468507e63f6969938dc820f32d73 Mon Sep 17 00:00:00 2001 From: Patrick Klein Date: Tue, 17 Apr 2018 18:04:06 -0700 Subject: [PATCH] ignore case when ordering --- resources/lib/database_handler.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/resources/lib/database_handler.py b/resources/lib/database_handler.py index 9145358..d98e2d3 100644 --- a/resources/lib/database_handler.py +++ b/resources/lib/database_handler.py @@ -52,12 +52,14 @@ def get_content_items(self, status, mediatype=None): if mediatype: self.c.execute( "SELECT * FROM Content WHERE Status=? AND Mediatype=? \ - ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) ELSE Title END)", + ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) \ + ELSE Title END) COLLATE NOCASE", (status, mediatype)) else: self.c.execute( "SELECT * FROM Content WHERE Status=? \ - ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) ELSE Title END)", + ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) \ + ELSE Title END) COLLATE NOCASE", (status,)) # get results and return items as objects rows = self.c.fetchall() @@ -70,7 +72,8 @@ def get_all_shows(self, status): # query database self.c.execute( "SELECT DISTINCT Show_Title FROM Content WHERE Status=? \ - ORDER BY (CASE WHEN Show_Title LIKE 'the %' THEN substr(Show_Title,5) ELSE Show_Title END)", + ORDER BY (CASE WHEN Show_Title LIKE 'the %' THEN substr(Show_Title,5) \ + ELSE Show_Title END) COLLATE NOCASE", (status,)) # get results and return items as list rows = self.c.fetchall() @@ -83,7 +86,8 @@ def get_show_episodes(self, status, show_title): # query database self.c.execute( "SELECT * FROM Content WHERE Status=? AND Show_Title=?\ - ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) ELSE Title END)", + ORDER BY (CASE WHEN Title LIKE 'the %' THEN substr(Title,5) \ + ELSE Title END) COLLATE NOCASE", (status, show_title)) # get results and return items as objects rows = self.c.fetchall() @@ -196,7 +200,8 @@ def get_synced_dirs(self): # query database self.c.execute( "SELECT * FROM Synced \ - ORDER BY (CASE WHEN Label LIKE 'the %' THEN substr(Label,5) ELSE Label END)") + ORDER BY (CASE WHEN Label LIKE 'the %' THEN substr(Label,5) \ + ELSE Label END) COLLATE NOCASE") # get results and return as list of dicts rows = self.c.fetchall() return [self.synced_item_dict(x) for x in rows] @@ -232,7 +237,7 @@ def remove_all_synced_dirs(self): def get_blocked_items(self): ''' Returns all items in Blocked as a list of dicts ''' self.c.execute( - "SELECT * FROM Blocked ORDER BY Value, Type") + "SELECT * FROM Blocked ORDER BY Type, Value") rows = self.c.fetchall() return [self.blocked_item_dict(x) for x in rows]