mtxr / SublimeText-SQLTools

SQLTools for Sublime Text 3
https://code.mteixeira.dev/SublimeText-SQLTools/
GNU General Public License v3.0
177 stars 40 forks source link

Comment in the drop-down list tables #202

Closed mercurykd closed 5 years ago

mercurykd commented 6 years ago

I modified the query

 "desc table": {
                    "query": "SELECT t.table_schema `Database`, t.table_name `Table`, t.engine `Engine`, t.table_rows `Rows`, round(((t.data_length + t.index_length) / 1024 / 1024), 2) as `Size in MB`, t.table_comment `Comment`,t.create_time `Create`, t.update_time `Update` FROM information_schema.tables t WHERE t.table_name = '{0}' AND t.table_schema=database();SELECT c.column_name `Field`, c.column_type `Type`, c.column_default 'Default', c.is_nullable 'Null', c.column_key 'Key', c.extra `Extra`, c.column_comment `Comment` FROM information_schema.columns c WHERE c.table_name = '{0}' AND c.table_schema=database() ORDER BY c.ordinal_position ASC;SHOW INDEX FROM {0};",
                    "options": ["--table"]
                },
                "desc" : {
                    "query": "SELECT CASE WHEN TABLE_NAME REGEXP '[^0-9a-zA-Z$_]' THEN concat('`',TABLE_NAME,'`') ELSE TABLE_NAME END AS obj FROM information_schema.tables WHERE table_schema = database() ORDER BY TABLE_NAME;",
                    "options": ["--silent", "--raw", "--skip-column-names"]
                }

but I can not force to display in front of the table name its comment in the drop-down list, I can but then there are difficulties in 'desc_table', because "show index from" requires the table name directly and does not accept any subquery select

Have any idea?

tkopets commented 5 years ago

It is not possible to include extra data in queries that return the list of tables. SQLTools expect this query to be in a certain specific format to be able to parse it and later on use this data in completions and popup filter panels (like ST: Describe Table).