restore people in search

This commit is contained in:
Luke Pulverenti 2016-02-14 00:23:33 -05:00
parent d610711d51
commit f6e3f6c875

View File

@ -80,7 +80,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
private IDbCommand _updateInheritedRatingCommand; private IDbCommand _updateInheritedRatingCommand;
private const int LatestSchemaVersion = 44; private const int LatestSchemaVersion = 45;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SqliteItemRepository"/> class. /// Initializes a new instance of the <see cref="SqliteItemRepository"/> class.
@ -221,6 +221,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.AddColumn(Logger, "TypedBaseItems", "InheritedParentalRatingValue", "INT"); _connection.AddColumn(Logger, "TypedBaseItems", "InheritedParentalRatingValue", "INT");
_connection.AddColumn(Logger, "TypedBaseItems", "UnratedType", "Text"); _connection.AddColumn(Logger, "TypedBaseItems", "UnratedType", "Text");
_connection.AddColumn(Logger, "TypedBaseItems", "TopParentId", "Text"); _connection.AddColumn(Logger, "TypedBaseItems", "TopParentId", "Text");
_connection.AddColumn(Logger, "TypedBaseItems", "IsItemByName", "BIT");
PrepareStatements(); PrepareStatements();
@ -445,7 +446,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"Tags", "Tags",
"IsFolder", "IsFolder",
"UnratedType", "UnratedType",
"TopParentId" "TopParentId",
"IsItemByName"
}; };
_saveItemCommand = _connection.CreateCommand(); _saveItemCommand = _connection.CreateCommand();
_saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values ("; _saveItemCommand.CommandText = "replace into TypedBaseItems (" + string.Join(",", saveColumns.ToArray()) + ") values (";
@ -730,6 +732,15 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveItemCommand.GetParameter(index++).Value = null; _saveItemCommand.GetParameter(index++).Value = null;
} }
var isByName = false;
var byName = item as IItemByName;
if (byName != null)
{
var dualAccess = item as IHasDualAccess;
isByName = dualAccess == null || dualAccess.IsAccessedByName;
}
_saveItemCommand.GetParameter(index++).Value = isByName;
_saveItemCommand.Transaction = transaction; _saveItemCommand.Transaction = transaction;
_saveItemCommand.ExecuteNonQuery(); _saveItemCommand.ExecuteNonQuery();
@ -1905,14 +1916,16 @@ namespace MediaBrowser.Server.Implementations.Persistence
if (query.TopParentIds.Length == 1) if (query.TopParentIds.Length == 1)
{ {
whereClauses.Add("(TopParentId=@TopParentId)"); whereClauses.Add("(TopParentId=@TopParentId or IsItemByName=@IsItemByName)");
cmd.Parameters.Add(cmd, "@TopParentId", DbType.String).Value = query.TopParentIds[0]; cmd.Parameters.Add(cmd, "@TopParentId", DbType.String).Value = query.TopParentIds[0];
cmd.Parameters.Add(cmd, "@IsItemByName", DbType.Boolean).Value = true;
} }
if (query.TopParentIds.Length > 1) if (query.TopParentIds.Length > 1)
{ {
var val = string.Join(",", query.TopParentIds.Select(i => "'" + i + "'").ToArray()); var val = string.Join(",", query.TopParentIds.Select(i => "'" + i + "'").ToArray());
whereClauses.Add("(TopParentId in (" + val + "))"); whereClauses.Add("(IsItemByName=@IsItemByName or TopParentId in (" + val + "))");
cmd.Parameters.Add(cmd, "@IsItemByName", DbType.Boolean).Value = true;
} }
if (query.AncestorIds.Length == 1) if (query.AncestorIds.Length == 1)