Home > Blockchain >  How can I remove excessive parentheses in MySQL view source
How can I remove excessive parentheses in MySQL view source

Time:01-18

I am adding views that join many table to my MySQL 5.7 database. When I try to view the source of the view after saving it I see that MySQL has added lots of parenthesis. How can I easily remove these to make my code more readable. I use DBeaver to do my editing. This is a snippet of what it does to my query that joins 12 tables.

from
    (
        (
            (
                (
                    (
                        (
                            (
                                (
                                    (
                                        (
                                            (
                                                (
                                                    (
                                                        `flight` `f`
                                                    join `flight_legs` `fl` on
                                                        (
                                                            (
                                                                `fl`.`flight_id` = `f`.`id`
                                                            )
                                                        )
                                                    )

CodePudding user response:

TLDR: You almost certainly can't.

Under the covers dbeaver is using MySQL's SHOW CREATE VIEW statement as seen here in the source of dbeaver's MySQL plugin which returns MySQL's internal representation of the view. According to the linked docs:

No matter how you write out a view definition, MySQL always stores it the same way, in a canonical form.

This is what is being returned to dbeaver when it queries for the view definition. It looks like dbeaver apply some formatting to the string after the fact, and that formatter does pull in preferences, but I expect that is more about indentation or syntax highlighting than changing the actual text. It would take more digging to be sure, but the answer is almost certainly that you can't.

  • Related