aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs30
1 files changed, 27 insertions, 3 deletions
diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
index bf95fa612..5c6adced6 100644
--- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
+++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs
@@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _updateInheritedRatingCommand;
- private const int LatestSchemaVersion = 32;
+ private const int LatestSchemaVersion = 37;
/// <summary>
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
@@ -223,6 +223,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(_logger, "TypedBaseItems", "IsFolder", "BIT");
_connection.AddColumn(_logger, "TypedBaseItems", "InheritedParentalRatingValue", "INT");
_connection.AddColumn(_logger, "TypedBaseItems", "UnratedType", "Text");
+ _connection.AddColumn(_logger, "TypedBaseItems", "TopParentId", "Text");
PrepareStatements();
@@ -451,7 +452,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"ExternalServiceId",
"Tags",
"IsFolder",
- "UnratedType"
+ "UnratedType",
+ "TopParentId"
};
_saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@@ -725,7 +727,17 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = item.IsFolder;
_saveItemCommand.GetParameter(index++).Value = item.GetBlockUnratedType().ToString();
-
+
+ var topParent = item.GetTopParent();
+ if (topParent != null)
+ {
+ _saveItemCommand.GetParameter(index++).Value = topParent.Id.ToString("N");
+ }
+ else
+ {
+ _saveItemCommand.GetParameter(index++).Value = null;
+ }
+
_saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery();
@@ -1940,6 +1952,18 @@ namespace MediaBrowser.Server.Implementations.Persistence
whereClauses.Add("LocationType not in (" + val + ")");
}
+ if (query.TopParentIds.Length == 1)
+ {
+ whereClauses.Add("(TopParentId is null or TopParentId=@TopParentId)");
+ cmd.Parameters.Add(cmd, "@TopParentId", DbType.String).Value = query.TopParentIds[0];
+ }
+ if (query.TopParentIds.Length > 1)
+ {
+ var val = string.Join(",", query.TopParentIds.Select(i => "'" + i + "'").ToArray());
+
+ whereClauses.Add("(TopParentId is null or TopParentId in (" + val + "))");
+ }
+
if (query.AncestorIds.Length == 1)
{
whereClauses.Add("Guid in (select itemId from AncestorIds where AncestorId=@AncestorId)");