浏览代码

fix artist case sensitivity searches

Luke Pulverenti 9 年之前
父节点
当前提交
7835d3d629

+ 1 - 1
MediaBrowser.Api/StartupWizardService.cs

@@ -117,7 +117,7 @@ namespace MediaBrowser.Api
             config.EnableStandaloneMusicKeys = true;
             config.EnableStandaloneMusicKeys = true;
             config.EnableCaseSensitiveItemIds = true;
             config.EnableCaseSensitiveItemIds = true;
             //config.EnableFolderView = true;
             //config.EnableFolderView = true;
-            config.SchemaVersion = 108;
+            config.SchemaVersion = 109;
         }
         }
 
 
         public void Post(UpdateStartupConfiguration request)
         public void Post(UpdateStartupConfiguration request)

+ 22 - 12
MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs

@@ -95,7 +95,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
         private IDbCommand _updateInheritedRatingCommand;
         private IDbCommand _updateInheritedRatingCommand;
         private IDbCommand _updateInheritedTagsCommand;
         private IDbCommand _updateInheritedTagsCommand;
 
 
-        public const int LatestSchemaVersion = 108;
+        public const int LatestSchemaVersion = 109;
 
 
         /// <summary>
         /// <summary>
         /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
         /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
@@ -915,7 +915,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                     }
                     }
                     else
                     else
                     {
                     {
-                        _saveItemCommand.GetParameter(index++).Value = item.Name.RemoveDiacritics();
+                        _saveItemCommand.GetParameter(index++).Value = GetCleanValue(item.Name);
                     }
                     }
 
 
                     _saveItemCommand.GetParameter(index++).Value = item.PresentationUniqueKey;
                     _saveItemCommand.GetParameter(index++).Value = item.PresentationUniqueKey;
@@ -2763,13 +2763,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
             if (!string.IsNullOrWhiteSpace(query.Name))
             if (!string.IsNullOrWhiteSpace(query.Name))
             {
             {
                 whereClauses.Add("CleanName=@Name");
                 whereClauses.Add("CleanName=@Name");
-                cmd.Parameters.Add(cmd, "@Name", DbType.String).Value = query.Name.RemoveDiacritics();
+                cmd.Parameters.Add(cmd, "@Name", DbType.String).Value = GetCleanValue(query.Name);
             }
             }
 
 
             if (!string.IsNullOrWhiteSpace(query.NameContains))
             if (!string.IsNullOrWhiteSpace(query.NameContains))
             {
             {
                 whereClauses.Add("CleanName like @NameContains");
                 whereClauses.Add("CleanName like @NameContains");
-                cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + query.NameContains.RemoveDiacritics() + "%";
+                cmd.Parameters.Add(cmd, "@NameContains", DbType.String).Value = "%" + GetCleanValue(query.NameContains) + "%";
             }
             }
             if (!string.IsNullOrWhiteSpace(query.NameStartsWith))
             if (!string.IsNullOrWhiteSpace(query.NameStartsWith))
             {
             {
@@ -2877,7 +2877,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 foreach (var artist in query.ArtistNames)
                 foreach (var artist in query.ArtistNames)
                 {
                 {
                     clauses.Add("@ArtistName" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
                     clauses.Add("@ArtistName" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
-                    cmd.Parameters.Add(cmd, "@ArtistName" + index, DbType.String).Value = artist.RemoveDiacritics();
+                    cmd.Parameters.Add(cmd, "@ArtistName" + index, DbType.String).Value = GetCleanValue(artist);
                     index++;
                     index++;
                 }
                 }
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
@@ -2894,7 +2894,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                     if (artistItem != null)
                     if (artistItem != null)
                     {
                     {
                         clauses.Add("@ExcludeArtistName" + index + " not in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
                         clauses.Add("@ExcludeArtistName" + index + " not in (select CleanValue from itemvalues where ItemId=Guid and Type <= 1)");
-                        cmd.Parameters.Add(cmd, "@ExcludeArtistName" + index, DbType.String).Value = artistItem.Name.RemoveDiacritics();
+                        cmd.Parameters.Add(cmd, "@ExcludeArtistName" + index, DbType.String).Value = GetCleanValue(artistItem.Name);
                         index++;
                         index++;
                     }
                     }
                 }
                 }
@@ -2915,7 +2915,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 foreach (var item in query.Genres)
                 foreach (var item in query.Genres)
                 {
                 {
                     clauses.Add("@Genre" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=2)");
                     clauses.Add("@Genre" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=2)");
-                    cmd.Parameters.Add(cmd, "@Genre" + index, DbType.String).Value = item.RemoveDiacritics();
+                    cmd.Parameters.Add(cmd, "@Genre" + index, DbType.String).Value = GetCleanValue(item);
                     index++;
                     index++;
                 }
                 }
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
@@ -2929,7 +2929,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 foreach (var item in query.Tags)
                 foreach (var item in query.Tags)
                 {
                 {
                     clauses.Add("@Tag" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=4)");
                     clauses.Add("@Tag" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=4)");
-                    cmd.Parameters.Add(cmd, "@Tag" + index, DbType.String).Value = item.RemoveDiacritics();
+                    cmd.Parameters.Add(cmd, "@Tag" + index, DbType.String).Value = GetCleanValue(item);
                     index++;
                     index++;
                 }
                 }
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
@@ -2949,7 +2949,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 foreach (var item in query.Studios)
                 foreach (var item in query.Studios)
                 {
                 {
                     clauses.Add("@Studio" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=3)");
                     clauses.Add("@Studio" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=3)");
-                    cmd.Parameters.Add(cmd, "@Studio" + index, DbType.String).Value = item.RemoveDiacritics();
+                    cmd.Parameters.Add(cmd, "@Studio" + index, DbType.String).Value = GetCleanValue(item);
                     index++;
                     index++;
                 }
                 }
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
@@ -2963,7 +2963,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 foreach (var item in query.Keywords)
                 foreach (var item in query.Keywords)
                 {
                 {
                     clauses.Add("@Keyword" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=5)");
                     clauses.Add("@Keyword" + index + " in (select CleanValue from itemvalues where ItemId=Guid and Type=5)");
-                    cmd.Parameters.Add(cmd, "@Keyword" + index, DbType.String).Value = item.RemoveDiacritics();
+                    cmd.Parameters.Add(cmd, "@Keyword" + index, DbType.String).Value = GetCleanValue(item);
                     index++;
                     index++;
                 }
                 }
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
                 var clause = "(" + string.Join(" OR ", clauses.ToArray()) + ")";
@@ -3298,6 +3298,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
             return whereClauses;
             return whereClauses;
         }
         }
 
 
+        private string GetCleanValue(string value)
+        {
+            if (string.IsNullOrWhiteSpace(value))
+            {
+                return value;
+            }
+
+            return value.RemoveDiacritics().ToLower();
+        }
+
         private bool EnableGroupByPresentationUniqueKey(InternalItemsQuery query)
         private bool EnableGroupByPresentationUniqueKey(InternalItemsQuery query)
         {
         {
             if (!query.GroupByPresentationUniqueKey)
             if (!query.GroupByPresentationUniqueKey)
@@ -4024,7 +4034,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                     ? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
                     ? (CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)
                     : CommandBehavior.SequentialAccess;
                     : CommandBehavior.SequentialAccess;
 
 
-                //Logger.Debug("GetItemValues: " + cmd.CommandText);
+                Logger.Debug("GetItemValues: " + cmd.CommandText);
 
 
                 using (var reader = cmd.ExecuteReader(commandBehavior))
                 using (var reader = cmd.ExecuteReader(commandBehavior))
                 {
                 {
@@ -4268,7 +4278,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
                 }
                 }
                 else
                 else
                 {
                 {
-                    _saveItemValuesCommand.GetParameter(3).Value = pair.Item2.RemoveDiacritics();
+                    _saveItemValuesCommand.GetParameter(3).Value = GetCleanValue(pair.Item2);
                 }
                 }
                 _saveItemValuesCommand.Transaction = transaction;
                 _saveItemValuesCommand.Transaction = transaction;