Skip to content

Conversation

adelinowona
Copy link
Contributor

Added TextPreview support for Prefix/Suffix/Substring Indexes

@adelinowona adelinowona requested a review from a team as a code owner September 3, 2025 17:14
@adelinowona adelinowona requested review from sanych-sun and removed request for a team September 3, 2025 17:14
@adelinowona adelinowona requested a review from BorisDog September 3, 2025 17:14
Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

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

Looks good overall, few changes requested

/// </remarks>
public sealed class PrefixOptions
{
private readonly int _strMaxQueryLength;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe auto props instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried to follow the pattern already present in this file. I didn't want to mix auto props pattern with the existing backing field pattern. As a matter of fact, I don't think we have a general guideline in the driver, do we generally prefer auto props pattern vs backing field pattern?

Copy link
Contributor

Choose a reason for hiding this comment

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

We don't have a general guideline, and we do have mixed styles. I do prefer auto props and recommend for others as well.
I don't see an issue with mixing styles within the same file. Also EncryptOptions can be refactored to use autoprops.

Copy link
Contributor

Choose a reason for hiding this comment

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

I strongly dislike auto-properties for all but the very simplest data only classes, and maybe not even then.

My issue is that when reading a class it is helpful to know what state the class maintains. When you have explicit fields at the beginning of the file you can easily tell what state the class maintains.

Auto-properties are harder to find, and so the state the class maintains is spread out a bit more.

The worst-case scenario is a class that has some explicit fields and some auto-properties, because then the state the class maintains is really hard to discern. For that reason, we should never mix the two.

To me auto properties are just lazy syntactic sugar that usually just make code harder to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave the changes as is just because I don't like mixing patterns.


RunTestCase(clientEncryption, prefixSuffixCollection, substringCollection);
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: no need for return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was following the rider suggestion to include an explicit return to enhance the clarity of the method control flow for readers which is fair given that the method has a multiple local functions. Do we generally not care about this?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we've notices that in other places. From a first glance having empty returns feels awkward.
Maybe not in this case, but in general if the method in not very readable, we probably should just refactor it.

@sanych-sun wdyt about empty returns?

"$expr", new BsonDocument
{
{
$"{operation}", new BsonDocument
Copy link
Contributor

Choose a reason for hiding this comment

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

@rishitb-mongodb we probably will need builders for $strEndsWith, $strStartsWith, $strContains.
But only when it will be out of preview. WDYT?

Copy link
Contributor

@BorisDog BorisDog left a comment

Choose a reason for hiding this comment

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

LGTM!

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

@adelinowona adelinowona merged commit 2c9c244 into mongodb:main Sep 5, 2025
61 of 66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants