Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/MongoDB.Analyzer/Core/ConstantsMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ internal sealed class ConstantsMapper
private const string RegexLookahead = "(?![\\w\"\\.])";
private const string RegexLookbehind = "(?<![\\w\"\\.])";
private const string VariableAnnotation = "VariableName";
private const string WildcardRegex = "\\.\\$\\*\\*";
private const string WildcardSuffix = ".$**";

private IDictionary<string, LiteralExpressionSyntax> _originalToSyntax;
private IDictionary<string, string> _mqlRemapping;
Expand Down Expand Up @@ -222,6 +224,7 @@ private void AddMapping(string source, string target, bool isString)
{
_mqlRemapping[$"{RegexLookbehind}\"{source}\"{RegexLookahead}"] = target;
_mqlRemapping[$"/{source}/"] = $"/{target}/";
_mqlRemapping[$"{RegexLookbehind}\"{source}{WildcardRegex}\"{RegexLookahead}"] = $"{target}{WildcardSuffix}";
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ public void Text()
_ = Builders<Person>.IndexKeys.Text(u => u.Address).Text("Vehicle");
}

[BuildersMQL("{ \"$**\" : 1 }")]
[BuildersMQL("{ \"Address.$**\" : 1 }")]
[BuildersMQL("{ \"SiblingsCount.$**\" : 1 }")]
[BuildersMQL("{ wildcardField.$** : 1 }")]
public void Wildcard()
{
_ = Builders<Person>.IndexKeys.Wildcard();
_ = Builders<Person>.IndexKeys.Wildcard("Address");
_ = Builders<Person>.IndexKeys.Wildcard(p => p.SiblingsCount);

var wildcardField = "Vehicle";
_ = Builders<Person>.IndexKeys.Wildcard(wildcardField);
}

[BuildersMQL("{ \"Name\" : \"text\", \"LastName\" : \"hashed\", \"Vehicle\" : \"2d\", \"Address\" : 1 }")]
[BuildersMQL("{ \"Name\" : \"2d\", \"LastName\" : \"2dsphere\", \"Vehicle\" : \"text\", \"Address\" : -1, \"SiblingsCount\" : \"hashed\", \"TicksSinceBirth\" : 1 }")]
[BuildersMQL("{ \"Name\" : \"2d\", \"LastName\" : \"2d\", \"Address\" : \"text\", \"Vehicle\" : \"text\" }")]
Expand Down