Browse Source

Support config default limit of query.

pull/45/head
cweijan 5 years ago
parent
commit
c86d59215f
  1. 3
      CHANGELOG.md
  2. 15
      README.md
  3. BIN
      images/setting.png
  4. 7
      package.json
  5. 3
      src/common/constants.ts
  6. 10
      src/model/main/tableNode.ts
  7. 10
      src/service/queryUnit.ts

3
CHANGELOG.md

@ -1,5 +1,8 @@
# CHANGELOG
## 2.3.7 - 2020/7/20
- Support config default limit of query.
## 2.3.6 - 2020/7/15
- Support edit date in result view.

15
README.md

@ -60,18 +60,9 @@ MySQL Client For Visual Studio Code
## Setting
```jsonc
{
// enable delimiter when import data
"vscode-mysql.enableDelimiter": false,
// Load database meta info when connected, If your machine's performance is low, turn it off.
"vscode-mysql.loadMetaOnConnect":true,
// set max tables show of each database.
"vscode-mysql.maxTableCount": 500
}
```
OpenSetting -> extensions -> Mysql
![Setting](images/setting.png)
## Other
* Find a suprise when you right click on a node.

BIN
images/setting.png

After

Width: 818  |  Height: 574  |  Size: 47 KiB

7
package.json

@ -2,7 +2,7 @@
"name": "vscode-mysql-client2",
"displayName": "MySQL",
"description": "MySQL Client for vscode",
"version": "2.3.6",
"version": "2.3.7",
"publisher": "cweijan",
"icon": "resources/logo.png",
"engines": {
@ -758,6 +758,11 @@
"default": true,
"description": "Load database meta info when connected, If your machine's performance is low, turn it off."
},
"vscode-mysql.defaultLimit": {
"type": "integer",
"default": "100",
"description": "Default limit of query sql."
},
"vscode-mysql.resultTheme": {
"type": "string",
"default": "Default",

3
src/common/constants.ts

@ -4,7 +4,6 @@ import * as path from "path";
export class Constants {
public static CONFIG_PREFIX = "vscode-mysql"
public static RES_PATH = path.join(vscode.extensions.getExtension('cweijan.vscode-mysql-client2').extensionPath, "resources");
public static DEFAULT_SIZE = 100;
}
export class Pattern {
@ -28,7 +27,7 @@ export enum ConfigKey {
ENABLE_DELIMITER = "enableDelimiter",
LOAD_META_ON_CONNECT = "loadMetaOnConnect",
REULST_THEME = "resultTheme",
DEFAULT_LIMIT = "defaultLimit",
}
export enum CommandKey {

10
src/model/main/tableNode.ts

@ -1,7 +1,7 @@
import * as path from "path";
import * as mysql from "mysql";
import * as vscode from "vscode";
import { Constants, ModelType, Template, MessageType } from "../../common/constants";
import { Constants, ModelType, Template, MessageType, ConfigKey } from "../../common/constants";
import { Util } from "../../common/util";
import { DbTreeDataProvider } from "../../provider/treeDataProvider";
import { DatabaseCache } from "../../service/common/databaseCache";
@ -15,6 +15,7 @@ import { MockRunner } from "../../service/mock/mockRunner";
import { QueryPage } from "../../view/result/query";
import { DataResponse } from "../../view/result/queryResponse";
import { ColumnMeta } from "../other/columnMeta";
import { Global } from "../../common/global";
export class TableNode extends Node implements CopyAble {
@ -119,12 +120,13 @@ ADD
}
public async openInNew() {
const sql = `SELECT * FROM ${Util.wrap(this.database)}.${Util.wrap(this.table)} LIMIT ${Constants.DEFAULT_SIZE};`;
const pageSize=Global.getConfig(ConfigKey.DEFAULT_LIMIT);
const sql = `SELECT * FROM ${Util.wrap(this.database)}.${Util.wrap(this.table)} LIMIT ${pageSize};`;
const connection = await ConnectionManager.getConnection(this);
const executeTime = new Date().getTime();
connection.query(sql, (err: mysql.MysqlError, data, fields?: mysql.FieldInfo[]) => {
const costTime = new Date().getTime() - executeTime;
QueryPage.send({ singlePage: false, type: MessageType.DATA, connection: this, res: { sql, costTime, data, fields, pageSize: Constants.DEFAULT_SIZE } as DataResponse });
QueryPage.send({ singlePage: false, type: MessageType.DATA, connection: this, res: { sql, costTime, data, fields, pageSize: pageSize } as DataResponse });
})
}
@ -134,7 +136,7 @@ ADD
}
public async selectSqlTemplate(run: boolean) {
const sql = `SELECT * FROM ${Util.wrap(this.database)}.${Util.wrap(this.table)} LIMIT ${Constants.DEFAULT_SIZE};`;
const sql = `SELECT * FROM ${Util.wrap(this.database)}.${Util.wrap(this.table)} LIMIT ${Global.getConfig(ConfigKey.DEFAULT_LIMIT)};`;
if (run) {
QueryUnit.runQuery(sql, this);

10
src/service/queryUnit.ts

@ -107,7 +107,7 @@ export class QueryUnit {
return;
}
if (Array.isArray(data)) {
QueryPage.send({ type: MessageType.DATA, connection: connectionNode, res: { sql, costTime, data, fields, pageSize: Constants.DEFAULT_SIZE } as DataResponse });
QueryPage.send({ type: MessageType.DATA, connection: connectionNode, res: { sql, costTime, data, fields, pageSize: Global.getConfig(ConfigKey.DEFAULT_LIMIT) } as DataResponse });
return;
}
QueryPage.send({ type: MessageType.MESSAGE, res: { message: `Execute sql success : ${sql}`, costTime, success: true } as MessageResponse });
@ -153,13 +153,13 @@ export class QueryUnit {
const sqlList = content.match(/(?:[^;"']+|["'][^"']*["'])+/g);
if (sqlList.length == 1) return sqlList[0];
const trimSqlList=[]
const trimSqlList = []
const docCursor = document.getText(Cursor.getRangeStartTo(current)).length;
let index = 0;
for (let i = 0; i < sqlList.length; i++) {
const sql = sqlList[i];
const trimSql=sql.trim();
if(trimSql){
const trimSql = sql.trim();
if (trimSql) {
trimSqlList.push(trimSql)
}
index += (sql.length + 1);
@ -169,7 +169,7 @@ export class QueryUnit {
}
}
return trimSqlList[trimSqlList.length-1];
return trimSqlList[trimSqlList.length - 1];
}
private static sqlDocument: vscode.TextEditor;

Loading…
Cancel
Save