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

fix issue #299: arithmetic operations in brackets are comma separated #306

Conversation

nicoder
Copy link
Contributor

@nicoder nicoder commented May 20, 2019

for example the query:

SELECT (1 + 2) AS THREE, (1 + 3) AS FOUR

would become:

SELECT (1,+,2) AS THREE, (1 + 3) AS FOUR

This is a regression caused by commit 3a9d906, that meant to add missing
commas in expressions like CAST(... AS DECIMAL(16, 2)),
but added too many commas visibly.

=> revert the parts of that commit that changed the code (leave the
added test assertion)

=> change the ExpressionListProcessor code that handles
unspecified nodes.

That code was added in commit 63d59d7, apparently to solve issue 51:
https://code.google.com/archive/p/php-sql-parser/issues/51

It seems to have copied and pasted the code that handles function
arguments, just above.

But that code does not keep commas,
and while the FunctionBuilder adds them back,
the SelectBracketExpressionBuilder does not.

The issue51Test.php test seems to cover the bug described in issue 51,
and it still passes (as do the other tests).

So maybe we do not need the same handling as for function arguments in
unspecified nodes?

Hopefully someone with a better understanding of this code can have a look.

…separated

for example the query:

```sql
SELECT (1 + 2) AS THREE, (1 + 3) AS FOUR
```

would become:

```sql
SELECT (1,+,2) AS THREE, (1 + 3) AS FOUR
```

This is a regression caused by commit 3a9d906, that meant to add missing
commas in expressions like `CAST(... AS DECIMAL(16, 2))`,
but added too many commas visibly.

=> revert the parts of that commit that changed the code (leave the
added test assertion)

=> change the `ExpressionListProcessor` code that handles
unspecified nodes.

That code was added in commit 63d59d7, apparently to solve issue 51:
https://code.google.com/archive/p/php-sql-parser/issues/51

It seems to have copied and pasted the code that handles function
arguments, just above.

But that code does not keep commas,
and while the `FunctionBuilder` adds them back,
the `SelectBracketExpressionBuilder` does not.

The issue51Test test seems to cover the bug described in issue 51,
and it still passes.

So maybe we do not need the same handling as for function arguments in
unspecified nodes?

Hopefully someone with a better understanding of this code can have a look.
@greenlion
Copy link
Owner

Thank you for this contribution.

@greenlion greenlion merged commit a4ad4ea into greenlion:master Jun 1, 2019
theilig pushed a commit to theilig/PHP-SQL-Parser that referenced this pull request Jan 15, 2021
…separated (greenlion#306)

for example the query:

```sql
SELECT (1 + 2) AS THREE, (1 + 3) AS FOUR
```

would become:

```sql
SELECT (1,+,2) AS THREE, (1 + 3) AS FOUR
```

This is a regression caused by commit 3a9d906, that meant to add missing
commas in expressions like `CAST(... AS DECIMAL(16, 2))`,
but added too many commas visibly.

=> revert the parts of that commit that changed the code (leave the
added test assertion)

=> change the `ExpressionListProcessor` code that handles
unspecified nodes.

That code was added in commit 63d59d7, apparently to solve issue 51:
https://code.google.com/archive/p/php-sql-parser/issues/51

It seems to have copied and pasted the code that handles function
arguments, just above.

But that code does not keep commas,
and while the `FunctionBuilder` adds them back,
the `SelectBracketExpressionBuilder` does not.

The issue51Test test seems to cover the bug described in issue 51,
and it still passes.

So maybe we do not need the same handling as for function arguments in
unspecified nodes?

Hopefully someone with a better understanding of this code can have a look.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants