Skip to content

Commit

Permalink
Remove client code for all EF.Functions
Browse files Browse the repository at this point in the history
Also switched to the EF Core standard error message for client-side
evaluation.

Closes #1312
  • Loading branch information
roji committed Mar 21, 2020
1 parent 122d785 commit afb93ef
Show file tree
Hide file tree
Showing 16 changed files with 356 additions and 448 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.EntityFrameworkCore.Diagnostics;

namespace Microsoft.EntityFrameworkCore
{
Expand All @@ -12,8 +13,8 @@ public static class NpgsqlFuzzyStringMatchDbFunctionsExtensions
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static string FuzzyStringMatchSoundex(this DbFunctions _, string text) =>
throw new NotSupportedException();
public static string FuzzyStringMatchSoundex(this DbFunctions _, string text)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchSoundex)));

/// <summary>
/// The difference function converts two strings to their Soundex codes and
Expand All @@ -26,8 +27,8 @@ public static string FuzzyStringMatchSoundex(this DbFunctions _, string text) =>
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static int FuzzyStringMatchDifference(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static int FuzzyStringMatchDifference(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchDifference)));

/// <summary>
/// Returns the Levenshtein distance between two strings.
Expand All @@ -37,8 +38,8 @@ public static int FuzzyStringMatchDifference(this DbFunctions _, string source,
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchLevenshtein)));

/// <summary>
/// Returns the Levenshtein distance between two strings.
Expand All @@ -48,8 +49,8 @@ public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source,
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source, string target, int insertionCost, int deletionCost, int substitutionCost) =>
throw new NotSupportedException();
public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source, string target, int insertionCost, int deletionCost, int substitutionCost)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchLevenshtein)));

/// <summary>
/// levenshtein_less_equal is an accelerated version of the Levenshtein function for use when only small distances are of interest.
Expand All @@ -61,8 +62,8 @@ public static int FuzzyStringMatchLevenshtein(this DbFunctions _, string source,
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, string source, string target, int maximumDistance) =>
throw new NotSupportedException();
public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, string source, string target, int maximumDistance)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchLevenshteinLessEqual)));

/// <summary>
/// levenshtein_less_equal is an accelerated version of the Levenshtein function for use when only small distances are of interest.
Expand All @@ -74,8 +75,8 @@ public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, strin
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, string source, string target, int insertionCost, int deletionCost, int substitutionCost, int maximumDistance) =>
throw new NotSupportedException();
public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, string source, string target, int insertionCost, int deletionCost, int substitutionCost, int maximumDistance)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchLevenshteinLessEqual)));

/// <summary>
/// The metaphone function converts a string to its Metaphone code.
Expand All @@ -85,8 +86,8 @@ public static int FuzzyStringMatchLevenshteinLessEqual(this DbFunctions _, strin
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static string FuzzyStringMatchMetaphone(this DbFunctions _, string text, int maximumOutputLength) =>
throw new NotSupportedException();
public static string FuzzyStringMatchMetaphone(this DbFunctions _, string text, int maximumOutputLength)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchMetaphone)));

/// <summary>
/// The dmetaphone function converts a string to its primary Double Metaphone code.
Expand All @@ -96,8 +97,8 @@ public static string FuzzyStringMatchMetaphone(this DbFunctions _, string text,
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static string FuzzyStringMatchDoubleMetaphone(this DbFunctions _, string text) =>
throw new NotSupportedException();
public static string FuzzyStringMatchDoubleMetaphone(this DbFunctions _, string text)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchDoubleMetaphone)));

/// <summary>
/// The dmetaphone_alt function converts a string to its alternate Double Metaphone code.
Expand All @@ -107,7 +108,7 @@ public static string FuzzyStringMatchDoubleMetaphone(this DbFunctions _, string
///
/// See https://www.postgresql.org/docs/current/fuzzystrmatch.html.
/// </remarks>
public static string FuzzyStringMatchDoubleMetaphoneAlt(this DbFunctions _, string text) =>
throw new NotSupportedException();
public static string FuzzyStringMatchDoubleMetaphoneAlt(this DbFunctions _, string text)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(FuzzyStringMatchDoubleMetaphoneAlt)));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using NetTopologySuite.Geometries;
using System;
using Microsoft.EntityFrameworkCore.Diagnostics;

namespace Microsoft.EntityFrameworkCore
{
Expand All @@ -15,6 +16,6 @@ public static class NpgsqlNetTopologySuiteDbFunctionsExtensions
/// </remarks>
public static TGeometry Transform<TGeometry>(this DbFunctions _, TGeometry geometry, int srid)
where TGeometry : Geometry
=> throw new NotSupportedException();
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Transform)));
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.EntityFrameworkCore.Diagnostics;

namespace Microsoft.EntityFrameworkCore
{
Expand All @@ -13,8 +14,8 @@ public static class NpgsqlTrigramsDbFunctionsExtensions
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static string[] TrigramsShow(this DbFunctions _, string text) =>
throw new NotSupportedException();
public static string[] TrigramsShow(this DbFunctions _, string text)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsShow)));

/// <summary>
/// Returns a number that indicates how similar the two arguments are.
Expand All @@ -26,8 +27,8 @@ public static string[] TrigramsShow(this DbFunctions _, string text) =>
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsSimilarity(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsSimilarity(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsSimilarity)));

/// <summary>
/// Returns a number that indicates the greatest similarity between the set of trigrams
Expand All @@ -39,8 +40,8 @@ public static double TrigramsSimilarity(this DbFunctions _, string source, strin
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsWordSimilarity(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsWordSimilarity(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsWordSimilarity)));

/// <summary>
/// Same as word_similarity(text, text), but forces extent boundaries to match word boundaries.
Expand All @@ -52,8 +53,8 @@ public static double TrigramsWordSimilarity(this DbFunctions _, string source, s
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsStrictWordSimilarity(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsStrictWordSimilarity(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsStrictWordSimilarity)));

/// <summary>
/// Returns true if its arguments have a similarity that is greater than the current similarity
Expand All @@ -64,8 +65,8 @@ public static double TrigramsStrictWordSimilarity(this DbFunctions _, string sou
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static bool TrigramsAreSimilar(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static bool TrigramsAreSimilar(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsAreSimilar)));

/// <summary>
/// Returns true if the similarity between the trigram set in the first argument and a continuous
Expand All @@ -77,8 +78,8 @@ public static bool TrigramsAreSimilar(this DbFunctions _, string source, string
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static bool TrigramsAreWordSimilar(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static bool TrigramsAreWordSimilar(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsAreWordSimilar)));

/// <summary>
/// Commutator of the &lt;% operator.
Expand All @@ -88,8 +89,8 @@ public static bool TrigramsAreWordSimilar(this DbFunctions _, string source, str
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static bool TrigramsAreNotWordSimilar(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static bool TrigramsAreNotWordSimilar(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsAreNotWordSimilar)));

/// <summary>
/// Returns true if its second argument has a continuous extent of an ordered trigram set that
Expand All @@ -102,8 +103,8 @@ public static bool TrigramsAreNotWordSimilar(this DbFunctions _, string source,
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static bool TrigramsAreStrictWordSimilar(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static bool TrigramsAreStrictWordSimilar(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsAreStrictWordSimilar)));

/// <summary>
/// Commutator of the &lt;&lt;% operator.
Expand All @@ -113,8 +114,8 @@ public static bool TrigramsAreStrictWordSimilar(this DbFunctions _, string sourc
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static bool TrigramsAreNotStrictWordSimilar(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static bool TrigramsAreNotStrictWordSimilar(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsAreNotStrictWordSimilar)));

/// <summary>
/// Returns the "distance" between the arguments, that is one minus the similarity() value.
Expand All @@ -124,8 +125,8 @@ public static bool TrigramsAreNotStrictWordSimilar(this DbFunctions _, string so
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsSimilarityDistance(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsSimilarityDistance(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsSimilarityDistance)));

/// <summary>
/// Returns the "distance" between the arguments, that is one minus the word_similarity() value.
Expand All @@ -135,8 +136,8 @@ public static double TrigramsSimilarityDistance(this DbFunctions _, string sourc
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsWordSimilarityDistance(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsWordSimilarityDistance(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsWordSimilarityDistance)));

/// <summary>
/// Commutator of the &lt;&lt;-&gt; operator.
Expand All @@ -146,8 +147,8 @@ public static double TrigramsWordSimilarityDistance(this DbFunctions _, string s
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsWordSimilarityDistanceInverted(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsWordSimilarityDistanceInverted(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsWordSimilarityDistanceInverted)));

/// <summary>
/// Returns the "distance" between the arguments, that is one minus the strict_word_similarity() value.
Expand All @@ -157,8 +158,8 @@ public static double TrigramsWordSimilarityDistanceInverted(this DbFunctions _,
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsStrictWordSimilarityDistance(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsStrictWordSimilarityDistance(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsStrictWordSimilarityDistance)));

/// <summary>
/// Commutator of the &lt;&lt;&lt;-&gt; operator.
Expand All @@ -168,7 +169,7 @@ public static double TrigramsStrictWordSimilarityDistance(this DbFunctions _, st
///
/// See https://www.postgresql.org/docs/current/pgtrgm.html.
/// </remarks>
public static double TrigramsStrictWordSimilarityDistanceInverted(this DbFunctions _, string source, string target) =>
throw new NotSupportedException();
public static double TrigramsStrictWordSimilarityDistanceInverted(this DbFunctions _, string source, string target)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(TrigramsStrictWordSimilarityDistanceInverted)));
}
}
Loading

0 comments on commit afb93ef

Please sign in to comment.