Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

adelinowona
Copy link
Contributor

No description provided.

@adelinowona adelinowona requested review from rstam and sanych-sun March 18, 2025 19:05
@adelinowona adelinowona requested a review from a team as a code owner March 18, 2025 19:05
@adelinowona adelinowona removed the request for review from a team March 18, 2025 19:05
if (method.Is(MongoDBMathMethod.Sigmoid))
{
var argExpression = arguments.Single();
var argTranslation = ExpressionToAggregationExpressionTranslator.Translate(context, argExpression);
Copy link
Member

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?

Copy link
Contributor

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>
Copy link
Member

@sanych-sun sanych-sun Mar 19, 2025

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);
Copy link
Member

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:

: base(fixture, server => server.VersionGreaterThanOrEqualTo("6.0"))

/// <summary>
/// Gets the $sigmoid operator feature.
/// </summary>
public static Feature Sigmoid => __sigmoid;
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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)
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants