Django MongoDB Backend: support evaluation of closed expressions

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Unresolved
    • Priority: Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • Python Drivers
    • None
    • None
    • None
    • None
    • None
    • None

      Context

      Currently, constant detection in the Django MongoDB backend is limited. Some closed expressions, those without free variables and independent from document fields, are not yet evaluated as constant values. This task aims to properly handle these expressions so they can be simplified or pre-evaluated before query execution.

      Definition of done

      • Closed expressions are correctly detected and evaluated as constant values when possible.
      • Functions or expressions that are syntactically closed but semantically non-deterministic (e.g., $rand, $dateNow) remain excluded.
      • Existing behavior for open expressions (those referencing document fields) remains unchanged.
      • Unit tests cover the new constant-evaluation logic.

      Pitfalls

      • Be careful not to treat expressions that rely on runtime state (like random or time-based functions) as constants.
      • Ensure that sub-expressions within CombinedExpression and Func are properly resolved to avoid false positives.

            Assignee:
            Unassigned
            Reporter:
            Emanuel Lupi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: