gchq / gchq/CyberChef

Bug report: SQL Beautify not evaluating 'UNION ALL' correctly

Open
#1,119 1 comment 1 reaction 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
35.8k
Forks
4.1k
Avg merge
2d 26m
Merged PRs (30d)
33

Description

**Describe the bug**
When using SQL beautify on an input that uses the 'UNION ALL' keyword, invalid SQL is returned.

**To Reproduce**
Add 'SQL Beautify' operation, paste the following example input:
```sql
SELECT City FROM Customers UNION ALL SELECT City FROM Suppliers ORDER BY City;
```

Gets incorrectly beautified to:
```sql
SELECT City
FROM Customers
UNION
ALLSELECT City
FROM Suppliers
ORDER BY City;
```

**Expected behaviour**
Should result in:
```sql
SELECT City
FROM Customers
UNION ALL
SELECT City
FROM Suppliers
ORDER BY City;
```

**Desktop (if relevant, please complete the following information):**
- OS: Windows
- Browser: Chrome 86.0.4240.111
- CyberChef version: 9.21.0

Seems like CyberChef is just using [aabluedragon/vkbeautify](https://github.com/aabluedragon/vkbeautify) under the hood, which no longer seems active; not sure what a suitable fix/replacement would be seeing as it's also used for JSON, CSS & XML beautify/minify operations and it would seem wasteful to drop in a replacement purely for SQL.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.