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-4872: Add support for Append in aggregate expressions. #1569

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

rstam
Copy link
Contributor

@rstam rstam commented Dec 7, 2024

No description provided.

@rstam rstam requested a review from sanych-sun December 7, 2024 22:11
@rstam rstam requested a review from a team as a code owner December 7, 2024 22:11
@rstam
Copy link
Contributor Author

rstam commented Dec 7, 2024

This adds support for Append in expressions.

It does not add support for top-level IQueryable Append. I'm not sure if there is a good way to support top-level Append in MQL. Perhaps with a $unionWith stage...

@rstam rstam requested a review from adelinowona December 19, 2024 16:20
else
{
elementTranslation = ExpressionToAggregationExpressionTranslator.TranslateEnumerable(context, elementExpression);
if (!elementTranslation.Serializer.Equals(itemSerializer))
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 for compatible serializers instead? For example if collection is of long and appended item is int.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should never happen. By the time we get here both serializers will always have the exact same ValueType.

The only question is whether they are serialized the same way.


namespace MongoDB.Driver.Tests.Linq.Linq3Implementation.Jira
{
public class CSharp4872Tests : Linq3IntegrationTest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I be able to Append int to collection of longs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but...

The compiler will insert a Convert from int to long so in the end you are actually appending a long.

@rstam rstam requested a review from sanych-sun December 20, 2024 19:01
Copy link
Member

@sanych-sun sanych-sun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

2 participants