Skip to content

Commit f661b46

Browse files
Copilothotlong
andcommitted
refactor: rename __$andRegex sentinel to _multiRegex for clarity
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 41b6831 commit f661b46

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

packages/plugins/driver-memory/src/memory-driver.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,9 @@ export class InMemoryDriver implements DriverInterface {
744744
if (value && typeof value === 'object' && !Array.isArray(value) && !(value instanceof Date) && !(value instanceof RegExp)) {
745745
const normalized = this.normalizeFieldOperators(value);
746746
// Handle multiple regex conditions on the same field (e.g. $startsWith + $endsWith)
747-
if (normalized.__$andRegex) {
748-
const regexConditions: Record<string, any>[] = normalized.__$andRegex;
749-
delete normalized.__$andRegex;
747+
if (normalized._multiRegex) {
748+
const regexConditions: Record<string, any>[] = normalized._multiRegex;
749+
delete normalized._multiRegex;
750750
// Each regex becomes its own { field: { $regex: ... } } inside $and
751751
for (const rc of regexConditions) {
752752
extraAndConditions.push({ [key]: { ...normalized, ...rc } });
@@ -825,12 +825,9 @@ export class InMemoryDriver implements DriverInterface {
825825
if (regexConditions.length === 1) {
826826
Object.assign(result, regexConditions[0]);
827827
} else if (regexConditions.length > 1) {
828-
// Cannot have multiple $regex on one object; promote to top-level $and
829-
// The caller (normalizeFilterCondition) handles field-level objects,
830-
// so we return a sentinel that the caller will need to unwrap.
831-
// Simpler approach: just assign the first and use $and for the rest isn't
832-
// possible in flat Mingo format. Use __$and sentinel for the caller.
833-
result.__$andRegex = regexConditions;
828+
// Cannot have multiple $regex on one object; promote to top-level $and.
829+
// _multiRegex is an internal sentinel consumed by normalizeFilterCondition().
830+
result._multiRegex = regexConditions;
834831
}
835832

836833
return result;

0 commit comments

Comments
 (0)