[CSHARP-4693] oDATA $matchesPattern support with LINQ3 Created: 27/Jun/23  Updated: 04/Jul/23  Resolved: 04/Jul/23

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Unknown
Reporter: Ching Hsu Assignee: Oleksandr Poliakov
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates CSHARP-4698 Expression not supported: Regex.IsMatch Closed
Documentation Changes Summary:

1. What would you like to communicate to the user about this feature?
2. Would you like the user to see examples of the syntax and/or executable code and its output?
3. Which versions of the driver/connector does this apply to?


 Description   

Summary

MongoDB.Driver.Linq.ExpressionNotSupportedException
  HResult=0x80131515
  Message=Expression not supported: (IIF((Convert($it.Gene, String) == null), null, Convert(IsMatch(Convert($it.Gene, String), "(^|\;)KIR2DL2(\;|$)", ECMAScript), Nullable`1)) == True).
  Source=MongoDB.Driver
  StackTrace: 
   於 MongoDB.Driver.Linq.Linq3Implementation.Translators.ExpressionToFilterTranslators.MethodTranslators.StringExpressionToRegexFilterTranslator.TranslateComparisonExpression(TranslationContext context, Expression expression, Expression leftExpression, AstComparisonFilterOperator comparisonOperator, Expression rightExpression) 在 /_/src/MongoDB.Driver/Linq/Linq3Implementation/Translators/ExpressionToFilterTranslators/ExpressionTranslators/StringExpressionToRegexFilterTranslator.cs:行 305 中

Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).

"Microsoft.AspNetCore.OData" Version="8.0.12"

"MongoDB.Driver" Version="2.20.0"

MongoDB 5.0.6 Community

How to Reproduce

http://localhost:5163/odata/Analysis/Detail?$filter=matchesPattern(Gene,'(^|\;)KIR2DL2(\;|$)')

Additional Background

expression debug view
.If ((System.String)$$it.Gene == null)

{     null }

.Else

{     (System.Nullable`1[System.Boolean]).Call System.Text.RegularExpressions.Regex.IsMatch(         (System.String)$$it.Gene,         "(^|\;)KIR2DL2(\;|$)",         .Constant<System.Text.RegularExpressions.RegexOptions>(ECMAScript)) }

== .Constant<System.Nullable`1[System.Boolean]>(True)



 Comments   
Comment by Oleksandr Poliakov [ 04/Jul/23 ]

Hello fo40225@hotmail.com ,

This issue was already fixed in scope of https://jira.mongodb.org/browse/CSHARP-4698 the fix will be available in the nearest build.

I'll close the ticket as duplicate, you can reference to the ticket above to check the progress.

 

Thanks,

Oleksandr

Comment by PM Bot [ 27/Jun/23 ]

Hi fo40225@hotmail.com, thank you for reporting this issue! The team will look into it and get back to you soon.

Generated at Wed Feb 07 21:49:03 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.