Log warning for unknown BaseItemKind to Type mapping

pull/7006/head
Cody Robibero 3 years ago
parent 249a1ca955
commit 0dd304f86c

@ -3611,15 +3611,32 @@ namespace Emby.Server.Implementations.Data
whereClauses.Add("type<>@type"); whereClauses.Add("type<>@type");
statement?.TryBind("@type", excludeTypeName); statement?.TryBind("@type", excludeTypeName);
} }
else
{
Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", excludeTypes[0]);
}
} }
else if (excludeTypes.Length > 1) else if (excludeTypes.Length > 1)
{ {
var inClause = string.Join( var whereBuilder = new StringBuilder();
',', foreach (var excludeType in excludeTypes)
excludeTypes {
.Select(i => _baseItemKindNames.TryGetValue(i, out var baseItemKindName) ? "'" + baseItemKindName + "'" : null) if (_baseItemKindNames.TryGetValue(excludeType, out var baseItemKindName))
.Where(i => !string.IsNullOrEmpty(i))); {
whereClauses.Add($"type not in ({inClause})"); whereBuilder
.Append('\'')
.Append(baseItemKindName)
.Append("',");
}
else
{
Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", excludeType);
}
}
// Remove trailing comma.
whereBuilder.Length--;
whereClauses.Add($"type not in ({whereBuilder})");
} }
} }
else if (includeTypes.Length == 1) else if (includeTypes.Length == 1)
@ -3629,15 +3646,32 @@ namespace Emby.Server.Implementations.Data
whereClauses.Add("type=@type"); whereClauses.Add("type=@type");
statement?.TryBind("@type", includeTypeName); statement?.TryBind("@type", includeTypeName);
} }
else
{
Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", includeTypes[0]);
}
} }
else if (includeTypes.Length > 1) else if (includeTypes.Length > 1)
{ {
var inClause = string.Join( var whereBuilder = new StringBuilder();
',', foreach (var includeType in includeTypes)
includeTypes {
.Select(i => _baseItemKindNames.TryGetValue(i, out var baseItemKindName) ? "'" + baseItemKindName + "'" : null) if (_baseItemKindNames.TryGetValue(includeType, out var baseItemKindName))
.Where(i => !string.IsNullOrEmpty(i))); {
whereClauses.Add($"type in ({inClause})"); whereBuilder
.Append('\'')
.Append(baseItemKindName)
.Append("',");
}
else
{
Logger.LogWarning("Undefined BaseItemKind to Type mapping: {BaseItemKind}", includeType);
}
}
// Remove trailing comma.
whereBuilder.Length--;
whereClauses.Add($"type in ({whereBuilder})");
} }
if (query.ChannelIds.Count == 1) if (query.ChannelIds.Count == 1)

Loading…
Cancel
Save