fixes #1763 - DLNA crashes when trying to get movies list

This commit is contained in:
Luke Pulverenti 2016-05-23 01:29:51 -04:00
parent 23e3a6caec
commit 0963717643

View File

@ -1827,7 +1827,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
return " ORDER BY " + string.Join(",", query.SortBy.Select(i =>
{
var columnMap = MapOrderByField(i);
var columnMap = MapOrderByField(i, EnableJoinUserData(query));
var columnAscending = isAscending;
if (columnMap.Item2)
{
@ -1840,7 +1840,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
}).ToArray());
}
private Tuple<string, bool> MapOrderByField(string name)
private Tuple<string, bool> MapOrderByField(string name, bool enableUserData)
{
if (string.Equals(name, ItemSortBy.AirTime, StringComparison.OrdinalIgnoreCase))
{
@ -1855,6 +1855,13 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
return new Tuple<string, bool>("RANDOM()", false);
}
if (string.Equals(name, ItemSortBy.IsFolder, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("IsFolder", true);
}
if (enableUserData)
{
if (string.Equals(name, ItemSortBy.DatePlayed, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("LastPlayedDate", false);
@ -1867,10 +1874,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
return new Tuple<string, bool>("IsFavorite", true);
}
if (string.Equals(name, ItemSortBy.IsFolder, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("IsFolder", true);
}
if (string.Equals(name, ItemSortBy.IsPlayed, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("played", true);
@ -1879,6 +1882,31 @@ namespace MediaBrowser.Server.Implementations.Persistence
{
return new Tuple<string, bool>("played", false);
}
}
else
{
if (string.Equals(name, ItemSortBy.DatePlayed, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("DateCreated", false);
}
if (string.Equals(name, ItemSortBy.PlayCount, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("DateCreated", false);
}
if (string.Equals(name, ItemSortBy.IsFavoriteOrLiked, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("DateCreated", true);
}
if (string.Equals(name, ItemSortBy.IsPlayed, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("DateCreated", true);
}
if (string.Equals(name, ItemSortBy.IsUnplayed, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("DateCreated", false);
}
}
if (string.Equals(name, ItemSortBy.DateLastContentAdded, StringComparison.OrdinalIgnoreCase))
{
return new Tuple<string, bool>("DateLastMediaAdded", false);
@ -2418,6 +2446,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@NameLessThan", DbType.String).Value = query.NameLessThan.ToLower();
}
if (EnableJoinUserData(query))
{
if (query.IsLiked.HasValue)
{
if (query.IsLiked.Value)
@ -2458,8 +2488,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
cmd.Parameters.Add(cmd, "@IsFavorite", DbType.Boolean).Value = query.IsFavorite.Value;
}
if (EnableJoinUserData(query))
{
if (query.IsPlayed.HasValue)
{
if (query.IsPlayed.Value)
@ -2472,7 +2500,6 @@ namespace MediaBrowser.Server.Implementations.Persistence
}
cmd.Parameters.Add(cmd, "@IsPlayed", DbType.Boolean).Value = query.IsPlayed.Value;
}
}
if (query.IsResumable.HasValue)
{
@ -2485,6 +2512,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add("(playbackPositionTicks is null or playbackPositionTicks = 0)");
}
}
}
if (query.ArtistNames.Length > 0)
{