[COMPASS-4737] Editing view causes $regexFind to be re-written Created: 28/Mar/21  Updated: 02/Jun/21

Status: Open
Project: Compass
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-55583 Difference between RegExp and raw // ... Closed
Story Points: 5

 Description   

Problem Description

While editing a view, I noticed that my query results change. I defined my view as :

{$addFields: {
  returnObject: {
    $regexFind: {
      input: "$Job", regex: /\[(.*)\]/    }
  }
}

But when I click "modify source" the view is now defined as:

[{$addFields: {
  returnObject: {
    $regexFind: {
      input: '$Job',
      regex: RegExp('\[(.*)\]')
    }
  }
}

This is creating a different capture in the $regexFind. This may be a server bug, but the re-writing of the query exposed this. Saving the query as a view does not cause the view definition to be re-written – it's only on modifying it. I raised SERVER-55583 to check on the syntax difference. You can see that report for raw repro.

 

Steps to Reproduce

Expected Results

Actual Results

Additional Notes



 Comments   
Comment by Daniel Pasette (Inactive) [ 01/Apr/21 ]

As shown in the linked server bug, the rewritten expression is not escaped correctly, causing the bug.  

Generated at Wed Feb 07 22:37:19 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.