Skip to content

Commit

Permalink
feat: Added nullability to GetFieldInternalQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
nikcio committed Jun 21, 2023
1 parent c205298 commit 52f686c
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/Examine.Lucene/Search/LuceneSearchQueryBase.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Examine.Search;
using Lucene.Net.Facet.Range;
Expand Down Expand Up @@ -265,7 +266,7 @@ protected internal LuceneBooleanOperationBase FieldInternal(string fieldName, IE
/// <inheritdoc/>
private LuceneBooleanOperationBase FieldInternal(string fieldName, IExamineValue fieldValue, Occur occurrence, bool useQueryParser)
{
Query queryToAdd = GetFieldInternalQuery(fieldName, fieldValue, useQueryParser);
Query? queryToAdd = GetFieldInternalQuery(fieldName, fieldValue, useQueryParser);

if (queryToAdd != null)
Query.Add(queryToAdd, occurrence);
Expand Down Expand Up @@ -364,7 +365,7 @@ protected internal LuceneBooleanOperationBase IdInternal(string id, Occur occurr
/// <param name="fieldValue"></param>
/// <param name="useQueryParser">True to use the query parser to parse the search text, otherwise, manually create the queries</param>
/// <returns>A new <see cref="IBooleanOperation"/> with the clause appended</returns>
protected virtual Query GetFieldInternalQuery(string fieldName, IExamineValue fieldValue, bool useQueryParser)
protected virtual Query? GetFieldInternalQuery(string fieldName, IExamineValue fieldValue, bool useQueryParser)
{
if (string.IsNullOrEmpty(fieldName))
throw new ArgumentException($"'{nameof(fieldName)}' cannot be null or empty", nameof(fieldName));
Expand All @@ -373,7 +374,7 @@ protected virtual Query GetFieldInternalQuery(string fieldName, IExamineValue fi
if (string.IsNullOrEmpty(fieldValue.Value))
throw new ArgumentException($"'{nameof(fieldName)}' cannot be null or empty", nameof(fieldName));

Query queryToAdd;
Query? queryToAdd;

switch (fieldValue.Examineness)
{
Expand Down Expand Up @@ -409,10 +410,10 @@ protected virtual Query GetFieldInternalQuery(string fieldName, IExamineValue fi
if (useQueryParser)
{
queryToAdd = _queryParser.GetFieldQueryInternal(fieldName, fieldValue.Value);
//if (queryToAdd != null) // TODO: Does this ever happen? Then the method should be made with a nullable return
//{
if (queryToAdd != null)
{
queryToAdd.Boost = fieldValue.Level;
//}
}
}
else
{
Expand Down

0 comments on commit 52f686c

Please sign in to comment.