Skip to content

Commit 65c73e4

Browse files
committed
Add null safety for the "where" clause extraction
1 parent 4b83d23 commit 65c73e4

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Parse/Platform/LiveQueries/ParseLiveQuery.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ public class ParseLiveQuery<T> where T : ParseObject
3838

3939
public ParseLiveQuery(IServiceHub serviceHub, string className, IDictionary<string, object> filters, IEnumerable<string> selectedKeys = null, IEnumerable<string> watchedKeys = null)
4040
{
41+
ArgumentNullException.ThrowIfNull(filters);
42+
4143
Services = serviceHub;
4244
ClassName = className;
4345
Filters = filters;

Parse/Platform/Queries/ParseQuery.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,9 +912,15 @@ public override int GetHashCode()
912912
return 0;
913913
}
914914

915+
/// <summary>
916+
/// Converts the current query into a live query that allows real-time updates to be monitored
917+
/// for changes that match the specified query criteria.
918+
/// </summary>
919+
/// <returns>A ParseLiveQuery object configured to monitor changes for the query.</returns>
915920
public ParseLiveQuery<T> GetLive()
916921
{
917-
IDictionary<string, object> paramsDict = BuildParameters();
918-
return new ParseLiveQuery<T>(Services, ClassName, paramsDict["where"] as IDictionary<string, object>, KeySelections);
922+
ArgumentNullException.ThrowIfNull(Filters);
923+
IDictionary<string, object> filters = BuildParameters().TryGetValue("where", out object where) ? where as IDictionary<string, object> : null;
924+
return new ParseLiveQuery<T>(Services, ClassName, filters, KeySelections);
919925
}
920926
}

0 commit comments

Comments
 (0)