-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(query): correctly cast embedded discriminator paths when discrimi…
…nator key is specified in array filter Fix #9977
- Loading branch information
Showing
5 changed files
with
47 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,24 @@ | ||
'use strict'; | ||
|
||
const modifiedPaths = require('./modifiedPaths'); | ||
|
||
module.exports = function updatedPathsByArrayFilter(update) { | ||
const updatedPaths = modifiedPaths(update); | ||
|
||
return Object.keys(updatedPaths).reduce((cur, path) => { | ||
const matches = path.match(/\$\[[^\]]+\]/g); | ||
if (matches == null) { | ||
return cur; | ||
} | ||
for (const match of matches) { | ||
const firstMatch = path.indexOf(match); | ||
if (firstMatch !== path.lastIndexOf(match)) { | ||
throw new Error(`Path '${path}' contains the same array filter multiple times`); | ||
} | ||
cur[match.substring(2, match.length - 1)] = path. | ||
substr(0, firstMatch - 1). | ||
replace(/\$\[[^\]]+\]/g, '0'); | ||
} | ||
return cur; | ||
}, {}); | ||
}; |
This file contains 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