-
Notifications
You must be signed in to change notification settings - Fork 524
Query: Adds LINQ RegexMatch Extension method #4078
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
Merged
microsoft-github-policy-service
merged 10 commits into
master
from
users/leminh/RegexMatchPOC
Oct 3, 2023
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9e665eb
Add support for translation to REgexmatch
803b328
Add test and fix some indexing issues
f1d97a9
remove visit explicit, add some comment. Update public contract and a…
661d4fc
add the missing baseline
3be866c
added test
eaf1ca5
Merge branch 'master' into users/leminh/RegexMatchPOC
289241a
address code review
76c63b6
Merge branch 'master' into users/leminh/RegexMatchPOC
4aca46d
update csproj
7150d4b
Merge branch 'master' into users/leminh/RegexMatchPOC
leminh98 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
...orTests/BaselineTest/TestBaseline/LinqTranslationBaselineTests.TestRegexMatchFunction.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,170 @@ | ||
| <Results> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with 1 argument]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch("abcd"))]]></Expression> | ||
leminh98 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], "abcd")]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with 2 argument]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch("abcd", "i"))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], "abcd", "i")]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with 1st argument member expression]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch(doc.StringField2))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], root["StringField2"])]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with ToString]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch(doc.IntField.ToString()))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], ToString(root["IntField"]))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with StringUpper]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch(doc.StringField2.ToUpper()))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], UPPER(root["StringField2"]))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with StringLower]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch(doc.StringField2.ToLower()))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], LOWER(root["StringField2"]))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with StringConcat]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch(Concat(doc.StringField, "str")))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], CONCAT(root["StringField"], "str"))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with string composition]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.IntField.ToString().RegexMatch(doc.StringField))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(ToString(root["IntField"]), root["StringField"])]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with string composition 2]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.IntField.ToString().RegexMatch(doc.StringField, doc.StringField2.ToString()))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(ToString(root["IntField"]), root["StringField"], root["StringField2"])]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with conditional]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => (doc.StringField.RegexMatch("abc") AndAlso doc.StringField2.RegexMatch("def")))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE (RegexMatch(root["StringField"], "abc") AND RegexMatch(root["StringField2"], "def"))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with conditional 2]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => (doc.StringField.RegexMatch("abc") OrElse doc.StringField2.RegexMatch("def")))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE (RegexMatch(root["StringField"], "abc") OR RegexMatch(root["StringField2"], "def"))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with conditional 3]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch("abc")).Where(doc => doc.StringField2.RegexMatch("abc"))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE (RegexMatch(root["StringField"], "abc") AND RegexMatch(root["StringField2"], "abc"))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with conditional 4]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch("abc")).Where(doc => Not(doc.StringField2.RegexMatch("abc")))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE (RegexMatch(root["StringField"], "abc") AND (NOT RegexMatch(root["StringField2"], "abc")))]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| <Result> | ||
| <Input> | ||
| <Description><![CDATA[RegexMatch with 2nd argument invalid string options]]></Description> | ||
| <Expression><![CDATA[query.Where(doc => doc.StringField.RegexMatch("abcd", "this should error out on the back end"))]]></Expression> | ||
| </Input> | ||
| <Output> | ||
| <SqlQuery><![CDATA[ | ||
| SELECT VALUE root | ||
| FROM root | ||
| WHERE RegexMatch(root["StringField"], "abcd", "this should error out on the back end")]]></SqlQuery> | ||
| </Output> | ||
| </Result> | ||
| </Results> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.