Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build User Varaiable Expression in FunctionBuilder #340

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/PHPSQLParser/builders/FunctionBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ protected function buildSubQuery($parsed) {
$builder = new SubQueryBuilder();
return $builder->build($parsed);
}


protected function buildUserVariableExpression($parsed) {
$builder = new UserVariableBuilder();
return $builder->build($parsed);
}

public function build(array $parsed) {
if (($parsed['expr_type'] !== ExpressionType::AGGREGATE_FUNCTION)
&& ($parsed['expr_type'] !== ExpressionType::SIMPLE_FUNCTION)
Expand All @@ -114,6 +119,7 @@ public function build(array $parsed) {
$sql .= $this->buildReserved($v);
$sql .= $this->buildSelectBracketExpression($v);
$sql .= $this->buildSelectExpression($v);
$sql .= $this->buildUserVariableExpression($v);

if ($len == strlen($sql)) {
throw new UnableToCreateSQLException('function subtree', $k, $v, 'expr_type');
Expand Down