Merge branch 'master' into sqlite_client_poc
# Conflicts: # Emby.Server.Implementations/Data/SqliteItemRepository.cs
This commit is contained in:
commit
c24571b5b8
|
@ -26,7 +26,6 @@ using MediaBrowser.Controller.Entities.Audio;
|
||||||
using MediaBrowser.Controller.Entities.Movies;
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
using MediaBrowser.Controller.Entities.TV;
|
using MediaBrowser.Controller.Entities.TV;
|
||||||
using MediaBrowser.Controller.Extensions;
|
using MediaBrowser.Controller.Extensions;
|
||||||
using MediaBrowser.Controller.Library;
|
|
||||||
using MediaBrowser.Controller.LiveTv;
|
using MediaBrowser.Controller.LiveTv;
|
||||||
using MediaBrowser.Controller.Persistence;
|
using MediaBrowser.Controller.Persistence;
|
||||||
using MediaBrowser.Controller.Playlists;
|
using MediaBrowser.Controller.Playlists;
|
||||||
|
@ -1291,88 +1290,27 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (_config.Configuration.SkipDeserializationForBasicTypes)
|
if (_config.Configuration.SkipDeserializationForBasicTypes)
|
||||||
{
|
{
|
||||||
if (type == typeof(Channel))
|
if (type == typeof(Channel)
|
||||||
{
|
|| type == typeof(UserRootFolder))
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(UserRootFolder))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == typeof(Season))
|
return type != typeof(Season)
|
||||||
{
|
&& type != typeof(MusicArtist)
|
||||||
return false;
|
&& type != typeof(Person)
|
||||||
}
|
&& type != typeof(MusicGenre)
|
||||||
|
&& type != typeof(Genre)
|
||||||
if (type == typeof(MusicArtist))
|
&& type != typeof(Studio)
|
||||||
{
|
&& type != typeof(PlaylistsFolder)
|
||||||
return false;
|
&& type != typeof(PhotoAlbum)
|
||||||
}
|
&& type != typeof(Year)
|
||||||
|
&& type != typeof(Book)
|
||||||
if (type == typeof(Person))
|
&& type != typeof(LiveTvProgram)
|
||||||
{
|
&& type != typeof(AudioBook)
|
||||||
return false;
|
&& type != typeof(Audio)
|
||||||
}
|
&& type != typeof(MusicAlbum);
|
||||||
|
|
||||||
if (type == typeof(MusicGenre))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(Genre))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(Studio))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(PlaylistsFolder))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(PhotoAlbum))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(Year))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(Book))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(LiveTvProgram))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(AudioBook))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(Audio))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (type == typeof(MusicAlbum))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BaseItem GetItem(SqliteDataReader reader, InternalItemsQuery query)
|
private BaseItem GetItem(SqliteDataReader reader, InternalItemsQuery query)
|
||||||
|
@ -2078,7 +2016,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
insertText.AppendFormat(CultureInfo.InvariantCulture, "(@ItemId, @ChapterIndex{0}, @StartPositionTicks{0}, @Name{0}, @ImagePath{0}, @ImageDateModified{0}),", i.ToString(CultureInfo.InvariantCulture));
|
insertText.AppendFormat(CultureInfo.InvariantCulture, "(@ItemId, @ChapterIndex{0}, @StartPositionTicks{0}, @Name{0}, @ImagePath{0}, @ImageDateModified{0}),", i.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
insertText.Length -= 1; // Remove last ,
|
insertText.Length -= 1; // Remove trailing comma
|
||||||
|
|
||||||
using (var statement = PrepareStatement(db, insertText.ToString()))
|
using (var statement = PrepareStatement(db, insertText.ToString()))
|
||||||
{
|
{
|
||||||
|
@ -3573,7 +3511,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
statement?.TryBind(paramName, "%" + trailerTypes[i] + "%");
|
statement?.TryBind(paramName, "%" + trailerTypes[i] + "%");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove last " OR "
|
|
||||||
clauseBuilder.Length -= Or.Length;
|
clauseBuilder.Length -= Or.Length;
|
||||||
clauseBuilder.Append(')');
|
clauseBuilder.Append(')');
|
||||||
|
|
||||||
|
@ -3620,7 +3557,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove last " OR "
|
|
||||||
clauseBuilder.Length -= Or.Length;
|
clauseBuilder.Length -= Or.Length;
|
||||||
clauseBuilder.Append(')');
|
clauseBuilder.Append(')');
|
||||||
|
|
||||||
|
@ -3787,215 +3723,219 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
if (query.ArtistIds.Length > 0)
|
if (query.ArtistIds.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.ArtistIds.Length; i++)
|
||||||
foreach (var artistId in query.ArtistIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@ArtistIds" + index;
|
clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@ArtistIds")
|
||||||
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, artistId);
|
.Append(") and Type<=1)) OR ");
|
||||||
index++;
|
statement?.TryBind("@ArtistIds" + i, query.ArtistIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.AlbumArtistIds.Length > 0)
|
if (query.AlbumArtistIds.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.AlbumArtistIds.Length; i++)
|
||||||
foreach (var artistId in query.AlbumArtistIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@ArtistIds" + index;
|
clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@ArtistIds")
|
||||||
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=1))");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, artistId);
|
.Append(") and Type=1)) OR ");
|
||||||
index++;
|
statement?.TryBind("@ArtistIds" + i, query.AlbumArtistIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.ContributingArtistIds.Length > 0)
|
if (query.ContributingArtistIds.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.ContributingArtistIds.Length; i++)
|
||||||
foreach (var artistId in query.ContributingArtistIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@ArtistIds" + index;
|
clauseBuilder.Append("((select CleanName from TypedBaseItems where guid=@ArtistIds")
|
||||||
clauses.Add("((select CleanName from TypedBaseItems where guid=" + paramName + ") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=" + paramName + ") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1))");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, artistId);
|
.Append(") in (select CleanValue from ItemValues where ItemId=Guid and Type=0) AND (select CleanName from TypedBaseItems where guid=@ArtistIds")
|
||||||
index++;
|
.Append(i)
|
||||||
|
.Append(") not in (select CleanValue from ItemValues where ItemId=Guid and Type=1)) OR ");
|
||||||
|
statement?.TryBind("@ArtistIds" + i, query.ContributingArtistIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.AlbumIds.Length > 0)
|
if (query.AlbumIds.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.AlbumIds.Length; i++)
|
||||||
foreach (var albumId in query.AlbumIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@AlbumIds" + index;
|
clauseBuilder.Append("Album in (select Name from typedbaseitems where guid=@AlbumIds")
|
||||||
clauses.Add("Album in (select Name from typedbaseitems where guid=" + paramName + ")");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, albumId);
|
.Append(") OR ");
|
||||||
index++;
|
statement?.TryBind("@AlbumIds" + i, query.AlbumIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.ExcludeArtistIds.Length > 0)
|
if (query.ExcludeArtistIds.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.ExcludeArtistIds.Length; i++)
|
||||||
foreach (var artistId in query.ExcludeArtistIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@ExcludeArtistId" + index;
|
clauseBuilder.Append("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@ExcludeArtistId")
|
||||||
clauses.Add("(guid not in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type<=1))");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, artistId);
|
.Append(") and Type<=1)) OR ");
|
||||||
index++;
|
statement?.TryBind("@ExcludeArtistId" + i, query.ExcludeArtistIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.GenreIds.Count > 0)
|
if (query.GenreIds.Count > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.GenreIds.Count; i++)
|
||||||
foreach (var genreId in query.GenreIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@GenreId" + index;
|
clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@GenreId")
|
||||||
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=2))");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, genreId);
|
.Append(") and Type=2)) OR ");
|
||||||
index++;
|
statement?.TryBind("@GenreId" + i, query.GenreIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.Genres.Count > 0)
|
if (query.Genres.Count > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.Genres.Count; i++)
|
||||||
foreach (var item in query.Genres)
|
|
||||||
{
|
{
|
||||||
clauses.Add("@Genre" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=2)");
|
clauseBuilder.Append("@Genre")
|
||||||
statement?.TryBind("@Genre" + index, GetCleanValue(item));
|
.Append(i)
|
||||||
index++;
|
.Append(" in (select CleanValue from ItemValues where ItemId=Guid and Type=2) OR ");
|
||||||
|
statement?.TryBind("@Genre" + i, GetCleanValue(query.Genres[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tags.Count > 0)
|
if (tags.Count > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < tags.Count; i++)
|
||||||
foreach (var item in tags)
|
|
||||||
{
|
{
|
||||||
clauses.Add("@Tag" + index + " in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
|
clauseBuilder.Append("@Tag")
|
||||||
statement?.TryBind("@Tag" + index, GetCleanValue(item));
|
.Append(i)
|
||||||
index++;
|
.Append(" in (select CleanValue from ItemValues where ItemId=Guid and Type=4) OR ");
|
||||||
|
statement?.TryBind("@Tag" + i, GetCleanValue(tags[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (excludeTags.Count > 0)
|
if (excludeTags.Count > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < excludeTags.Count; i++)
|
||||||
foreach (var item in excludeTags)
|
|
||||||
{
|
{
|
||||||
clauses.Add("@ExcludeTag" + index + " not in (select CleanValue from ItemValues where ItemId=Guid and Type=4)");
|
clauseBuilder.Append("@ExcludeTag")
|
||||||
statement?.TryBind("@ExcludeTag" + index, GetCleanValue(item));
|
.Append(i)
|
||||||
index++;
|
.Append(" not in (select CleanValue from ItemValues where ItemId=Guid and Type=4) OR ");
|
||||||
|
statement?.TryBind("@ExcludeTag" + i, GetCleanValue(excludeTags[i]));
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.StudioIds.Length > 0)
|
if (query.StudioIds.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.StudioIds.Length; i++)
|
||||||
foreach (var studioId in query.StudioIds)
|
|
||||||
{
|
{
|
||||||
var paramName = "@StudioId" + index;
|
clauseBuilder.Append("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=@StudioId")
|
||||||
clauses.Add("(guid in (select itemid from ItemValues where CleanValue = (select CleanName from TypedBaseItems where guid=" + paramName + ") and Type=3))");
|
.Append(i)
|
||||||
statement?.TryBind(paramName, studioId);
|
.Append(") and Type=3)) OR ");
|
||||||
index++;
|
statement?.TryBind("@StudioId" + i, query.StudioIds[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.OfficialRatings.Length > 0)
|
if (query.OfficialRatings.Length > 0)
|
||||||
{
|
{
|
||||||
var clauses = new List<string>();
|
clauseBuilder.Append('(');
|
||||||
var index = 0;
|
for (var i = 0; i < query.OfficialRatings.Length; i++)
|
||||||
foreach (var item in query.OfficialRatings)
|
|
||||||
{
|
{
|
||||||
clauses.Add("OfficialRating=@OfficialRating" + index);
|
clauseBuilder.Append("OfficialRating=@OfficialRating").Append(i).Append(Or);
|
||||||
statement?.TryBind("@OfficialRating" + index, item);
|
statement?.TryBind("@OfficialRating" + i, query.OfficialRatings[i]);
|
||||||
index++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var clause = "(" + string.Join(" OR ", clauses) + ")";
|
clauseBuilder.Length -= Or.Length;
|
||||||
whereClauses.Add(clause);
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ratingClauseBuilder = new StringBuilder("(");
|
clauseBuilder.Append('(');
|
||||||
if (query.HasParentalRating ?? false)
|
if (query.HasParentalRating ?? false)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append("InheritedParentalRatingValue not null");
|
clauseBuilder.Append("InheritedParentalRatingValue not null");
|
||||||
if (query.MinParentalRating.HasValue)
|
if (query.MinParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(" AND InheritedParentalRatingValue >= @MinParentalRating");
|
clauseBuilder.Append(" AND InheritedParentalRatingValue >= @MinParentalRating");
|
||||||
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
|
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.MaxParentalRating.HasValue)
|
if (query.MaxParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
|
clauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
|
||||||
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (query.BlockUnratedItems.Length > 0)
|
else if (query.BlockUnratedItems.Length > 0)
|
||||||
{
|
{
|
||||||
var paramName = "@UnratedType";
|
const string ParamName = "@UnratedType";
|
||||||
var index = 0;
|
clauseBuilder.Append("(InheritedParentalRatingValue is null AND UnratedType not in (");
|
||||||
string blockedUnratedItems = string.Join(',', query.BlockUnratedItems.Select(_ => paramName + index++));
|
|
||||||
ratingClauseBuilder.Append("(InheritedParentalRatingValue is null AND UnratedType not in (" + blockedUnratedItems + "))");
|
|
||||||
|
|
||||||
if (statement is not null)
|
for (int i = 0; i < query.BlockUnratedItems.Length; i++)
|
||||||
{
|
{
|
||||||
for (var ind = 0; ind < query.BlockUnratedItems.Length; ind++)
|
clauseBuilder.Append(ParamName).Append(i).Append(',');
|
||||||
{
|
statement?.TryBind(ParamName + i, query.BlockUnratedItems[i].ToString());
|
||||||
statement.TryBind(paramName + ind, query.BlockUnratedItems[ind].ToString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remove trailing comma
|
||||||
|
clauseBuilder.Length--;
|
||||||
|
clauseBuilder.Append("))");
|
||||||
|
|
||||||
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
|
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(" OR (");
|
clauseBuilder.Append(" OR (");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.MinParentalRating.HasValue)
|
if (query.MinParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append("InheritedParentalRatingValue >= @MinParentalRating");
|
clauseBuilder.Append("InheritedParentalRatingValue >= @MinParentalRating");
|
||||||
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
|
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4003,50 +3943,50 @@ namespace Emby.Server.Implementations.Data
|
||||||
{
|
{
|
||||||
if (query.MinParentalRating.HasValue)
|
if (query.MinParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(" AND ");
|
clauseBuilder.Append(" AND ");
|
||||||
}
|
}
|
||||||
|
|
||||||
ratingClauseBuilder.Append("InheritedParentalRatingValue <= @MaxParentalRating");
|
clauseBuilder.Append("InheritedParentalRatingValue <= @MaxParentalRating");
|
||||||
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
|
if (query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(")");
|
clauseBuilder.Append(')');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue))
|
if (!(query.MinParentalRating.HasValue || query.MaxParentalRating.HasValue))
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(" OR InheritedParentalRatingValue not null");
|
clauseBuilder.Append(" OR InheritedParentalRatingValue not null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (query.MinParentalRating.HasValue)
|
else if (query.MinParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append("InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating");
|
clauseBuilder.Append("InheritedParentalRatingValue is null OR (InheritedParentalRatingValue >= @MinParentalRating");
|
||||||
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
|
statement?.TryBind("@MinParentalRating", query.MinParentalRating.Value);
|
||||||
|
|
||||||
if (query.MaxParentalRating.HasValue)
|
if (query.MaxParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
|
clauseBuilder.Append(" AND InheritedParentalRatingValue <= @MaxParentalRating");
|
||||||
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
ratingClauseBuilder.Append(")");
|
clauseBuilder.Append(')');
|
||||||
}
|
}
|
||||||
else if (query.MaxParentalRating.HasValue)
|
else if (query.MaxParentalRating.HasValue)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append("InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating");
|
clauseBuilder.Append("InheritedParentalRatingValue is null OR InheritedParentalRatingValue <= @MaxParentalRating");
|
||||||
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
statement?.TryBind("@MaxParentalRating", query.MaxParentalRating.Value);
|
||||||
}
|
}
|
||||||
else if (!query.HasParentalRating ?? false)
|
else if (!query.HasParentalRating ?? false)
|
||||||
{
|
{
|
||||||
ratingClauseBuilder.Append("InheritedParentalRatingValue is null");
|
clauseBuilder.Append("InheritedParentalRatingValue is null");
|
||||||
}
|
}
|
||||||
|
|
||||||
var ratingClauseString = ratingClauseBuilder.ToString();
|
if (clauseBuilder.Length > 1)
|
||||||
if (!string.Equals(ratingClauseString, "(", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
{
|
||||||
whereClauses.Add(ratingClauseString + ")");
|
whereClauses.Add(clauseBuilder.Append(')').ToString());
|
||||||
|
clauseBuilder.Length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.HasOfficialRating.HasValue)
|
if (query.HasOfficialRating.HasValue)
|
||||||
|
@ -4533,7 +4473,6 @@ namespace Emby.Server.Implementations.Data
|
||||||
|
|
||||||
return whereClauses;
|
return whereClauses;
|
||||||
}
|
}
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Formats a where clause for the specified provider.
|
/// Formats a where clause for the specified provider.
|
||||||
|
@ -4550,6 +4489,7 @@ namespace Emby.Server.Implementations.Data
|
||||||
provider);
|
provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
private List<string> GetItemByNameTypesInQuery(InternalItemsQuery query)
|
private List<string> GetItemByNameTypesInQuery(InternalItemsQuery query)
|
||||||
{
|
{
|
||||||
var list = new List<string>();
|
var list = new List<string>();
|
||||||
|
@ -4629,17 +4569,12 @@ namespace Emby.Server.Implementations.Data
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.IncludeItemTypes.Contains(BaseItemKind.Episode)
|
return query.IncludeItemTypes.Contains(BaseItemKind.Episode)
|
||||||
|| query.IncludeItemTypes.Contains(BaseItemKind.Video)
|
|| query.IncludeItemTypes.Contains(BaseItemKind.Video)
|
||||||
|| query.IncludeItemTypes.Contains(BaseItemKind.Movie)
|
|| query.IncludeItemTypes.Contains(BaseItemKind.Movie)
|
||||||
|| query.IncludeItemTypes.Contains(BaseItemKind.MusicVideo)
|
|| query.IncludeItemTypes.Contains(BaseItemKind.MusicVideo)
|
||||||
|| query.IncludeItemTypes.Contains(BaseItemKind.Series)
|
|| query.IncludeItemTypes.Contains(BaseItemKind.Series)
|
||||||
|| query.IncludeItemTypes.Contains(BaseItemKind.Season))
|
|| query.IncludeItemTypes.Contains(BaseItemKind.Season);
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateInheritedValues()
|
public void UpdateInheritedValues()
|
||||||
|
@ -4744,20 +4679,20 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type
|
||||||
|
|
||||||
CheckDisposed();
|
CheckDisposed();
|
||||||
|
|
||||||
var commandText = "select ItemId, Name, Role, PersonType, SortOrder from People p";
|
StringBuilder commandText = new StringBuilder("select ItemId, Name, Role, PersonType, SortOrder from People p");
|
||||||
|
|
||||||
var whereClauses = GetPeopleWhereClauses(query, null);
|
var whereClauses = GetPeopleWhereClauses(query, null);
|
||||||
|
|
||||||
if (whereClauses.Count != 0)
|
if (whereClauses.Count != 0)
|
||||||
{
|
{
|
||||||
commandText += " where " + string.Join(" AND ", whereClauses);
|
commandText.Append(" where ").AppendJoin(" AND ", whereClauses);
|
||||||
}
|
}
|
||||||
|
|
||||||
commandText += " order by ListOrder";
|
commandText.Append(" order by ListOrder");
|
||||||
|
|
||||||
if (query.Limit > 0)
|
if (query.Limit > 0)
|
||||||
{
|
{
|
||||||
commandText += " LIMIT " + query.Limit;
|
commandText.Append(" LIMIT ").Append(query.Limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
var list = new List<PersonInfo>();
|
var list = new List<PersonInfo>();
|
||||||
|
@ -4877,7 +4812,7 @@ AND Type = @InternalPersonType)");
|
||||||
i.ToString(CultureInfo.InvariantCulture));
|
i.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove last ,
|
// Remove trailing comma
|
||||||
insertText.Length--;
|
insertText.Length--;
|
||||||
|
|
||||||
using (var statement = PrepareStatement(db, insertText.ToString()))
|
using (var statement = PrepareStatement(db, insertText.ToString()))
|
||||||
|
@ -5402,7 +5337,7 @@ AND Type = @InternalPersonType)");
|
||||||
i);
|
i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove last comma
|
// Remove trailing comma
|
||||||
insertText.Length--;
|
insertText.Length--;
|
||||||
|
|
||||||
using (var statement = PrepareStatement(db, insertText.ToString()))
|
using (var statement = PrepareStatement(db, insertText.ToString()))
|
||||||
|
@ -5480,7 +5415,7 @@ AND Type = @InternalPersonType)");
|
||||||
i.ToString(CultureInfo.InvariantCulture));
|
i.ToString(CultureInfo.InvariantCulture));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove last comma
|
// Remove trailing comma
|
||||||
insertText.Length--;
|
insertText.Length--;
|
||||||
|
|
||||||
using (var statement = PrepareStatement(db, insertText.ToString()))
|
using (var statement = PrepareStatement(db, insertText.ToString()))
|
||||||
|
@ -6007,14 +5942,13 @@ AND Type = @InternalPersonType)");
|
||||||
|
|
||||||
for (var i = startIndex; i < endIndex; i++)
|
for (var i = startIndex; i < endIndex; i++)
|
||||||
{
|
{
|
||||||
var index = i.ToString(CultureInfo.InvariantCulture);
|
|
||||||
insertText.Append("(@ItemId, ");
|
insertText.Append("(@ItemId, ");
|
||||||
|
|
||||||
foreach (var column in _mediaAttachmentSaveColumns.Skip(1))
|
foreach (var column in _mediaAttachmentSaveColumns.Skip(1))
|
||||||
{
|
{
|
||||||
insertText.Append('@')
|
insertText.Append('@')
|
||||||
.Append(column)
|
.Append(column)
|
||||||
.Append(index)
|
.Append(i)
|
||||||
.Append(',');
|
.Append(',');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@
|
||||||
<Rule Id="CA1727" Action="Error" />
|
<Rule Id="CA1727" Action="Error" />
|
||||||
<!-- error on CA1813: Avoid unsealed attributes -->
|
<!-- error on CA1813: Avoid unsealed attributes -->
|
||||||
<Rule Id="CA1813" Action="Error" />
|
<Rule Id="CA1813" Action="Error" />
|
||||||
|
<!-- error on CA1834: Use 'StringBuilder.Append(char)' instead of 'StringBuilder.Append(string)' when the input is a constant unit string -->
|
||||||
|
<Rule Id="CA1834" Action="Error" />
|
||||||
<!-- error on CA1843: Do not use 'WaitAll' with a single task -->
|
<!-- error on CA1843: Do not use 'WaitAll' with a single task -->
|
||||||
<Rule Id="CA1843" Action="Error" />
|
<Rule Id="CA1843" Action="Error" />
|
||||||
<!-- error on CA1845: Use span-based 'string.Concat' -->
|
<!-- error on CA1845: Use span-based 'string.Concat' -->
|
||||||
|
|
Loading…
Reference in New Issue
Block a user