-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSHARP-5527: Support $sigmoid expression #1638
base: main
Are you sure you want to change the base?
Conversation
if (method.Is(MongoDBMathMethod.Sigmoid)) | ||
{ | ||
var argExpression = arguments.Single(); | ||
var argTranslation = ExpressionToAggregationExpressionTranslator.Translate(context, argExpression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we check if argTranslation has numeric bson representaiton?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should.
|
||
namespace MongoDB.Driver.Tests.Linq.Linq3Implementation.Jira | ||
{ | ||
public class CSharp5527Tests : LinqIntegrationTest<CSharp5527Tests.ClassFixture> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to rename this test class to SigmoidMethodToAggregationExpressionTranslatorTests
and move into appropriate namespace.
[Fact] | ||
public void Sigmoid_should_work() | ||
{ | ||
RequireServer.Check().Supports(Feature.Sigmoid); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this condition to ctor to avoid collection creation in case server does not support the feature. Like here:
mongo-csharp-driver/tests/MongoDB.Driver.Tests/Linq/Linq3Implementation/Jira/CSharp4244Tests.cs
Line 30 in cf2892b
: base(fixture, server => server.VersionGreaterThanOrEqualTo("6.0")) |
/// <summary> | ||
/// Gets the $sigmoid operator feature. | ||
/// </summary> | ||
public static Feature Sigmoid => __sigmoid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: rename feature to SigmoidOperator
.
if (method.Is(MongoDBMathMethod.Sigmoid)) | ||
{ | ||
var argExpression = arguments.Single(); | ||
var argTranslation = ExpressionToAggregationExpressionTranslator.Translate(context, argExpression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we should.
if (method.Is(MongoDBMathMethod.Sigmoid)) | ||
{ | ||
var argExpression = arguments.Single(); | ||
var argTranslation = ExpressionToAggregationExpressionTranslator.Translate(context, argExpression); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: keep these names consistent with the declaration of the method, so rename to valueExpression
and valueTranslation
.
/// </summary> | ||
/// <param name="value">The input value.</param> | ||
/// <returns>The transformed value.</returns> | ||
public static double Sigmoid(double value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is a perfectly reasonable place to declare this method we should discuss a bit whether going forward we want all new methods like this to live in the Mql
class.
No description provided.