Skip to content

Commit 7d64afa

Browse files
committed
Expressions are permitted in SET operations.
1 parent 4f15f1d commit 7d64afa

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

src/Components/SetOperation.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,25 +86,34 @@ public static function parse(Parser $parser, TokensList $list, array $options =
8686

8787
// No keyword is expected.
8888
if (($token->type === Token::TYPE_KEYWORD) && ($token->flags & Token::FLAG_KEYWORD_RESERVED)) {
89-
break;
89+
if ($state == 0) {
90+
break;
91+
}
9092
}
9193

9294
if ($state === 0) {
9395
if ($token->token === '=') {
9496
$state = 1;
95-
} else {
97+
} else if ($token->value !== ',') {
9698
$expr->column .= $token->token;
9799
}
98100
} elseif ($state === 1) {
99-
if ($token->token === ',') {
100-
$expr->column = trim($expr->column);
101-
$expr->value = trim($expr->value);
102-
$ret[] = $expr;
103-
$expr = new SetOperation();
104-
$state = 0;
105-
} else {
106-
$expr->value .= $token->token;
101+
$tmp = Expression::parse(
102+
$parser,
103+
$list,
104+
array(
105+
'noAlias' => true,
106+
)
107+
);
108+
if ($tmp == null) {
109+
$expr = null;
110+
break;
107111
}
112+
$expr->column = trim($expr->column);
113+
$expr->value = $tmp->expr;
114+
$ret[] = $expr;
115+
$expr = new SetOperation();
116+
$state = 0;
108117
}
109118
}
110119

0 commit comments

Comments
 (0)