When field is used as expression, this method will be called.

@param \atk4\dsql\Expression $expression

@return \atk4\dsql\Expression
18440
public function getDSQLExpression($expression)
    {
        $expr = $this->expr;
        if (is_callable($expr)) {
            $c = $this->expr;
            $expr = $c($this->owner, $expression);
        }

        if (is_string($expr)) {
            // If our Model has expr() method (inherited from Persistence\SQL) then use it
            if ($this->owner->hasMethod('expr')) {
                return $this->owner->expr('([])', [$this->owner->expr($expr)]);
            }

            // Otherwise call it from expression itself
            return $expression->expr('([])', [$expression->expr($expr)]);
        }

        return $expr;
    }
1119776
public function evaluate($expression)
    {
        $lexer = $this->getLexer();
        $tokens = $lexer->tokenize($expression);

        $translationStrategy = new \Math\TranslationStrategy\ShuntingYard();

        return $this->evaluateRPN($translationStrategy->translate($tokens));
    }
387352
protected function compileEchoStack($expression)
    {
        foreach (['RawEcho', 'Echo'] as $token) {
            $out = $this->{'compile'.$token}($expression);

            if (strlen($out) !== 0) {
                $expression = $out;
            }
        }

        return $expression;
    }
285933
public function removeExpression($expression)
    {
        if ($this->expressions->contains($expression)) {
            $this->expressions->removeElement($expression);
        }

        return $this;
    }
1261925
private function fetchExpression($expression)
    {
        $selectors = explode(',', $expression);
        $paths = [];

        foreach ($selectors as $selector) {
            $selector = trim($selector);

            if (array_key_exists($selector, $this->compiledExpressions)) {
                $paths[] = $this->compiledExpressions[ $selector ];

                continue;
            }

            $this->compiledExpressions[ $selector ] = $this->fetchCssExpression($selector);

            $paths[] = $this->compiledExpressions[ $selector ];
        }

        return implode('|', $paths);
    }
281968
public function addOr($expression)
    {
        $this->query['$or'][] = $expression instanceof Expr ? $expression->getQuery() : $expression;
        return $this;
    }
762997
public function getDSQLExpression($expression)
    {
        if (!$this->owner->persistence || !$this->owner->persistence instanceof Persistence\SQL) {
            throw new Exception([
                'Field must have SQL persistence if it is used as part of expression',
                'persistence'=> $this->owner->persistence ?? null,
            ]);
        }

        return $this->owner->persistence->getFieldSQLExpression($this, $expression);
    }
689276
public function walkCaseExpression($expression)
    {
        switch (true) {
            case ($expression instanceof AST\CoalesceExpression):
                return $this->walkCoalesceExpression($expression);

            case ($expression instanceof AST\NullIfExpression):
                return $this->walkNullIfExpression($expression);

            case ($expression instanceof AST\GeneralCaseExpression):
                return $this->walkGeneralCaseExpression($expression);

            case ($expression instanceof AST\SimpleCaseExpression):
                return $this->walkSimpleCaseExpression($expression);

            default:
                return '';
        }
    }
1186514
private function query(string $expression): \DOMNodeList
    {
        return $this->xpath->query(
            $this->expressionTranslator->convertToXpath($expression)
        );
    }
859707
public function create(ExpressionInterface $expression = null)
	{
		if($expression instanceof ConditionInterface)
		{
			return new ConditionBuilder($expression);
		}
		elseif($expression instanceof JoinInterface)
		{
			return new JoinBuilder($expression);
		}
		else
		{
			return new NullBuilder();
		}
	}
159886
public static function parseWithFilters(string $expression): string
    {
        $expression = \trim($expression);

        if ($expression === '' || \is_numeric($expression)) {
            return $expression;
        }

        if (!isset(self::$cache[$expression])) {
            $tree = self::treeStruct($expression);
            [$tree, $filters] = self::splitFilters($tree);

            $code = self::transform($tree);
            if ($filters !== []) {
                $code = '$this->filter(' . $code . ')';

                /* @var Token $filter */
                foreach ($filters as [$filter, $args]) {
                    $code .= '->' . $filter->getContent();
                    if ($args === []) {
                        $code .= '()';
                    } else {
                        $code .= self::transform($args);
                    }
                }
            }

            self::$cache[$expression] = $code . '->getResult()';
        }

        return self::$cache[$expression];
    }
639195
protected function transform(Expression $expression)
    {
        $constraint = $expression->getConstraint();
        $getter = 'get'.ucfirst($expression->getSelector());

        return Expr::method($getter, new $constraint($expression->getValue()));
    }
529575
public function eq($expression1, $expression2) : self
    {
        $this->expr->eq($expression1, $expression2);

        return $this;
    }
504410
public function not($expression) : self
    {
        return $this->operator('$not', $expression instanceof Expr ? $expression->getQuery() : $expression);
    }
1212011
static private function translate ($expression)
  {
    list ($main, $op) = self::translateSimpleExpression ($expression);

    $exp = $main;
    if ($op == '|') {
      $filters = preg_split (self::PARSE_FILTER, $expression);
      if ($filters)
        foreach ($filters as $filter)
          $exp = self::translateFilter ($filter, $exp);
    }

    return $exp;
  }
756117
public function elemMatch($expression) : self
    {
        return $this->operator('$elemMatch', $expression instanceof Expr ? $expression->getQuery() : $expression);
    }
687632
public function addOperator($expression) {
        /**
         * SELECT DISTINCT subject FROM statements WHERE
         */
        $this->query .= '(' .
                $this->getDriverEscaper()->dbCommand('SELECT') . ' ' .
                $this->getDriverEscaper()->dbCommand('DISTINCT') . ' ' .
                $this->getDriverEscaper()->reserved('subject') . ' ' .
                $this->getDriverEscaper()->dbCommand('FROM') . ' ' .
                $this->getDriverEscaper()->reserved($this->options['table']) . ' ' .
                $this->getDriverEscaper()->dbCommand('WHERE') .
                $this->operationSeparator .
                $this->userLanguage . ' ' . $expression;

        if (!empty($this->model)) {
            $this->query .=  $this->getDriverEscaper()->dbCommand('AND') . ' '.
                $this->getDriverEscaper()->reserved('modelid') . ' '.
                $this->getDriverEscaper()->dbCommand('IN') . ' '.
                '(' . implode(',', $this->model->getReadableModels()) . ')'.
                $this->operationSeparator ;
        }
        $this->query .= ' )'.')';

        $this->predicateLoop ++;

        return $this;
    }