Skip to content

Conversation

2276225819
Copy link
Contributor

有木有搜索图标可以用一下 ?现在的图标不太合适【

package.json Outdated
{
"command": "mysql.searchTable",
"title": "Search Table",
"icon": {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do you use the icon?

package.json Outdated
"category": "MySQL"
},
{
"command": "mysql.searchTable",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is more like filter not search

}

public static tableFilter(tables: any[]) {
if ( Global.keyword ) {
Copy link
Owner

@formulahendry formulahendry Dec 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter should only take place on a certain database not global.


public async searchTable() {
Global.keyword = await vscode.window.showInputBox({ prompt: "" , placeHolder: "table", value: Global.keyword });
this.refresh();
Copy link
Owner

@formulahendry formulahendry Dec 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refresh should only take place on a certain database not global.

Copy link
Owner

@formulahendry formulahendry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also rebase with the master branch

package.json Outdated
},
{
"command": "mysql.keywordFilter",
"title": "Keyword Filter",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better naming? Just call it Filter?

package.json Outdated
"group": "mysql@1"
},
{
"command": "mysql.keywordFilter",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put this after mysql.deleteConnection

package.json Outdated
{
"command": "mysql.keywordFilter",
"when": "view == mysql && viewItem == connection",
"group": "mysql@2"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be mysql@2?

package.json Outdated
"group": "mysql@2"
},
{
"command": "mysql.keywordFilter",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it after

{
                    "command": "mysql.refresh",
                    "when": "view == mysql && viewItem == database",
                    "group": "mysql@1"
                }

import { INode } from "./INode";

export class ConnectionNode implements INode {
public keyword;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a blank line after this

import { TableNode } from "./tableNode";

export class DatabaseNode implements INode {
public keyword;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leave a blank line after this


return Utility.queryPromise<any[]>(connection, "SHOW DATABASES")
.then((databases) => {
if ( this.keyword ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No extra space inside parentheses

.then((databases) => {
if ( this.keyword ) {
databases = databases.filter((table) => {
return table.Database.indexOf( this.keyword ) !== -1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: No extra space inside parentheses

public async keywordFilter(node: DatabaseNode | ConnectionNode) {
vscode.window.showInputBox({
prompt: "" , placeHolder: "keyword", value: node.keyword,
validateInput: (keyword: string) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It this by design? It will trigger this.refresh(node) every time user input or delete a character. For the better practice, it should be only trigger when user press Enter

return Utility.queryPromise<any[]>(connection, "SHOW DATABASES")
.then((databases) => {
if ( this.keyword ) {
databases = databases.filter((table) => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

table -> database

certPath: this.certPath,
});

return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${Utility.maxTableCount}`)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this.keyword is set, how about updating the SQL to add TABLE_NAME like '%this.keyword%'? In case there are over thousands of tables in a database.

});

return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${Utility.maxTableCount}`)
const filter = this.keyword ? `TABLE_NAME LIKE '%${this.keyword}%'` : "";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Miss AND

});

return Utility.queryPromise<any[]>(connection, "SHOW DATABASES")
return Utility.queryPromise<any[]>(connection, "SHOW DATABASES" + (this.keyword ? ` LIKE '%${this.keyword}%'` : ""))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Database name becomes blank:
image

Copy link
Owner

@formulahendry formulahendry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

2 participants