-
Notifications
You must be signed in to change notification settings - Fork 60
support search for table #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
package.json
Outdated
{ | ||
"command": "mysql.searchTable", | ||
"title": "Search Table", | ||
"icon": { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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
src/common/global.ts
Outdated
} | ||
|
||
public static tableFilter(tables: any[]) { | ||
if ( Global.keyword ) { |
There was a problem hiding this comment.
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.
src/mysqlTreeDataProvider.ts
Outdated
|
||
public async searchTable() { | ||
Global.keyword = await vscode.window.showInputBox({ prompt: "" , placeHolder: "table", value: Global.keyword }); | ||
this.refresh(); |
There was a problem hiding this comment.
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.
There was a problem hiding this 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", |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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
src/model/connectionNode.ts
Outdated
|
||
return Utility.queryPromise<any[]>(connection, "SHOW DATABASES") | ||
.then((databases) => { | ||
if ( this.keyword ) { |
There was a problem hiding this comment.
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
src/model/connectionNode.ts
Outdated
.then((databases) => { | ||
if ( this.keyword ) { | ||
databases = databases.filter((table) => { | ||
return table.Database.indexOf( this.keyword ) !== -1; |
There was a problem hiding this comment.
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) => { |
There was a problem hiding this comment.
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
src/model/connectionNode.ts
Outdated
return Utility.queryPromise<any[]>(connection, "SHOW DATABASES") | ||
.then((databases) => { | ||
if ( this.keyword ) { | ||
databases = databases.filter((table) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
table -> database
src/model/databaseNode.ts
Outdated
certPath: this.certPath, | ||
}); | ||
|
||
return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${Utility.maxTableCount}`) |
There was a problem hiding this comment.
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}%'` : ""; |
There was a problem hiding this comment.
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}%'` : "")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also resolve https://github.com/formulahendry/vscode-mysql/pull/12/files#r159821601
有木有搜索图标可以用一下 ?现在的图标不太合适【
】