Bug #100608 Beautify query doesn't work when CAST(<field>) AS DOUBLE is used
Submitted: 21 Aug 2020 18:25 Modified: 31 Aug 2020 13:19
Reporter: A.H.R. Huzen Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:8.0.21, 8.0.31, 8.0.32, 8.0.33 OS:MacOS
Assigned to: CPU Architecture:x86

[21 Aug 2020 18:25] A.H.R. Huzen
Description:
This query doesn't get beautified when applied or changed on Ctrl+B:
CREATE VIEW `v_test` AS select cast(`ra`.`hours` as double) AS `hours_raw` from `v_resource_allocation_compact` `ra`

But this one does:
CREATE VIEW `v_test` AS select `ra`.`hours` AS `hours_raw` from `v_resource_allocation_compact` `ra`

The result is:
CREATE VIEW `v_test` AS
    SELECT 
        `ra`.`hours` AS `hours_raw`
    FROM
        `v_resource_allocation_compact` `ra`

Know that `ra`.`hours` was already a DOUBLE from the beginning.
Of course, this situation didn't arrive in the bare form where it is presented here. I started with: cast(format(sum(`ra`.`hours`),2) as double).

How to repeat:
See description.

Suggested fix:
Make sure beautify query works also with CAST( ) AS DOUBLE.
[31 Aug 2020 13:19] MySQL Verification Team
Hello Huzen,

Thank you for the bug report.
Verified as described.

Regards,
Ashwini Patil
[27 Dec 2022 13:10] MySQL Verification Team
Bug #109480 marked as duplicate of this one
[7 Apr 2023 12:08] MySQL Verification Team
Bug #110631 marked as duplicate of this one
[23 Aug 2023 12:42] MySQL Verification Team
Bug #112146 marked as duplicate of this one