Skip to content

Commit

Permalink
more minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
WhatzGames committed Dec 14, 2024
1 parent 382d1bc commit 4b83cdc
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public NpgsqlRegexTranslator(
IReadOnlyList<SqlExpression> arguments,
IDiagnosticsLogger<DbLoggerCategory.Query> logger)
=> TranslateIsMatch(instance, method, arguments, logger)
?? TranslateRegexReplace(method, arguments, logger)
?? TranslateReplace(method, arguments, logger)
?? TranslateCount(method, arguments, logger);

private SqlExpression? TranslateIsMatch(
Expand All @@ -85,7 +85,7 @@ public NpgsqlRegexTranslator(
: null;
}

private SqlExpression? TranslateRegexReplace(
private SqlExpression? TranslateReplace(
MethodInfo method,
IReadOnlyList<SqlExpression> arguments,
IDiagnosticsLogger<DbLoggerCategory.Query> logger)
Expand All @@ -109,9 +109,7 @@ public NpgsqlRegexTranslator(
_sqlExpressionFactory.ApplyTypeMapping(replacement, typeMapping)
];

var translatedOptions = TranslateOptions(regexOptions.Value);

if (translatedOptions.Length is not 0)
if (TranslateOptions(regexOptions.Value) is { Length: not 0 } translatedOptions)
{
passingArguments.Add(_sqlExpressionFactory.Constant(translatedOptions));
}
Expand Down Expand Up @@ -148,9 +146,7 @@ public NpgsqlRegexTranslator(
_sqlExpressionFactory.ApplyTypeMapping(pattern, typeMapping)
];

var translatedOptions = TranslateOptions(regexOptions.Value);

if (translatedOptions.Length is not 0)
if (TranslateOptions(regexOptions.Value) is { Length: not 0 } translatedOptions)
{
passingArguments.AddRange([
//starting position has to be set to use the options in postgres
Expand Down

0 comments on commit 4b83cdc

Please sign in to comment.