author
int64 658
755k
| date
stringlengths 19
19
| timezone
int64 -46,800
43.2k
| hash
stringlengths 40
40
| message
stringlengths 5
490
| mods
list | language
stringclasses 20
values | license
stringclasses 3
values | repo
stringlengths 5
68
| original_message
stringlengths 12
491
|
|---|---|---|---|---|---|---|---|---|---|
141,908
|
15.05.2021 10:53:32
| -28,800
|
327c649e238892e7fc4ee771c7860c680ec38137
|
Version 3.8.2.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.8.2 2021-5-15\n+\n+- Connection keep origin position when edit.\n+- Support export SQLite data and struct.\n+- Fix possible connection delete bug.\n+\n# 3.8.0 2021-5-14\n- Support sqlite.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.1\",\n+ \"version\": \"3.8.2\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.2.
|
141,908
|
17.05.2021 09:50:06
| -28,800
|
72cacade11d70796e275aac16c1855a090fae0de
|
Fix pg duplicate columns.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/dialect/postgreSqlDialect.ts",
"new_path": "src/service/dialect/postgreSqlDialect.ts",
"diff": "@@ -155,8 +155,9 @@ ALTER TABLE ${table} ALTER COLUMN ${columnName} ${defaultDefinition};`;\ninformation_schema.columns c\nleft join information_schema.constraint_column_usage ccu\non c.COLUMN_NAME=ccu.column_name and c.table_name=ccu.table_name and ccu.table_catalog=c.TABLE_CATALOG\n+ and c.table_schema=ccu.table_schema\nleft join information_schema.table_constraints tc\n- on tc.constraint_name=ccu.constraint_name\n+ on tc.constraint_name=ccu.constraint_name and tc.table_schema=ccu.table_schema\nand tc.table_catalog=c.TABLE_CATALOG and tc.table_name=c.table_name WHERE c.TABLE_SCHEMA = '${database}' AND c.table_name = '${view ? view : table}' ORDER BY ORDINAL_POSITION;`;\n}\nshowTriggers(database: string): string {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix pg duplicate columns.
|
141,908
|
17.05.2021 09:57:58
| -28,800
|
97a8ff712801b95583476de61d71dae0cb18fc66
|
Fix list tables duplicate.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/dialect/postgreSqlDialect.ts",
"new_path": "src/service/dialect/postgreSqlDialect.ts",
"diff": "@@ -181,8 +181,8 @@ ALTER TABLE ${table} ALTER COLUMN ${columnName} ${defaultDefinition};`;\nshowTables(database: string): string {\nreturn ` SELECT t.table_name \"name\", pg_catalog.obj_description(pgc.oid, 'pg_class') \"comment\"\nFROM information_schema.tables t\n- INNER JOIN pg_catalog.pg_class pgc\n- ON t.table_name = pgc.relname\n+ JOIN pg_catalog.pg_class pgc ON t.table_name = pgc.relname\n+ JOIN pg_catalog.pg_namespace pgn ON pgn.oid=pgc.relnamespace and pgn.nspname=t.table_schema\nWHERE t.table_type='BASE TABLE'\nAND t.table_schema='${database}' order by t.table_name;`\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix list tables duplicate.
|
141,908
|
17.05.2021 16:39:23
| -28,800
|
006e11b0879ecd052f26a955bf99202ab9a05b93
|
Add schema keyword.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/keywordChain.ts",
"new_path": "src/provider/complete/chain/keywordChain.ts",
"diff": "@@ -3,7 +3,7 @@ import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\nexport class KeywordChain implements ComplectionChain {\n- private keywordList: string[] = [\"JOIN\", \"AND\", \"OR\", \"SELECT\", \"SET\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"IS\",\"NULL\",\"DATABASE\",\n+ private keywordList: string[] = [\"SCHEMA\",\"JOIN\", \"AND\", \"OR\", \"SELECT\", \"SET\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"IS\",\"NULL\",\"DATABASE\",\n\"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COLUMN\", \"BETWEEN\",\"RLIKE\",\n\"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\", \"ROLLBACK\", \"COMMENT\", \"COMMIT\", \"BEGIN\", \"DELIMITER\", \"CALL\", \"REPLACE\",\"TEMPORARY\",\n\"REFERENCES\", \"USING\", \"END\", \"BEFORE\", \"AFTER\", \"GRANT\", \"RETURNS\", \"SOME\", \"ANY\", \"ASC\", \"DESC\", \"UNIQUE\", \"UNION\", \"ALL\", \"ON\",\"REGEXP\",\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add schema keyword.
|
141,908
|
17.05.2021 17:36:43
| -28,800
|
f96e006b5f6453f66c308586b7eea4eb7d717a01
|
Support show mongo data.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/database/catalogNode.ts",
"new_path": "src/model/database/catalogNode.ts",
"diff": "@@ -2,11 +2,12 @@ import { DbTreeDataProvider } from \"@/provider/treeDataProvider\";\nimport { DatabaseCache } from \"@/service/common/databaseCache\";\nimport { QueryUnit } from \"@/service/queryUnit\";\nimport * as vscode from \"vscode\";\n-import { ModelType } from \"../../common/constants\";\n+import { DatabaseType, ModelType } from \"../../common/constants\";\nimport { Util } from '../../common/util';\nimport { ConnectionManager } from \"../../service/connectionManager\";\nimport { CopyAble } from \"../interface/copyAble\";\nimport { Node } from \"../interface/node\";\n+import { MongoTableGroup } from \"../mongo/mongoTableGroup\";\nexport class CatalogNode extends Node implements CopyAble {\n@@ -28,6 +29,9 @@ export class CatalogNode extends Node implements CopyAble {\n}\npublic getChildren(): Promise<Node[]> | Node[] {\n+ if(this.dbType==DatabaseType.MONGO_DB){\n+ return [ new MongoTableGroup(this) ]\n+ }\nreturn this.parent.getChildren.call(this,true)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/mongo/mongoTableGroup.ts",
"new_path": "src/model/mongo/mongoTableGroup.ts",
"diff": "-import { Constants, ModelType } from \"@/common/constants\";\n-import { DiagnosticRelatedInformation } from \"vscode\";\n+import { ModelType } from \"@/common/constants\";\n+import { TableMeta } from \"@/common/typeDef\";\n+import { ThemeIcon } from \"vscode\";\nimport { Node } from \"../interface/node\";\n-import { TableGroup } from \"../main/tableGroup\";\n-import * as path from \"path\";\n-import { MonggoBaseNode } from \"./mongoBaseNode\";\nimport { TableNode } from \"../main/tableNode\";\n+import { MonggoBaseNode } from \"./mongoBaseNode\";\nimport { MongoTableNode } from \"./mongoTableNode\";\n-import { TableMeta } from \"@/common/typeDef\";\nexport class MongoTableGroup extends MonggoBaseNode {\ncontextValue = ModelType.TABLE_GROUP;\n- public iconPath: string = path.join(Constants.RES_PATH, \"icon/table.svg\");\n+ public iconPath=new ThemeIcon(\"list-flat\")\nconstructor(readonly parent: Node) {\nsuper(\"COLLECTION\")\nthis.uid = `${parent.getConnectId()}_${parent.database}_${ModelType.TABLE_GROUP}`;\n@@ -27,7 +25,9 @@ export class MongoTableGroup extends MonggoBaseNode {\nconst tables = await client.db(this.database).listCollections().toArray()\nconst tableNodes = tables.map<TableNode>((table) => {\n- return new MongoTableNode({ name: table.name } as TableMeta, this);\n+ const mongoNode:TableNode = new MongoTableNode({ name: table.name } as TableMeta, this);\n+ mongoNode.schema=mongoNode.database\n+ return mongoNode;\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mongoConnection.ts",
"new_path": "src/service/connect/mongoConnection.ts",
"diff": "@@ -78,7 +78,7 @@ export class MongoConnection extends IConnection {\n// const indexNode = Node.nodeCache[`${this.opt.getConnectId()}_${indexName}`] as Node;\n// fields = (await indexNode?.getChildren())?.map((node: any) => { return { name: node.label, type: node.type, nullable: 'YES' }; }) as any;\n// }\n- callback(null, rows, fields);\n+ callback(null, rows, fields||[]);\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/queryUnit.ts",
"new_path": "src/service/queryUnit.ts",
"diff": "@@ -102,7 +102,8 @@ export class QueryUnit {\nif (Array.isArray(fields)) {\nconst isQuery = fields[0] != null && fields[0].name != undefined;\nconst isSqliteEmptyQuery = fields.length == 0 && sql.match(/\\bselect\\b/i);\n- if (isQuery || isSqliteEmptyQuery) {\n+ const isMongoEmptyQuery = fields.length == 0 && sql.match(/\\.collection\\b/i);\n+ if (isQuery || isSqliteEmptyQuery || isMongoEmptyQuery) {\nQueryPage.send({ connection: connectionNode, type: MessageType.DATA, queryOption, res: { sql, costTime, data, fields, total, pageSize: Global.getConfig(ConfigKey.DEFAULT_LIMIT) } as DataResponse });\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/connect/index.vue",
"new_path": "src/vue/connect/index.vue",
"diff": "\"PostgreSQL\",\n\"SqlServer\",\n\"SQLite\",\n- \"ElasticSearch\",\n\"MongoDB\",\n\"Redis\",\n+ \"ElasticSearch\",\n\"SSH\",\n\"FTP\"\n],\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support show mongo data.
|
141,908
|
17.05.2021 17:40:03
| -28,800
|
989953f38ccc9ae230f7356cf6a4774aa7918efc
|
Remove mongo group.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/database/catalogNode.ts",
"new_path": "src/model/database/catalogNode.ts",
"diff": "@@ -30,7 +30,7 @@ export class CatalogNode extends Node implements CopyAble {\npublic getChildren(): Promise<Node[]> | Node[] {\nif(this.dbType==DatabaseType.MONGO_DB){\n- return [ new MongoTableGroup(this) ]\n+ return new MongoTableGroup(this).getChildren()\n}\nreturn this.parent.getChildren.call(this,true)\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Remove mongo group.
|
141,908
|
17.05.2021 17:42:19
| -28,800
|
dc0cc5611f1728136aefc10d4a9376287cfc35c5
|
Add mongo icon.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/icon/mongodb-icon.svg",
"diff": "+<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 31 67\" fill=\"#fff\" fill-rule=\"evenodd\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><use xlink:href=\"#A\" x=\"1\" y=\"1\"/><symbol id=\"A\" overflow=\"visible\"><g stroke=\"none\" fill-rule=\"nonzero\"><path d=\"M14.174.175l1.708 3.208c.371.579.804 1.117 1.29 1.604 1.43 1.43 2.788 2.928 4.008 4.532 2.894 3.8 4.846 8 6.24 12.584a30.94 30.94 0 0 1 1.324 8.54c.14 8.646-2.824 16.07-8.8 22.24-.972.978-2.022 1.876-3.14 2.684-.592 0-.872-.454-1.116-.872-.454-.766-.732-1.64-.872-2.51-.21-1.046-.348-2.092-.28-3.172v-.488c-.048-.124-.57-48.124-.362-48.35z\" fill=\"#599636\"/><path d=\"M14.174.069c-.07-.14-.14-.034-.21.034.034.7-.21 1.324-.592 1.92-.4.592-.976 1.046-1.534 1.534-3.1 2.684-5.54 5.926-7.494 9.552-2.6 4.88-3.94 10.11-4.32 15.616-.174 1.986.628 8.994 1.254 11.016 1.708 5.368 4.776 9.866 8.75 13.77a35.08 35.08 0 0 0 3.1 2.65c.314 0 .348-.28.4-.488a9.57 9.57 0 0 0 .314-1.36l.7-5.228L14.174.069z\" fill=\"#6cac48\"/><path d=\"M15.882 57.691c.07-.8.454-1.464.872-2.126-.4-.174-.732-.52-.976-.906a6.47 6.47 0 0 1-.52-1.15c-.488-1.464-.592-3-.732-4.496v-.906c-.174.14-.21 1.324-.21 1.5-.102 1.581-.312 3.154-.628 4.706-.104.628-.174 1.254-.56 1.812 0 .07 0 .14.034.244.628 1.848.8 3.73.906 5.648v.7c0 .836-.034.66.66.94.28.104.592.14.872.348.21 0 .244-.174.244-.314l-.104-1.15v-3.208c-.034-.56.07-1.116.14-1.64z\" fill=\"#c2bfbf\"/></g></symbol></svg>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/connectionNode.ts",
"new_path": "src/model/database/connectionNode.ts",
"diff": "@@ -41,6 +41,8 @@ export class ConnectionNode extends Node implements CopyAble {\nthis.iconPath = path.join(Constants.RES_PATH, \"icon/mssql_server.png\");\n}else if(this.dbType==DatabaseType.SQLITE){\nthis.iconPath = path.join(Constants.RES_PATH, \"icon/sqlite-icon.svg\");\n+ }else if(this.dbType==DatabaseType.MONGO_DB){\n+ this.iconPath = path.join(Constants.RES_PATH, \"icon/mongodb-icon.svg\");\n}\nif (this.disable) {\nthis.collapsibleState = vscode.TreeItemCollapsibleState.None;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add mongo icon.
|
141,908
|
17.05.2021 17:46:24
| -28,800
|
a4aed6baa30f7ff8a3d9ff6865515219866e47d7
|
Update mongo icon.
|
[
{
"change_type": "MODIFY",
"old_path": "resources/icon/mongodb-icon.svg",
"new_path": "resources/icon/mongodb-icon.svg",
"diff": "-<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 31 67\" fill=\"#fff\" fill-rule=\"evenodd\" stroke=\"#000\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><use xlink:href=\"#A\" x=\"1\" y=\"1\"/><symbol id=\"A\" overflow=\"visible\"><g stroke=\"none\" fill-rule=\"nonzero\"><path d=\"M14.174.175l1.708 3.208c.371.579.804 1.117 1.29 1.604 1.43 1.43 2.788 2.928 4.008 4.532 2.894 3.8 4.846 8 6.24 12.584a30.94 30.94 0 0 1 1.324 8.54c.14 8.646-2.824 16.07-8.8 22.24-.972.978-2.022 1.876-3.14 2.684-.592 0-.872-.454-1.116-.872-.454-.766-.732-1.64-.872-2.51-.21-1.046-.348-2.092-.28-3.172v-.488c-.048-.124-.57-48.124-.362-48.35z\" fill=\"#599636\"/><path d=\"M14.174.069c-.07-.14-.14-.034-.21.034.034.7-.21 1.324-.592 1.92-.4.592-.976 1.046-1.534 1.534-3.1 2.684-5.54 5.926-7.494 9.552-2.6 4.88-3.94 10.11-4.32 15.616-.174 1.986.628 8.994 1.254 11.016 1.708 5.368 4.776 9.866 8.75 13.77a35.08 35.08 0 0 0 3.1 2.65c.314 0 .348-.28.4-.488a9.57 9.57 0 0 0 .314-1.36l.7-5.228L14.174.069z\" fill=\"#6cac48\"/><path d=\"M15.882 57.691c.07-.8.454-1.464.872-2.126-.4-.174-.732-.52-.976-.906a6.47 6.47 0 0 1-.52-1.15c-.488-1.464-.592-3-.732-4.496v-.906c-.174.14-.21 1.324-.21 1.5-.102 1.581-.312 3.154-.628 4.706-.104.628-.174 1.254-.56 1.812 0 .07 0 .14.034.244.628 1.848.8 3.73.906 5.648v.7c0 .836-.034.66.66.94.28.104.592.14.872.348.21 0 .244-.174.244-.314l-.104-1.15v-3.208c-.034-.56.07-1.116.14-1.64z\" fill=\"#c2bfbf\"/></g></symbol></svg>\n\\ No newline at end of file\n+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n+<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"69pt\" height=\"69pt\" viewBox=\"0 0 69 69\" version=\"1.1\">\n+<g id=\"surface1\">\n+<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(34.901961%,58.823529%,21.176471%);fill-opacity:1;\" d=\"M 33.773438 1.210938 L 37.574219 4.515625 C 38.402344 5.109375 39.367188 5.664062 40.449219 6.164062 C 43.628906 7.636719 46.652344 9.179688 49.367188 10.832031 C 55.808594 14.746094 60.15625 19.070312 63.257812 23.792969 C 65.125 26.644531 66.117188 29.605469 66.203125 32.585938 C 66.515625 41.492188 59.917969 49.136719 46.617188 55.492188 C 44.453125 56.5 42.117188 57.421875 39.628906 58.253906 C 38.3125 58.253906 37.6875 57.789062 37.144531 57.359375 C 36.132812 56.570312 35.515625 55.667969 35.203125 54.773438 C 34.734375 53.695312 34.429688 52.617188 34.582031 51.507812 L 34.582031 51.003906 C 34.472656 50.875 33.3125 1.441406 33.773438 1.210938 Z M 33.773438 1.210938 \"/>\n+<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(42.352941%,67.45098%,28.235294%);fill-opacity:1;\" d=\"M 33.773438 1.101562 C 33.617188 0.957031 33.460938 1.066406 33.308594 1.136719 C 33.382812 1.855469 32.839844 2.5 31.988281 3.113281 C 31.097656 3.722656 29.816406 4.191406 28.574219 4.691406 C 21.675781 7.457031 16.242188 10.796875 11.894531 14.53125 C 6.109375 19.554688 3.125 24.941406 2.277344 30.613281 C 1.890625 32.65625 3.675781 39.875 5.070312 41.957031 C 8.871094 47.484375 15.699219 52.117188 24.546875 56.136719 C 26.730469 57.109375 29.035156 58.019531 31.445312 58.867188 C 32.144531 58.867188 32.222656 58.578125 32.335938 58.363281 C 32.644531 57.90625 32.875 57.4375 33.035156 56.964844 L 34.59375 51.578125 Z M 33.773438 1.101562 \"/>\n+<path style=\" stroke:none;fill-rule:nonzero;fill:rgb(76.078431%,74.901961%,74.901961%);fill-opacity:1;\" d=\"M 37.574219 60.441406 C 37.730469 59.617188 38.585938 58.933594 39.515625 58.253906 C 38.625 58.074219 37.886719 57.71875 37.34375 57.320312 C 36.875 56.945312 36.488281 56.546875 36.1875 56.136719 C 35.101562 54.628906 34.871094 53.046875 34.558594 51.507812 L 34.558594 50.574219 C 34.171875 50.71875 34.089844 51.9375 34.089844 52.117188 C 33.863281 53.746094 33.394531 55.367188 32.691406 56.964844 C 32.460938 57.609375 32.304688 58.253906 31.445312 58.832031 C 31.445312 58.902344 31.445312 58.972656 31.523438 59.082031 C 32.917969 60.984375 33.300781 62.921875 33.539062 64.898438 L 33.539062 65.617188 C 33.539062 66.480469 33.460938 66.296875 35.007812 66.585938 C 35.628906 66.695312 36.324219 66.730469 36.949219 66.945312 C 37.414062 66.945312 37.492188 66.765625 37.492188 66.621094 L 37.261719 65.4375 L 37.261719 62.132812 C 37.183594 61.558594 37.414062 60.984375 37.570312 60.445312 Z M 37.574219 60.441406 \"/>\n+</g>\n+</svg>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/connectionNode.ts",
"new_path": "src/model/database/connectionNode.ts",
"diff": "@@ -35,6 +35,7 @@ export class ConnectionNode extends Node implements CopyAble {\nthis.description = parent.name\nthis.name = parent.name\n}\n+ // https://www.iloveimg.com/zh-cn/resize-image/resize-svg\nif (this.dbType == DatabaseType.PG) {\nthis.iconPath = path.join(Constants.RES_PATH, \"icon/pg_server.svg\");\n} else if (this.dbType == DatabaseType.MSSQL) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/mongo/mongoTableNode.ts",
"new_path": "src/model/mongo/mongoTableNode.ts",
"diff": "import { ModelType } from \"@/common/constants\";\n+import { TableMeta } from \"@/common/typeDef\";\nimport { MongoConnection } from \"@/service/connect/mongoConnection\";\nimport { ConnectionManager } from \"@/service/connectionManager\";\nimport { MongoClient } from \"mongodb\";\n@@ -9,8 +10,18 @@ export class MongoTableNode extends TableNode {\ncontextValue = ModelType.TABLE_GROUP;\ncollapsibleState=TreeItemCollapsibleState.None;\npublic async getChildren() {\n+ const client = await this.getClient()\n- return [];\n+ const tables = await client.db(this.database).listCollections().toArray()\n+\n+ const tableNodes = tables.map<TableNode>((table) => {\n+ const mongoNode:TableNode = new MongoTableNode({ name: table.name } as TableMeta, this);\n+ mongoNode.schema=mongoNode.database\n+ return mongoNode;\n+ });\n+\n+\n+ return tableNodes;\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Update mongo icon.
|
141,908
|
18.05.2021 10:45:46
| -28,800
|
e7ab51c34043002035344452298901597e011b5b
|
Add timeout detech.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -28,18 +28,25 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\n}\npublic async getChildren(element?: Node): Promise<Node[]> {\n+ return new Promise(async (res,rej)=>{\nif (!element) {\n- return this.getConnectionNodes();\n+ res(this.getConnectionNodes())\n+ return;\n}\ntry {\n+ const mark=setTimeout(() => {\n+ res([new InfoNode(`Connect time out!`)])\n+ }, element.connectTimeout||5000);\nconst children = await element.getChildren();\n+ clearTimeout(mark)\nfor (const child of children) {\nchild.parent = element;\n}\n- return children;\n+ res(children);\n} catch (error) {\n- return [new InfoNode(error)]\n+ res([new InfoNode(error)])\n}\n+ })\n}\npublic async openConnection(connectionNode: ConnectionNode) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add timeout detech.
|
141,908
|
18.05.2021 10:48:35
| -28,800
|
f8bf6533a3df44444b0b357019518b6307640c10
|
Mongo support auth.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mongoConnection.ts",
"new_path": "src/service/connect/mongoConnection.ts",
"diff": "@@ -10,7 +10,13 @@ export class MongoConnection extends IConnection {\n}\nconnect(callback: (err: Error) => void): void {\n- MongoClient.connect(`mongodb://${this.opt.host}:${this.opt.port}`, (err, client) => {\n+ let url = `mongodb://${this.opt.host}:${this.opt.port}`;\n+ if (this.opt.user && this.opt.password) {\n+ url = `mongodb://${this.opt.user}:${this.opt.password}@${this.opt.host}:${this.opt.port}`;\n+ }\n+ MongoClient.connect(url, {\n+ connectTimeoutMS: this.opt.connectTimeout || 5000, waitQueueTimeoutMS: this.opt.requestTimeout\n+ }, (err, client) => {\nif (!err) {\nthis.client = client;\nthis.conneted = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/connect/index.vue",
"new_path": "src/vue/connect/index.vue",
"diff": "</div>\n</section>\n- <section class=\"mb-2\" v-if=\"connectionOption.dbType!='FTP'\">\n+ <section class=\"mb-2\" v-if=\"connectionOption.dbType!='FTP' && connectionOption.dbType!='MongoDB'\">\n<div class=\"inline-block mr-10\">\n<label class=\"font-bold mr-5 inline-block w-32\">Databases</label>\n<input class=\"w-64 field__input\" placeholder=\"Special connection database\"\nthis.connectionOption.database = \"0\";\nbreak;\ncase \"MongoDB\":\n+ this.connectionOption.user = null;\n+ this.connectionOption.password = null;\nthis.connectionOption.port = 27017;\nbreak;\ncase \"FTP\":\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Mongo support auth.
|
141,908
|
18.05.2021 11:03:27
| -28,800
|
ae3a4e59aa96d7d882ab207b691f60060165a4e9
|
Support open mongo terminal.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/interface/node.ts",
"new_path": "src/model/interface/node.ts",
"diff": "@@ -289,6 +289,9 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\n}else if(this.dbType==DatabaseType.REDIS){\nthis.checkCommand('redis-cli');\ncommand = `redis-cli -h ${this.host} -p ${this.port} \\n`;\n+ }else if(this.dbType==DatabaseType.MONGO_DB){\n+ this.checkCommand('mongo');\n+ command = `mongo --host ${this.host} --port ${this.port} ${this.user&&this.password?` -u ${this.user} -p ${this.password}`:''} \\n`;\n}\nconst terminal = vscode.window.createTerminal(this.dbType.toString())\nterminal.sendText(command)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support open mongo terminal.
|
141,908
|
18.05.2021 11:08:05
| -28,800
|
d88e304bab926d2b9595c0ed1f486fe623bd3731
|
Support open sqlite shell.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/interface/node.ts",
"new_path": "src/model/interface/node.ts",
"diff": "@@ -2,6 +2,7 @@ import { Console } from \"@/common/Console\";\nimport { DatabaseType, ModelType } from \"@/common/constants\";\nimport { Util } from \"@/common/util\";\nimport { DbTreeDataProvider } from \"@/provider/treeDataProvider\";\n+import { getSqliteBinariesPath } from \"@/service/connect/sqlite/sqliteCommandValidation\";\nimport { ConnectionManager } from \"@/service/connectionManager\";\nimport { SqlDialect } from \"@/service/dialect/sqlDialect\";\nimport { QueryUnit } from \"@/service/queryUnit\";\n@@ -292,6 +293,9 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\n}else if(this.dbType==DatabaseType.MONGO_DB){\nthis.checkCommand('mongo');\ncommand = `mongo --host ${this.host} --port ${this.port} ${this.user&&this.password?` -u ${this.user} -p ${this.password}`:''} \\n`;\n+ }else if(this.dbType==DatabaseType.SQLITE){\n+\n+ command = `${getSqliteBinariesPath()} ${this.dbPath} \\n`;\n}\nconst terminal = vscode.window.createTerminal(this.dbType.toString())\nterminal.sendText(command)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support open sqlite shell.
|
141,908
|
18.05.2021 11:20:11
| -28,800
|
0cb9564fcbf7fa2458ad296b8d1e84408e34a86a
|
Mongo support use ssl.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mongoConnection.ts",
"new_path": "src/service/connect/mongoConnection.ts",
"diff": "+import * as fs from \"fs\";\nimport { Node } from \"@/model/interface/node\";\n-import { MongoClient } from \"mongodb\";\n+import { MongoClient, MongoClientOptions } from \"mongodb\";\nimport { IConnection, queryCallback } from \"./connection\";\nexport class MongoConnection extends IConnection {\nprivate conneted: boolean;\nprivate client: MongoClient;\n- constructor(private opt: Node) {\n+ private option: MongoClientOptions;\n+ constructor(private node: Node) {\nsuper()\n+ this.option = {\n+ connectTimeoutMS: this.node.connectTimeout || 5000, waitQueueTimeoutMS: this.node.requestTimeout,\n+ ssl: this.node.useSSL, sslValidate: false,\n+ sslCert: (node.clientCertPath) ? fs.readFileSync(node.clientCertPath) : null,\n+ sslKey: (node.clientKeyPath) ? fs.readFileSync(node.clientKeyPath) : null,\n+ } as MongoClientOptions;\n}\nconnect(callback: (err: Error) => void): void {\n- let url = `mongodb://${this.opt.host}:${this.opt.port}`;\n- if (this.opt.user && this.opt.password) {\n- url = `mongodb://${this.opt.user}:${this.opt.password}@${this.opt.host}:${this.opt.port}`;\n+ let url = `mongodb://${this.node.host}:${this.node.port}`;\n+ if (this.node.user && this.node.password) {\n+ url = `mongodb://${this.node.user}:${this.node.password}@${this.node.host}:${this.node.port}`;\n}\n- MongoClient.connect(url, {\n- connectTimeoutMS: this.opt.connectTimeout || 5000, waitQueueTimeoutMS: this.opt.requestTimeout\n- }, (err, client) => {\n+ MongoClient.connect(url, this.option, (err, client) => {\nif (!err) {\nthis.client = client;\nthis.conneted = true;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/connect/index.vue",
"new_path": "src/vue/connect/index.vue",
"diff": "<el-switch v-model=\"connectionOption.usingSSH\"></el-switch>\n</div>\n<div class=\"inline-block mr-10\"\n- v-if=\"connectionOption.dbType=='MySQL' || connectionOption.dbType=='PostgreSQL'\">\n+ v-if=\"connectionOption.dbType=='MySQL' || connectionOption.dbType=='PostgreSQL' || connectionOption.dbType=='MongoDB'\">\n<label class=\"font-bold mr-5 inline-block w-18\">Use SSL</label>\n<el-switch v-model=\"connectionOption.useSSL\"></el-switch>\n</div>\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Mongo support use ssl.
|
141,908
|
18.05.2021 11:30:09
| -28,800
|
a524d21a2e90ef6d9fe3a5223842e333e77ae863
|
Support reconnect mongo
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/mongo/mongoBaseNode.ts",
"new_path": "src/model/mongo/mongoBaseNode.ts",
"diff": "@@ -6,8 +6,8 @@ import { Node } from \"../interface/node\";\nexport class MonggoBaseNode extends Node{\npublic async getClient(): Promise<MongoClient> {\n- const redis = (await ConnectionManager.getConnection(this)) as MongoConnection\n- return new Promise(res => { redis.run(res) })\n+ const mongo = (await ConnectionManager.getConnection(this)) as MongoConnection\n+ return new Promise(res => { mongo.run(res) })\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/mongo/mongoTableGroup.ts",
"new_path": "src/model/mongo/mongoTableGroup.ts",
"diff": "@@ -19,9 +19,9 @@ export class MongoTableGroup extends MonggoBaseNode {\npublic async getChildren() {\n-\nconst client = await this.getClient()\n+ try {\nconst tables = await client.db(this.database).listCollections().toArray()\nconst tableNodes = tables.map<TableNode>((table) => {\n@@ -29,9 +29,11 @@ export class MongoTableGroup extends MonggoBaseNode {\nmongoNode.schema = mongoNode.database\nreturn mongoNode;\n});\n-\n-\nreturn tableNodes;\n+ } catch (error) {\n+ client.close()\n+ throw error;\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mongoConnection.ts",
"new_path": "src/service/connect/mongoConnection.ts",
"diff": "@@ -46,7 +46,7 @@ export class MongoConnection extends IConnection {\nend(): void {\n}\nisAlive(): boolean {\n- return this.conneted;\n+ return this.conneted && this.client && this.client.isConnected();\n}\nquery(sql: string, callback?: queryCallback): void;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support reconnect mongo
|
141,908
|
18.05.2021 15:19:55
| -28,800
|
3eebb22d7c9e7cc4fcf9ee8ef24b173ed6da228d
|
Fix ftp icon gone.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/ftp/ftpConnectionNode.ts",
"new_path": "src/model/ftp/ftpConnectionNode.ts",
"diff": "@@ -19,7 +19,7 @@ export class FTPConnectionNode extends FtpBaseNode {\nthis.contextValue = this.file ? ModelType.FTP_FOLDER : ModelType.FTP_CONNECTION;\nthis.init(parent)\nif (this.file) {\n- this.iconPath = path.join(Constants.RES_PATH, \"ssh/folder.svg\");\n+ this.iconPath = new vscode.ThemeIcon(\"folder\");\n} else {\nthis.iconPath = new vscode.ThemeIcon(\"server\");\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/ftp/ftpFileNode.ts",
"new_path": "src/model/ftp/ftpFileNode.ts",
"diff": "@@ -141,7 +141,7 @@ export class FTPFileNode extends FtpBaseNode {\n}\n- return `${extPath}/ssh/icon/${fileIcon}`\n+ return `${extPath}/ssh/${fileIcon}`\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix ftp icon gone.
|
141,908
|
18.05.2021 15:56:03
| -28,800
|
ae4999b9a227a999ad1b7b205b4b65ad2739c948
|
Support crud by mongo.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mongoConnection.ts",
"new_path": "src/service/connect/mongoConnection.ts",
"diff": "import * as fs from \"fs\";\nimport { Node } from \"@/model/interface/node\";\n-import { MongoClient, MongoClientOptions } from \"mongodb\";\n+import { MongoClient, MongoClientOptions, ObjectId as MObjectId } from \"mongodb\";\nimport { IConnection, queryCallback } from \"./connection\";\nexport class MongoConnection extends IConnection {\n@@ -61,10 +61,26 @@ export class MongoConnection extends IConnection {\nconsole.log(res)\n})\n} else {\n+ try {\nconst result = await eval('this.client.' + sql)\n+ if (!result) {\n+ callback(null)\n+ } else if (result.insertedCount != undefined) {\n+ callback(null, { affectedRows: result.insertedCount })\n+ } else if (result.updatedCount != undefined) {\n+ callback(null, { affectedRows: result.updatedCount })\n+ } else if (result.deletedCount != undefined) {\n+ callback(null, { affectedRows: result.deletedCount })\n+ } else {\nthis.handleSearch(sql, result, callback)\n}\n+ } catch (error) {\n+ callback(error)\n+ }\n}\n+ }\n+\n+\nprivate async handleSearch(sql: any, data: any, callback: any) {\nlet fields = null;\n@@ -79,7 +95,9 @@ export class MongoConnection extends IConnection {\nlet row = {};\nfor (const key in document) {\nrow[key] = document[key];\n- if (row[key] instanceof Object) {\n+ if (row[key] instanceof MObjectId) {\n+ row[key] = `ObjectID('${row[key]}')`;\n+ } else if (row[key] instanceof Object) {\nrow[key] = JSON.stringify(row[key]);\n}\n}\n@@ -94,3 +112,7 @@ export class MongoConnection extends IConnection {\n}\n}\n+\n+function ObjectID(objectId: string) {\n+ return new MObjectId(objectId)\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/result/query.ts",
"new_path": "src/service/result/query.ts",
"diff": "-import { FieldInfo } from \"@/common/typeDef\";\n+import { ColumnMeta, FieldInfo } from \"@/common/typeDef\";\nimport { Util } from \"@/common/util\";\nimport { EsRequest } from \"@/model/es/esRequest\";\nimport { ServiceManager } from \"@/service/serviceManager\";\n@@ -98,6 +98,8 @@ export class QueryPage {\ncase MessageType.DATA:\nif (queryParam.connection.dbType == DatabaseType.ES) {\nawait this.loadEsColumnList(queryParam);\n+ }else if (queryParam.connection.dbType == DatabaseType.MONGO_DB) {\n+ await this.loadMongoColumnList(queryParam);\n} else {\nawait this.loadColumnList(queryParam);\n}\n@@ -151,6 +153,15 @@ export class QueryPage {\nqueryParam.res.columnList = queryParam.res.fields.slice(4) as any[]\n}\n+ private static async loadMongoColumnList(queryParam: QueryParam<DataResponse>) {\n+ const parse = queryParam.res.sql.match(/db\\('(.+?)'\\)\\.collection\\('(.+?)'\\)/);\n+ queryParam.res.database = parse[1]\n+ queryParam.res.table = parse[2]\n+ queryParam.res.primaryKey = '_id'\n+ queryParam.res.tableCount = 1\n+ queryParam.res.columnList = queryParam.res.fields as any[]\n+ }\n+\nprivate static async loadColumnList(queryParam: QueryParam<DataResponse>) {\n// fix null point on result view\nqueryParam.res.columnList = []\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "</ux-table-column>\n</ux-grid>\n<!-- table result -->\n- <EditDialog ref=\"editor\" :dbType=\"result.dbType\" :table=\"result.table\" :primaryKey=\"result.primaryKey\" :primaryKeyList=\"result.primaryKeyList\" :columnList=\"result.columnList\" @execute=\"execute\" />\n+ <EditDialog ref=\"editor\" :dbType=\"result.dbType\" :database=\"result.database\" :table=\"result.table\" :primaryKey=\"result.primaryKey\" :primaryKeyList=\"result.primaryKeyList\" :columnList=\"result.columnList\" @execute=\"execute\" />\n<ExportDialog :visible.sync=\"exportOption.visible\" @exportHandle=\"confirmExport\" />\n</div>\n</template>\n@@ -508,6 +508,9 @@ export default {\n)\n.join(\"\\n\")}`\n: `DELETE /${this.result.table}/_doc/${checkboxRecords[0]}`;\n+ } else if (this.result.dbType == \"MongoDB\") {\n+ deleteSql = `db('${this.result.database}').collection(\"${this.result.table}\")\n+ .deleteMany({_id:{$in:[${checkboxRecords.join(\",\")}]}})`;\n}else {\ndeleteSql =\ncheckboxRecords.length > 1\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/EditDialog.vue",
"new_path": "src/vue/result/component/EditDialog.vue",
"diff": "@@ -31,7 +31,7 @@ import { wrapByDb } from \"@/common/wrapper\";\nexport default {\nmixins: [util],\ncomponents: { CellEditor },\n- props: [\"dbType\", \"table\", \"primaryKey\",\"primaryKeyList\", \"columnList\"],\n+ props: [\"dbType\",\"database\", \"table\", \"primaryKey\",\"primaryKeyList\", \"columnList\"],\ndata() {\nreturn {\nmodel: \"insert\",\n@@ -86,6 +86,9 @@ export default {\nif (this.dbType == \"ElasticSearch\") {\nthis.confirmInsertEs();\nreturn;\n+ }else if (this.dbType == \"MongoDB\") {\n+ this.confirmInsertMongo();\n+ return;\n}\nlet columns = \"\";\nlet values = \"\";\n@@ -111,6 +114,8 @@ export default {\nbuildUpdateSql(currentNew, oldRow) {\nif (this.dbType == \"ElasticSearch\") {\nreturn this.confirmUpdateEs(currentNew);\n+ }else if (this.dbType == \"MongoDB\") {\n+ return this.confirmUpdateMongo(currentNew,oldRow);\n}\nif (!this.primaryKey) {\nthis.$message.error(\"This table has not primary key, cannot update!\");\n@@ -167,6 +172,21 @@ export default {\n`POST /${this.table}/_doc\\n` + JSON.stringify(this.editModel)\n);\n},\n+ confirmInsertMongo() {\n+ this.$emit(\n+ \"execute\",\n+ `db('${this.database}').collection(\"${this.table}\").insertOne(${JSON.stringify(this.editModel)})\\n`\n+ );\n+ },\n+ confirmUpdateMongo(row, oldRow) {\n+ const temp=Object.assign({},row)\n+ delete temp['_id']\n+ const id=oldRow._id.indexOf(\"ObjectID\") != -1 ?oldRow._id:`'${oldRow._id}'`\n+ this.$emit(\n+ \"execute\",\n+ `db('${this.database}').collection(\"${this.table}\").updateOne({_id:${id}},{ $set:${JSON.stringify(temp)}})\\n`\n+ );\n+ },\nconfirmUpdateEs(row) {\nlet value = {};\nfor (const key in row) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support crud by mongo.
|
141,908
|
18.05.2021 16:00:39
| -28,800
|
6166fdd032cc538958c9523a7f8243831a9f73c9
|
Version 3.8.3.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.8.3 2021-5-18\n+\n+- Support connect to MongoDB.\n+- Fix postgresql duplicate tables.\n+\n# 3.8.2 2021-5-15\n- Connection keep origin position when edit.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.2\",\n+ \"version\": \"3.8.3\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n},\n{\n\"command\": \"mysql.name.copy\",\n- \"when\": \"view =~ /cweijan.+?ql/ && viewItem =~ /^(catalog|user|database|esColumn|column|table|view|esIndex|procedure|function|trigger)$/\",\n+ \"when\": \"view =~ /cweijan.+?ql/ && viewItem =~ /^(catalog|user|database|esColumn|column|table|view|esIndex|procedure|function|trigger|mongoTable|redisKey)$/\",\n\"group\": \"-1_mysql@-5\"\n},\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/mongo/mongoTableNode.ts",
"new_path": "src/model/mongo/mongoTableNode.ts",
"diff": "@@ -7,7 +7,7 @@ import { TreeItemCollapsibleState } from \"vscode\";\nimport { TableNode } from \"../main/tableNode\";\nexport class MongoTableNode extends TableNode {\n- contextValue = ModelType.TABLE_GROUP;\n+ contextValue = ModelType.MONGO_TABLE;\ncollapsibleState=TreeItemCollapsibleState.None;\npublic async getChildren() {\nreturn [];\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.3.
|
141,908
|
24.05.2021 09:28:16
| -28,800
|
cd99ba5117e4dafab94d70a2d20c0d8139fade42
|
Fix ssh forward icon gone.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/ssh/forward/forwardService.ts",
"new_path": "src/service/ssh/forward/forwardService.ts",
"diff": "@@ -24,7 +24,7 @@ export class ForwardService {\npublic createForwardView(sshConfig: SSHConfig) {\nViewManager.createWebviewPanel({\n- iconPath: join(Constants.RES_PATH,'ssh/icon/forward.svg'),\n+ iconPath: join(Constants.RES_PATH,'ssh/forward.svg'),\nsplitView: false, path: \"app\", title: `forward://${sshConfig.username}@${sshConfig.host}`,\neventHandler: (handler) => {\nhandler.on(\"init\", () => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix ssh forward icon gone.
|
141,908
|
24.05.2021 11:28:58
| -28,800
|
0f921a0819b6e28f68719fc1473ca18dc1523908
|
Extra row component from result view.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "<el-input type=\"textarea\" :autosize=\"{ minRows:2, maxRows:5}\" v-model=\"toolbar.sql\" class=\"sql-pannel\" />\n</div>\n<div class=\"toolbar\">\n- <el-button v-if=\"showFullBtn\" @click=\"full\" type=\"primary\" title=\"Full Result View\" icon=\"el-icon-rank\" size=\"mini\" circle>\n+ <el-button v-if=\"showFullBtn\" @click=\"()=>sendToVscode('full')\" type=\"primary\" title=\"Full Result View\" icon=\"el-icon-rank\" size=\"mini\" circle>\n</el-button>\n<el-input v-model=\"table.search\" size=\"mini\" placeholder=\"Input To Search Data\" style=\"width:200px\" :clearable=\"true\" />\n- <el-button type=\"primary\" size=\"mini\" icon=\"el-icon-milk-tea\" title=\"Buy the author a cup of coffee\" circle @click='openCoffee'></el-button>\n+ <el-button type=\"primary\" size=\"mini\" icon=\"el-icon-milk-tea\" title=\"Buy the author a cup of coffee\" circle @click=\"()=>sendToVscode('openCoffee')\"></el-button>\n<el-button @click=\"$refs.editor.openInsert()\" :disabled=\"result.tableCount!=1\" type=\"info\" title=\"Insert new row\" icon=\"el-icon-circle-plus-outline\" size=\"mini\" circle>\n</el-button>\n<el-button @click=\"deleteConfirm\" title=\"delete\" type=\"danger\" size=\"mini\" icon=\"el-icon-delete\" circle :disabled=\"!toolbar.show\">\n<ux-grid ref=\"dataTable\" v-loading='table.loading' size='small' :cell-style=\"{height: '35px'}\" @sort-change=\"sort\" :height=\"remainHeight\" width=\"100vh\" stripe @selection-change=\"selectionChange\" :checkboxConfig=\"{ checkMethod: ({row})=>editable&&!row.isFilter,highlight: true}\" :data=\"result.data.filter(data => !table.search || JSON.stringify(data).toLowerCase().includes(table.search.toLowerCase()))\" :show-header-overflow=\"false\" :show-overflow=\"false\">\n<ux-table-column type=\"checkbox\" width=\"40\" fixed=\"left\"> </ux-table-column>\n<ux-table-column type=\"index\" width=\"40\" :seq-method=\"({row,rowIndex})=>(rowIndex||!row.isFilter)?rowIndex:undefined\">\n- <template slot=\"header\" slot-scope=\"scope\">\n+ <template slot=\"header\">\n<el-popover placement=\"bottom\" title=\"Select columns to show\" width=\"200\" trigger=\"click\" type=\"primary\">\n<el-checkbox-group v-model=\"toolbar.showColumns\">\n<el-checkbox v-for=\"(column,index) in result.fields\" :label=\"column.name\" :key=\"index\">\n</el-popover>\n</template>\n</ux-table-column>\n- <ux-table-column v-if=\"result.fields && field.name && toolbar.showColumns.includes(field.name.toLowerCase())\" v-for=\"(field,index) in result.fields\" :key=\"index\" :resizable=\"true\" :field=\"field.name\" :title=\"field.name\" :sortable=\"true\" :width=\"computeWidth(field,0,index,toolbar.filter[field.name])\" edit-render>\n+ <ux-table-column v-if=\"result.fields && field.name && toolbar.showColumns.includes(field.name.toLowerCase())\" v-for=\"(field,index) in result.fields\" :key=\"index\" :resizable=\"true\" :field=\"field.name\" :title=\"field.name\" :sortable=\"true\" :width=\"computeWidth(field,0)\" edit-render>\n<template slot=\"header\" slot-scope=\"scope\">\n<el-tooltip class=\"item\" effect=\"dark\" :content=\"getTip(result.columnList[index],scope.column)\" placement=\"left-start\">\n<div>\n</el-tooltip>\n</template>\n<template slot-scope=\"scope\">\n- <template v-if=\"scope.row.isFilter\">\n- <el-input class='edit-filter' v-model=\"toolbar.filter[scope.column.title]\" :clearable='true' placeholder=\"Filter\" @clear=\"filter(null,scope.column.title)\" @keyup.enter.native=\"filter($event,scope.column.title)\">\n- </el-input>\n- </template>\n- <template v-if=\"!scope.row.isFilter\">\n- <div class=\"edit-column\" :contenteditable=\"editable\" style=\"height: 100%; line-height: 33px;\" @input=\"editListen($event,scope)\" @contextmenu.prevent=\"onContextmenu($event,scope)\" v-html='dataformat(scope.row[scope.column.title])'></div>\n- </template>\n+ <Row :scope=\"scope\" :result=\"result\" @execute=\"execute\" :filterObj=\"toolbar.filter\" :editList.sync=\"update.editList\" @sendToVscode=\"sendToVscode\" @openEditor=\"openEditor\"></Row>\n</template>\n</ux-table-column>\n</ux-grid>\n<script>\nimport { getVscodeEvent } from \"../util/vscode\";\nimport CellEditor from \"./component/CellEditor.vue\";\n+import Row from \"./component/Row.vue\";\nimport ExportDialog from \"./component/ExportDialog.vue\";\nimport EditDialog from \"./component/EditDialog.vue\";\nimport { util } from \"./mixin/util\";\n@@ -94,6 +89,7 @@ export default {\nCellEditor,\nExportDialog,\nEditDialog,\n+ Row,\n},\ndata() {\nreturn {\n@@ -126,6 +122,7 @@ export default {\ntoolbar: {\nsql: null,\nshow: false,\n+ // using to clear filter input value\nfilter: {},\nshowColumns: [],\n},\n@@ -199,7 +196,10 @@ export default {\n});\n});\nwindow.onkeypress = (e) => {\n- if ((e.code == \"Enter\" && e.target.classList.contains('edit-column') ) || (e.ctrlKey && e.code == \"KeyS\")) {\n+ if (\n+ (e.code == \"Enter\" && e.target.classList.contains(\"edit-column\")) ||\n+ (e.ctrlKey && e.code == \"KeyS\")\n+ ) {\nthis.save();\ne.stopPropagation();\ne.preventDefault();\n@@ -235,8 +235,11 @@ export default {\nhandlerCommon(response);\nthis.info.error = false;\nthis.info.needRefresh = false;\n- if(response.message.indexOf(\"AffectedRows\")!=-1 || response.isInsert){\n- this.refresh()\n+ if (\n+ response.message.indexOf(\"AffectedRows\") != -1 ||\n+ response.isInsert\n+ ) {\n+ this.refresh();\n}\nbreak;\ncase \"ERROR\":\n@@ -265,21 +268,9 @@ export default {\n},\nmethods: {\ngetTip(column, scopeColumn) {\n- if(!column || !column.comment)return scopeColumn.title\n-\n+ if (!column || !column.comment) return scopeColumn.title;\nreturn column.comment;\n},\n- editListen(event, scope) {\n- const { row, column, rowIndex } = scope;\n- const editList = this.update.editList;\n- if (!editList[rowIndex]) {\n- editList[rowIndex] = { ...row };\n- delete editList[rowIndex]._XID;\n- console.log(editList[rowIndex]);\n- }\n- editList[rowIndex][column.title] = event.target.textContent;\n- vscodeEvent.emit(\"dataModify\");\n- },\nsave() {\nif (Object.keys(this.update.editList).length == 0 && this.update.lock) {\nreturn;\n@@ -297,11 +288,15 @@ export default {\nvscodeEvent.emit(\"saveModify\", sql);\n}\n},\n- full() {\n- vscodeEvent.emit(\"full\");\n+ sendToVscode(event, param) {\n+ vscodeEvent.emit(event, param);\n},\n- openCoffee() {\n- vscodeEvent.emit(\"openCoffee\");\n+ openEditor(row, isCopy) {\n+ if (isCopy) {\n+ this.$refs.editor.openCopy(row);\n+ } else {\n+ this.$refs.editor.openEdit(row);\n+ }\n},\nconfirmExport(exportOption) {\nvscodeEvent.emit(\"export\", {\n@@ -312,148 +307,6 @@ export default {\n},\n});\n},\n- onContextmenu(event, scope) {\n- const { row, column } = scope;\n- const name = column.title;\n- const value = event.target.textContent;\n- event.target.value = value;\n- this.$contextmenu({\n- items: [\n- {\n- label: `Copy`,\n- onClick: () => {\n- vscodeEvent.emit(\"copy\", value);\n- },\n- divided: true,\n- },\n- {\n- label: `Open Edit Dialog`,\n- onClick: () => {\n- this.$refs.editor.openEdit(row);\n- },\n- },\n- {\n- label: `Open Copy Dialog`,\n- onClick: () => {\n- this.$refs.editor.openCopy(row);\n- },\n- divided: true,\n- },\n- {\n- label: `Filter by ${name} = '${value}'`,\n- onClick: () => {\n- this.filter(event, name, \"=\");\n- },\n- },\n- {\n- label: \"Filter by\",\n- divided: true,\n- children: [\n- {\n- label: `Filter by ${name} > '${value}'`,\n- onClick: () => {\n- this.filter(event, name, \">\");\n- },\n- },\n- {\n- label: `Filter by ${name} >= '${value}'`,\n- onClick: () => {\n- this.filter(event, name, \">=\");\n- },\n- divided: true,\n- },\n- {\n- label: `Filter by ${name} < '${value}'`,\n- onClick: () => {\n- this.filter(event, name, \"<\");\n- },\n- },\n- {\n- label: `Filter by ${name} <= '${value}'`,\n- onClick: () => {\n- this.filter(event, name, \"<=\");\n- },\n- divided: true,\n- },\n- {\n- label: `Filter by ${name} LIKE '%${value}%'`,\n- onClick: () => {\n- event.target.value = `%${value}%`;\n- this.filter(event, name, \"LIKE\");\n- },\n- },\n- {\n- label: `Filter by ${name} NOT LIKE '%${value}%'`,\n- onClick: () => {\n- event.target.value = `%${value}%`;\n- this.filter(event, name, \"NOT LIKE\");\n- },\n- },\n- ],\n- },\n- ],\n- event,\n- customClass: \"class-a\",\n- zIndex: 3,\n- minWidth: 230,\n- });\n- return false;\n- },\n- filter(event, column, operation) {\n- if (!operation) operation = \"=\";\n- let inputvalue = \"\" + (event ? event.target.value : \"\");\n- if (this.result.dbType == \"ElasticSearch\") {\n- vscodeEvent.emit(\"esFilter\", { match: { [column]: inputvalue } });\n- return;\n- }\n-\n- let filterSql =\n- this.result.sql.replace(/\\n/, \" \").replace(\";\", \" \") + \" \";\n-\n- let existsCheck = new RegExp(\n- `(WHERE|AND)?\\\\s*\\`?${column}\\`?\\\\s*(=|is|>=|<=|<>)\\\\s*.+?\\\\s`,\n- \"igm\"\n- );\n-\n- if (inputvalue) {\n- const condition =\n- inputvalue.toLowerCase() === \"null\"\n- ? `${column} is null`\n- : `${wrapByDb(\n- column,\n- this.result.dbType\n- )} ${operation} '${inputvalue}'`;\n- if (existsCheck.exec(filterSql)) {\n- // condition present\n- filterSql = filterSql.replace(existsCheck, `$1 ${condition} `);\n- } else if (filterSql.match(/\\bwhere\\b/gi)) {\n- //have where\n- filterSql = filterSql.replace(\n- /\\b(where)\\b/gi,\n- `\\$1 ${condition} AND `\n- );\n- } else {\n- //have not where\n- filterSql = filterSql.replace(\n- new RegExp(`(from\\\\s*.+?)\\\\s`, \"ig\"),\n- `\\$1 WHERE ${condition} `\n- );\n- }\n- } else {\n- // empty value, clear filter\n- let beforeAndCheck = new RegExp(\n- `\\\\b${column}\\\\b\\\\s*(=|is)\\\\s*.+?\\\\s*AND`,\n- \"igm\"\n- );\n- if (beforeAndCheck.exec(filterSql)) {\n- filterSql = filterSql.replace(beforeAndCheck, \"\");\n- } else {\n- filterSql = filterSql.replace(existsCheck, \" \");\n- }\n- }\n-\n- this.execute(filterSql + \";\");\n- },\nchangePageSize(size) {\nthis.page.pageSize = size;\nvscodeEvent.emit(\"changePageSize\", size);\n@@ -509,7 +362,9 @@ export default {\n.join(\"\\n\")}`\n: `DELETE /${this.result.table}/_doc/${checkboxRecords[0]}`;\n} else if (this.result.dbType == \"MongoDB\") {\n- deleteSql = `db('${this.result.database}').collection(\"${this.result.table}\")\n+ deleteSql = `db('${this.result.database}').collection(\"${\n+ this.result.table\n+ }\")\n.deleteMany({_id:{$in:[${checkboxRecords.join(\",\")}]}})`;\n} else {\ndeleteSql =\n@@ -529,22 +384,27 @@ export default {\n}\n});\n},\n- computeWidth(field, index, keyIndex, value) {\n+ /**\n+ * compute column row width, get maxium of fieldName or value or fieldType by top 10 row.\n+ */\n+ computeWidth(field, index) {\n+ // only compute once.\nlet key = field.name;\n- if (this.table.widthItem[keyIndex]) return this.table.widthItem[keyIndex];\n+ if (this.table.widthItem[key]) return this.table.widthItem[key];\nif (!index) index = 0;\nif (!this.result.data[index] || index > 10) return 70;\n- if (!value) {\n- value = this.result.data[index][key];\n- }\n- var dynamic = value ? (value + \"\").length * 10 :\n- Math.max((key + \"\").length * 10,(field.type+\"\").length*10)\n- ;\n+ const value = this.result.data[index][key];\n+ var dynamic = Math.max(\n+ (key + \"\").length * 10,\n+ (value + \"\").length * 10,\n+ (field.type + \"\").length * 10\n+ );\nif (dynamic > 150) dynamic = 150;\nif (dynamic < 70) dynamic = 70;\n- var nextDynamic = this.computeWidth(field, index + 1, keyIndex);\n+ var nextDynamic = this.computeWidth(field, index + 1);\nif (dynamic < nextDynamic) dynamic = nextDynamic;\n- this.table.widthItem[keyIndex] = dynamic;\n+ // cache column width\n+ this.table.widthItem[key] = dynamic;\nreturn dynamic;\n},\nrefresh() {\n@@ -572,15 +432,7 @@ export default {\n});\nthis.table.loading = true;\n},\n- dataformat(origin) {\n- if (origin == undefined || origin == null) {\n- return \"<span class='null-column'>(NULL)</span>\";\n- }\n- if (origin.hasOwnProperty(\"type\")) {\n- return String.fromCharCode.apply(null, new Uint16Array(origin.data));\n- }\n- return origin;\n- },\n+\ninitShowColumn() {\nconst fields = this.result.fields;\nif (!fields) return;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/CellEditor.vue",
"new_path": "src/vue/result/component/CellEditor.vue",
"diff": "<template v-else-if=\"isDateTime(type)\">\n<el-date-picker value-format=\"yyyy-MM-dd HH:mm:ss\" type=\"datetime\" :value=\"value\" @input=\"sync\"></el-date-picker>\n</template>\n- <el-input v-else=\"type\" :value=\"value\" @input=\"sync\"></el-input>\n+ <el-input v-else :value=\"value\" @input=\"sync\"></el-input>\n</div>\n</template>\n<script>\n-import { METHODS } from \"http\"\nexport default {\nprops: [\"type\", \"value\"],\nmethods: {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/EditDialog.vue",
"new_path": "src/vue/result/component/EditDialog.vue",
"diff": "@@ -150,7 +150,7 @@ export default {\n}\n}\nconsole.log(updateSql)\n- return updateSql;\n+ return updateSql+\";\";\n},\nconfirmUpdate(row, oldRow) {\nif (!oldRow) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/vue/result/component/Row.vue",
"diff": "+<template>\n+ <div>\n+ <template v-if=\"scope.row.isFilter\">\n+ <el-input class='edit-filter' v-model=\"filterObj[scope.column.title]\" :clearable='true' placeholder=\"Filter\" @clear=\"filter(null,scope.column.title)\" @keyup.enter.native=\"filter($event,scope.column.title)\">\n+ </el-input>\n+ </template>\n+ <template v-if=\"!scope.row.isFilter && result.dbType=='ElasticSearch'\">\n+ <div class=\"edit-column\" :contenteditable=\"editable\" style=\"height: 100%; line-height: 33px;\" @input=\"editListen($event,scope)\" @contextmenu.prevent=\"onContextmenu($event,scope)\" v-html='dataformat(scope.row[scope.column.title])'></div>\n+ </template>\n+ <template v-else>\n+ <div class=\"edit-column\" :contenteditable=\"editable\" style=\"height: 100%; line-height: 33px;\" @input=\"editListen($event,scope)\" @contextmenu.prevent=\"onContextmenu($event,scope)\">\n+ <template v-if=\"scope.row[scope.column.title]\">\n+ <span v-text='dataformat(scope.row[scope.column.title])'></span>\n+ </template>\n+ <template v-else>\n+ <span class='null-column'>(NULL)</span>\n+ </template>\n+ </div>\n+ </template>\n+ </div>\n+</template>\n+\n+<script>\n+import { wrapByDb } from \"@/common/wrapper\";\n+\n+export default {\n+ props: [\"result\", \"scope\", \"editList\",\"filterObj\"],\n+ methods: {\n+ dataformat(origin) {\n+ if (origin == undefined || origin == null) {\n+ return \"<span class='null-column'>(NULL)</span>\";\n+ }\n+ if (origin.hasOwnProperty(\"type\")) {\n+ return String.fromCharCode.apply(null, new Uint16Array(origin.data));\n+ }\n+ return origin;\n+ },\n+ editListen(event, scope) {\n+ const { row, column, rowIndex } = scope;\n+ const editList = this.editList.concat([]);\n+ if (!editList[rowIndex]) {\n+ editList[rowIndex] = { ...row };\n+ delete editList[rowIndex]._XID;\n+ console.log(editList[rowIndex]);\n+ }\n+ editList[rowIndex][column.title] = event.target.textContent;\n+ this.$emit(\"sendToVscode\", \"dataModify\");\n+ this.$emit(\"update:editList\", editList);\n+ },\n+ filter(event, column, operation) {\n+ if (!operation) operation = \"=\";\n+ let inputvalue = \"\" + (event ? event.target.value : \"\");\n+ if (this.result.dbType == \"ElasticSearch\") {\n+ this.$emit(\"sendToVscode\", \"esFilter\", {\n+ match: { [column]: inputvalue },\n+ });\n+ return;\n+ }\n+\n+ let filterSql =\n+ this.result.sql.replace(/\\n/, \" \").replace(\";\", \" \") + \" \";\n+\n+ let existsCheck = new RegExp(\n+ `(WHERE|AND)?\\\\s*\\`?${column}\\`?\\\\s*(=|is|>=|<=|<>)\\\\s*.+?\\\\s`,\n+ \"igm\"\n+ );\n+\n+ if (inputvalue) {\n+ const condition =\n+ inputvalue.toLowerCase() === \"null\"\n+ ? `${column} is null`\n+ : `${wrapByDb(\n+ column,\n+ this.result.dbType\n+ )} ${operation} '${inputvalue}'`;\n+ if (existsCheck.exec(filterSql)) {\n+ // condition present\n+ filterSql = filterSql.replace(existsCheck, `$1 ${condition} `);\n+ } else if (filterSql.match(/\\bwhere\\b/gi)) {\n+ //have where\n+ filterSql = filterSql.replace(\n+ /\\b(where)\\b/gi,\n+ `\\$1 ${condition} AND `\n+ );\n+ } else {\n+ //have not where\n+ filterSql = filterSql.replace(\n+ new RegExp(`(from\\\\s*.+?)\\\\s`, \"ig\"),\n+ `\\$1 WHERE ${condition} `\n+ );\n+ }\n+ } else {\n+ // empty value, clear filter\n+ let beforeAndCheck = new RegExp(\n+ `\\\\b${column}\\\\b\\\\s*(=|is)\\\\s*.+?\\\\s*AND`,\n+ \"igm\"\n+ );\n+ if (beforeAndCheck.exec(filterSql)) {\n+ filterSql = filterSql.replace(beforeAndCheck, \"\");\n+ } else {\n+ filterSql = filterSql.replace(existsCheck, \" \");\n+ }\n+ }\n+ this.$emit(\"execute\", filterSql + \";\");\n+ },\n+ onContextmenu(event, scope) {\n+ const { row, column } = scope;\n+ const name = column.title;\n+ const value = event.target.textContent;\n+ event.target.value = value;\n+ this.$contextmenu({\n+ items: [\n+ {\n+ label: `Copy`,\n+ onClick: () => {\n+ this.$emit(\"sendToVscode\", \"copy\", value);\n+ },\n+ divided: true,\n+ },\n+ {\n+ label: `Open Edit Dialog`,\n+ onClick: () => {\n+ this.$emit(\"openEditor\", row, false);\n+ },\n+ },\n+ {\n+ label: `Open Copy Dialog`,\n+ onClick: () => {\n+ this.$emit(\"openEditor\", row, true);\n+ },\n+ divided: true,\n+ },\n+ {\n+ label: `Filter by ${name} = '${value}'`,\n+ onClick: () => {\n+ this.filter(event, name, \"=\");\n+ },\n+ },\n+ {\n+ label: \"Filter by\",\n+ divided: true,\n+ children: [\n+ {\n+ label: `Filter by ${name} > '${value}'`,\n+ onClick: () => {\n+ this.filter(event, name, \">\");\n+ },\n+ },\n+ {\n+ label: `Filter by ${name} >= '${value}'`,\n+ onClick: () => {\n+ this.filter(event, name, \">=\");\n+ },\n+ divided: true,\n+ },\n+ {\n+ label: `Filter by ${name} < '${value}'`,\n+ onClick: () => {\n+ this.filter(event, name, \"<\");\n+ },\n+ },\n+ {\n+ label: `Filter by ${name} <= '${value}'`,\n+ onClick: () => {\n+ this.filter(event, name, \"<=\");\n+ },\n+ divided: true,\n+ },\n+ {\n+ label: `Filter by ${name} LIKE '%${value}%'`,\n+ onClick: () => {\n+ event.target.value = `%${value}%`;\n+ this.filter(event, name, \"LIKE\");\n+ },\n+ },\n+ {\n+ label: `Filter by ${name} NOT LIKE '%${value}%'`,\n+ onClick: () => {\n+ event.target.value = `%${value}%`;\n+ this.filter(event, name, \"NOT LIKE\");\n+ },\n+ },\n+ ],\n+ },\n+ ],\n+ event,\n+ customClass: \"class-a\",\n+ zIndex: 3,\n+ minWidth: 230,\n+ });\n+ return false;\n+ },\n+ },\n+ computed: {\n+ editable() {\n+ return this.result.primaryKey && this.result.tableCount == 1;\n+ },\n+ },\n+};\n+</script>\n+\n+<style>\n+</style>\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Extra row component from result view.
|
141,908
|
24.05.2021 15:51:54
| -28,800
|
8a2ee73030b2241bab6b38c2471ffc5621464d80
|
Detech by path.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/sqlite/sqliteCommandValidation.ts",
"new_path": "src/service/connect/sqlite/sqliteCommandValidation.ts",
"diff": "@@ -2,6 +2,7 @@ import { Global } from '@/common/global';\nimport { spawnSync } from 'child_process';\nimport { existsSync } from 'fs';\nimport { arch, platform } from 'os';\n+var commandExistsSync = require('command-exists').sync;\n/**\n* Validate the sqlite3 command/path passed as argument, if not valid fallback to the binary in the bin directory.\n@@ -11,16 +12,7 @@ export function validateSqliteCommand(sqliteCommand: string): string {\nif (isValid) {\nreturn sqliteCommand;\n} else {\n- sqliteCommand = getSqliteBinariesPath();\n- if (!sqliteCommand) {\n- throw new Error(`Unable to find a valid SQLite command. Fallback binary not found.`);\n- }\n- isValid = isSqliteCommandValid(sqliteCommand);\n- if (isValid) {\n- return sqliteCommand;\n- } else {\n- throw new Error(`Unable to find a valid SQLite command. Fallback binary is not valid.`);\n- }\n+ return getSqliteBinariesPath();\n}\n}\n@@ -68,6 +60,9 @@ export function getSqliteBinariesPath(): string {\nsqliteBin = 'sqlite-v3.26.0-win32-x86.exe';\nbreak;\ncase 'linux':\n+ if (commandExistsSync('sqlite3')) {\n+ return 'sqlite3';\n+ }\nif (os_arch === 'x64') {\nsqliteBin = 'sqlite-v3.26.0-linux-x64';\n} else {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Detech by path.
|
141,908
|
24.05.2021 16:02:56
| -28,800
|
9c9efcc7868d08524c9088dff886c4d3b0e4f184
|
Add name of panel.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"activitybar\": [\n{\n\"id\": \"github-cweijan-mysql\",\n- \"title\": \"Database Explorer\",\n+ \"title\": \"Explorer\",\n\"icon\": \"resources/icon/database-container.svg\"\n},\n{\n\"id\": \"github-cweijan-nosql\",\n- \"title\": \"Other Explorer\",\n+ \"title\": \"Explorer\",\n\"icon\": \"resources/image/other-container.png\"\n}\n]\n\"github-cweijan-mysql\": [\n{\n\"id\": \"github.cweijan.mysql\",\n- \"name\": \"\"\n+ \"name\": \"Database\"\n}\n],\n\"github-cweijan-nosql\": [\n{\n\"id\": \"github.cweijan.nosql\",\n- \"name\": \"\"\n+ \"name\": \"NoSQL\"\n}\n]\n},\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add name of panel.
|
141,908
|
24.05.2021 16:26:01
| -28,800
|
26f2cb59633bb743c1f71c792e9b2e18514f9907
|
Version 3.8.5.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.4\",\n+ \"version\": \"3.8.5\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.5.
|
141,908
|
25.05.2021 10:24:18
| -28,800
|
206b13c6bc8b36212aa4866b29e2528416a9dd26
|
Redis connection support ssl
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/redisConnection.ts",
"new_path": "src/service/connect/redisConnection.ts",
"diff": "import { Node } from \"@/model/interface/node\";\nimport { IConnection, queryCallback } from \"./connection\";\n-\n+import * as fs from \"fs\";\nimport * as IoRedis from \"ioredis\";\nexport class RedisConnection extends IConnection {\nprivate conneted: boolean;\nprivate client: IoRedis.Redis;\n- constructor(opt: Node) {\n+ constructor(node: Node) {\nsuper()\n- this.client = new IoRedis({\n- port: opt.port,\n- host: opt.host,\n- password: opt.password,\n- connectTimeout: opt.connectTimeout || 5000,\n- db: opt.database as any as number,\n- family: 4, // 4 (IPv4) or 6 (IPv6)\n- });\n+ let config = {\n+ port: node.port,\n+ host: node.host,\n+ password: node.password,\n+ connectTimeout: node.connectTimeout || 5000,\n+ db: node.database as any as number,\n+ family: 4,\n+ }as IoRedis.RedisOptions;\n+ if(node.useSSL){\n+ config.tls={\n+ rejectUnauthorized: false,\n+ cert: ( node.clientCertPath) ? fs.readFileSync(node.clientCertPath) : null,\n+ key: ( node.clientKeyPath) ? fs.readFileSync(node.clientKeyPath) : null,\n+ minVersion: 'TLSv1'\n+ }\n+ }\n+ this.client = new IoRedis(config);\n}\n@@ -39,11 +48,11 @@ export class RedisConnection extends IConnection {\ncallback(new Error(\"Connect to redis server time out.\"))\n}\n}, 5000);\n- this.client.ping(() => {\n+ this.client.ping((err) => {\nif (timeout) {\nthis.conneted = true;\ntimeout = false;\n- callback(null)\n+ callback(err)\n}\n})\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/connect/index.vue",
"new_path": "src/vue/connect/index.vue",
"diff": "<el-switch v-model=\"connectionOption.usingSSH\"></el-switch>\n</div>\n<div class=\"inline-block mr-10\"\n- v-if=\"connectionOption.dbType=='MySQL' || connectionOption.dbType=='PostgreSQL' || connectionOption.dbType=='MongoDB'\">\n+ v-if=\"connectionOption.dbType=='MySQL' || connectionOption.dbType=='PostgreSQL' || connectionOption.dbType=='MongoDB' || connectionOption.dbType=='Redis' \">\n<label class=\"font-bold mr-5 inline-block w-18\">Use SSL</label>\n<el-switch v-model=\"connectionOption.useSSL\"></el-switch>\n</div>\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Redis connection support ssl
|
141,908
|
03.06.2021 14:13:06
| -28,800
|
1c2823bf4e3faa12b3c87524bc0c13214d18d7c2
|
Fix parse empty string or zero to null.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/Row/index.vue",
"new_path": "src/vue/result/component/Row/index.vue",
"diff": "</template>\n<template v-else>\n<div class=\"edit-column\" :contenteditable=\"editable\" style=\"height: 100%; line-height: 33px;\" @input=\"editListen($event,scope)\" @contextmenu.prevent=\"onContextmenu($event,scope)\">\n- <template v-if=\"scope.row[scope.column.title]\">\n- <span v-text='dataformat(scope.row[scope.column.title])'></span>\n+ <template v-if=\"scope.row[scope.column.title]==null || scope.row[scope.column.title]==undefined\">\n+ <span class='null-column'>(NULL)</span>\n</template>\n<template v-else>\n- <span class='null-column'>(NULL)</span>\n+ <span v-text='dataformat(scope.row[scope.column.title])'></span>\n</template>\n</div>\n</template>\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix parse empty string or zero to null.
|
141,908
|
03.06.2021 14:14:57
| -28,800
|
90f1bf4ea0eeaf0be5f3e5af30d8cdd3592ad604
|
Version 3.8.6.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.8.6 2021-6-3\n+\n+- Support connect redis with ssl.\n+- Fix parse empty string or zero as null on result.\n+\n# 3.8.3 2021-5-18\n- Support connect to MongoDB.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.5\",\n+ \"version\": \"3.8.6\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.6.
|
141,908
|
03.06.2021 20:43:51
| -28,800
|
b5b3c3f69c3f006369c623ba0b5560caeda86da8
|
Fix drop trigger error template.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/dialect/sqlDialect.ts",
"new_path": "src/service/dialect/sqlDialect.ts",
"diff": "@@ -50,7 +50,7 @@ export abstract class SqlDialect {\nreturn null;\n}\ndropTriggerTemplate(name: string): string {\n- return `DROP IF EXISTS TRIGGER ${name}`\n+ return `DROP TRIGGER IF EXISTS ${name}`\n}\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix drop trigger error template.
|
141,908
|
08.06.2021 09:07:42
| -28,800
|
e2fb414d039d511bad3c1e16607e2d231e49456e
|
Prefer sqlite3 command in path.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/sqlite/sqliteCommandValidation.ts",
"new_path": "src/service/connect/sqlite/sqliteCommandValidation.ts",
"diff": "@@ -50,6 +50,11 @@ export function isSqliteCommandValid(sqliteCommand: string) {\n* If there are no binaries for the platform returns an empty string.\n*/\nexport function getSqliteBinariesPath(): string {\n+\n+ if (commandExistsSync('sqlite3')) {\n+ return 'sqlite3';\n+ }\n+\nlet plat = platform();\nlet os_arch = arch();\nlet sqliteBin: string;\n@@ -60,9 +65,6 @@ export function getSqliteBinariesPath(): string {\nsqliteBin = 'sqlite-v3.26.0-win32-x86.exe';\nbreak;\ncase 'linux':\n- if (commandExistsSync('sqlite3')) {\n- return 'sqlite3';\n- }\nif (os_arch === 'x64') {\nsqliteBin = 'sqlite-v3.26.0-linux-x64';\n} else {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Prefer sqlite3 command in path.
|
141,908
|
08.06.2021 10:43:26
| -28,800
|
0a386f38077597cb29dabaa16813076affaacd10
|
Update toolbar.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/result/query.ts",
"new_path": "src/service/result/query.ts",
"diff": "@@ -76,6 +76,8 @@ export class QueryPage {\n})\n}).on('changePageSize', (pageSize) => {\nGlobal.updateConfig(ConfigKey.DEFAULT_LIMIT, pageSize)\n+ }).on('openGithub', () => {\n+ env.openExternal(Uri.parse('https://github.com/cweijan/vscode-database-client'));\n}).on('openCoffee', () => {\nenv.openExternal(Uri.parse('https://www.buymeacoffee.com/cweijan'));\n}).on('dataModify', () => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "<el-input type=\"textarea\" :autosize=\"{ minRows:2, maxRows:5}\" v-model=\"toolbar.sql\" class=\"sql-pannel\" />\n</div>\n<div class=\"toolbar\">\n- <el-button v-if=\"showFullBtn\" @click=\"()=>sendToVscode('full')\" type=\"primary\" title=\"Full Result View\" icon=\"el-icon-rank\" size=\"mini\" circle>\n- </el-button>\n- <el-input v-model=\"table.search\" size=\"mini\" placeholder=\"Input To Search Data\" style=\"width:200px\" :clearable=\"true\" />\n- <el-button type=\"primary\" size=\"mini\" icon=\"el-icon-milk-tea\" title=\"Buy the author a cup of coffee\" circle @click=\"()=>sendToVscode('openCoffee')\"></el-button>\n- <el-button @click=\"$refs.editor.openInsert()\" :disabled=\"result.tableCount!=1\" type=\"info\" title=\"Insert new row\" icon=\"el-icon-circle-plus-outline\" size=\"mini\" circle>\n- </el-button>\n- <el-button @click=\"deleteConfirm\" title=\"delete\" type=\"danger\" size=\"mini\" icon=\"el-icon-delete\" circle :disabled=\"!toolbar.show\">\n- </el-button>\n- <el-button @click=\"exportOption.visible = true\" type=\"primary\" size=\"mini\" icon=\"el-icon-bottom\" circle title=\"Export\"></el-button>\n- <el-button type=\"success\" size=\"mini\" icon=\"el-icon-caret-right\" :disabled=\"!toolbar.sql\" title=\"Execute Sql\" circle @click='info.visible = false;execute(toolbar.sql);'></el-button>\n- <div style=\"display:inline-block;font-size:14px;padding-left: 8px;\" class=\"el-pagination__total\">\n- CostTime: {{result.costTime}}ms\n- </div>\n+ <Toolbar :showFullBtn=\"showFullBtn\" :search.sync=\"table.search\" :costTime=\"result.costTime\" @sendToVscode=\"sendToVscode\" @export=\"exportOption.visible = true\" @insert=\"$refs.editor.openInsert()\" @deleteConfirm=\"deleteConfirm\" @run=\"info.visible = false;execute(toolbar.sql);\" />\n<div style=\"display:inline-block\">\n<el-pagination @size-change=\"changePageSize\" @current-change=\"page=>changePage(page,true)\" @next-click=\"()=>changePage(1)\" @prev-click=\"()=>changePage(-1)\" :current-page.sync=\"page.pageNum\" :small=\"true\" :page-size=\"page.pageSize\" :page-sizes=\"[100,30,50,300,500]\" :layout=\"page.total!=null?'sizes,prev,pager, next, total':'sizes,prev, next'\" :total=\"page.total\">\n</el-pagination>\n<Row slot-scope=\"scope\" :scope=\"scope\" :result=\"result\" :filterObj=\"toolbar.filter\" :editList.sync=\"update.editList\" @execute=\"execute\" @sendToVscode=\"sendToVscode\" @openEditor=\"openEditor\" />\n</ux-table-column>\n</ux-grid>\n- <EditDialog ref=\"editor\" :dbType=\"result.dbType\" :database=\"result.database\" :table=\"result.table\" :primaryKey=\"result.primaryKey\" :primaryKeyList=\"result.primaryKeyList\" :columnList=\"result.columnList\" @execute=\"execute\" />\n+ <EditDialog ref=\"editor\" :dbType=\"result.dbType\" :result=\"result\" :database=\"result.database\" :table=\"result.table\" :primaryKey=\"result.primaryKey\" :primaryKeyList=\"result.primaryKeyList\" :columnList=\"result.columnList\" @execute=\"execute\" />\n<ExportDialog :visible.sync=\"exportOption.visible\" @exportHandle=\"confirmExport\" />\n</div>\n</template>\n@@ -50,6 +38,7 @@ import Row from \"./component/Row\";\nimport Controller from \"./component/Row/Controller.vue\";\nimport Header from \"./component/Row/Header.vue\";\nimport ExportDialog from \"./component/ExportDialog.vue\";\n+import Toolbar from \"./component/Toolbar\";\nimport EditDialog from \"./component/EditDialog\";\nimport { util } from \"./mixin/util\";\nlet vscodeEvent;\n@@ -59,6 +48,7 @@ export default {\ncomponents: {\nExportDialog,\nEditDialog,\n+ Toolbar,\nController,\nRow,\nHeader,\n@@ -301,14 +291,21 @@ export default {\n}\n},\ndeleteConfirm() {\n+ const datas = this.$refs.dataTable.getCheckboxRecords();\n+ if (!datas || datas.length == 0) {\n+ this.$message({\n+ type: \"warning\",\n+ message: \"You need to select at least one row of data.\",\n+ });\n+ return;\n+ }\nthis.$confirm(\"Are you sure you want to delete this data?\", \"Warning\", {\nconfirmButtonText: \"OK\",\ncancelButtonText: \"Cancel\",\ntype: \"warning\",\n})\n.then(() => {\n- let checkboxRecords = this.$refs.dataTable\n- .getCheckboxRecords()\n+ let checkboxRecords = datas\n.filter(\n(checkboxRecord) => checkboxRecord[this.result.primaryKey] != null\n)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/EditDialog/index.vue",
"new_path": "src/vue/result/component/EditDialog/index.vue",
"diff": "@@ -31,7 +31,7 @@ import { wrapByDb } from \"@/common/wrapper\";\nexport default {\nmixins: [util],\ncomponents: { CellEditor },\n- props: [\"dbType\",\"database\", \"table\", \"primaryKey\",\"primaryKeyList\", \"columnList\"],\n+ props: [\"result\",\"dbType\",\"database\", \"table\", \"primaryKey\",\"primaryKeyList\", \"columnList\"],\ndata() {\nreturn {\nmodel: \"insert\",\n@@ -66,6 +66,13 @@ export default {\nthis.visible = true;\n},\nopenInsert() {\n+ if(this.result.tableCount!=1){\n+ this.$message({\n+ type: \"warning\",\n+ message: \"Only one table support insert!\",\n+ });\n+ return;\n+ }\nthis.model = \"insert\";\nthis.editModel = {};\nthis.loading = false;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/vue/result/icon/iconfont.css",
"diff": "+@font-face {\n+ font-family: \"iconfont\"; /* Project id 2598912 */\n+ src: url('iconfont.woff?t=1623116621438') format('woff');\n+}\n+\n+[class*=\" icon-\"], [class^=icon-] {\n+ font-family: \"iconfont\" !important;\n+ speak: none;\n+ font-style: normal;\n+ font-weight: 400;\n+ font-variant: normal;\n+ text-transform: none;\n+ line-height: 1;\n+ vertical-align: baseline;\n+ display: inline-block;\n+ -webkit-font-smoothing: antialiased;\n+ -moz-osx-font-smoothing: grayscale\n+}\n+\n+.icon-github:before {\n+ content: \"\\e601\";\n+}\n+\n"
},
{
"change_type": "ADD",
"old_path": "src/vue/result/icon/iconfont.woff",
"new_path": "src/vue/result/icon/iconfont.woff",
"diff": "Binary files /dev/null and b/src/vue/result/icon/iconfont.woff differ\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/main.js",
"new_path": "src/vue/result/main.js",
"diff": "@@ -10,6 +10,7 @@ import 'umy-table/lib/theme-chalk/index.css';\nimport '@/../public/theme/auto.css'\nimport '@/../public/theme/umyui.css'\nimport './view.css'\n+import './icon/iconfont.css'\nVue.use(UmyTable);\nVue.config.productionTip = false\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Update toolbar.
|
141,908
|
08.06.2021 11:53:16
| -28,800
|
8e9998143b450441ad5c1e4cf9cc13d9f498d288
|
Update toolbar style again.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/Toolbar/index.vue",
"new_path": "src/vue/result/component/Toolbar/index.vue",
"diff": "@@ -58,10 +58,28 @@ export default {\nmargin-left: 7px;\n}\n-.el-button:focus, .el-button:hover {\n- color: #409EFF !important;\n+.el-button:focus,\n+.el-button:hover {\n+ color: #409eff !important;\nborder-color: #c6e2ff;\nbackground-color: var(--vscode-editor-background);\n}\n+.el-pagination {\n+ padding: 0;\n+}\n+>>> .el-input{\n+ bottom: 2px;\n+}\n+>>> .el-input--mini .el-input__inner{\n+ height: 24px;\n+}\n+\n+</style>\n+\n+<style>\n+.el-pagination span,.el-pagination li,\n+.btn-prev i,.btn-next i{\n+ line-height: 27px !important;\n+}\n</style>\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Update toolbar style again.
|
141,908
|
08.06.2021 11:56:56
| -28,800
|
cdacf38efc780ecdee2760f9da5fa28275a5b360
|
Version 3.8.7.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.8.7 2021-6-8\n+\n+- Update toolbar style.\n+- Fix trigger template error.\n+- Support using sqlite3 from path.\n+\n# 3.8.6 2021-6-3\n- Support connect redis with ssl.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.6\",\n+ \"version\": \"3.8.7\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.7.
|
141,908
|
10.06.2021 08:59:27
| -28,800
|
75f1e023ee734ee63ef3278d38c0a654eb9c4947
|
Change focus color.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/Toolbar/index.vue",
"new_path": "src/vue/result/component/Toolbar/index.vue",
"diff": "@@ -58,7 +58,11 @@ export default {\nmargin-left: 7px;\n}\n-.el-button:focus,\n+.el-button:focus{\n+ color: inherit !important;\n+ background-color: var(--vscode-editor-background);\n+}\n+\n.el-button:hover {\ncolor: #409eff !important;\nborder-color: #c6e2ff;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Change focus color.
|
141,908
|
10.06.2021 09:01:18
| -28,800
|
b23210dd351aa3c5696c003ad0c5a738116bba18
|
Update height.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "@@ -99,10 +99,10 @@ export default {\n};\n},\nmounted() {\n- this.remainHeight = window.innerHeight - 120;\n+ this.remainHeight = window.innerHeight - 90;\nthis.showFullBtn = window.outerWidth / window.innerWidth >= 2;\nwindow.addEventListener(\"resize\", () => {\n- this.remainHeight = window.innerHeight - 120;\n+ this.remainHeight = window.innerHeight - 90;\nthis.showFullBtn = window.outerWidth / window.innerWidth >= 2;\n});\nconst handlerData = (data, sameTable) => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Update height.
|
141,908
|
11.06.2021 21:26:52
| -28,800
|
30a1b6f93965dd14c0a4d122db1c975ca0569c7f
|
Fix export occur undefined
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/export/exportService.ts",
"new_path": "src/service/export/exportService.ts",
"diff": "@@ -97,7 +97,7 @@ export class ExportService {\nlet values = \"\";\nfor (const key in row) {\ncolumns += `${key},`\n- values += `'${row[key]}',`\n+ values += `${row[key]!=null?`'${row[key]}'`:'null'},`\n}\nsql += `insert into ${exportContext.table}(${columns.replace(/.$/, '')}) values(${values.replace(/.$/, '')});\\n`\n}\n@@ -127,7 +127,7 @@ export class ExportService {\nlet csvContent = \"\";\nfor (const row of rows) {\nfor (const key in row) {\n- csvContent += `${row[key]},`\n+ csvContent += `${row[key]!=null?row[key]:''},`\n}\ncsvContent = csvContent.replace(/.$/, \"\") + \"\\n\"\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix export occur undefined #218.
|
141,908
|
11.06.2021 21:32:36
| -28,800
|
cf64823b3069534766ad2471306ecb326a92740a
|
Postgresql query with quote
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/wrapper.js",
"new_path": "src/common/wrapper.js",
"diff": "*/\nexport function wrapByDb(origin, databaseType) {\nif (origin == null) { return origin; }\n+ if (databaseType == 'PostgreSQL') {\n+ return origin.split(\".\").map(text => `\"${text}\"`).join(\".\")\n+ }\nif (origin.match(/\\b[-\\s]+\\b/ig) || origin.match(/^( |if|key|desc|length)$/i)) {\nif (databaseType == 'SqlServer') {\nreturn origin.split(\".\").map(text => `[${text}]`).join(\".\")\n}\n- if (databaseType == 'PostgreSQL') {\n- return origin.split(\".\").map(text => `\"${text}\"`).join(\".\")\n- }\nif (databaseType == 'MongoDB') {\nreturn origin;\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Postgresql query with quote #217.
|
141,908
|
11.06.2021 21:51:20
| -28,800
|
dddf325235ca5f6a643af328d2e5716358027a2b
|
Remove legacy config.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"type\": \"object\",\n\"title\": \"%config.title%\",\n\"properties\": {\n- \"database-client.enableDelimiter\": {\n- \"type\": \"boolean\",\n- \"default\": false,\n- \"description\": \"%config.enableDelimiter%\"\n- },\n\"database-client.defaultSelectLimit\": {\n\"type\": \"integer\",\n\"default\": 100,\n\"description\": \"%config.defaultSelectLimit%\"\n},\n- \"database-client.showTotal\": {\n- \"type\": \"boolean\",\n- \"default\": true,\n- \"description\": \"%config.showTotal%\"\n- },\n\"database-client.disableSqlCodeLen\": {\n\"type\": \"boolean\",\n\"default\": false,\n"
},
{
"change_type": "MODIFY",
"old_path": "package.nls.json",
"new_path": "package.nls.json",
"diff": "\"command.redis.key.del\": \"Delete Key\",\n\"command.redis.key.detail\": \"View Key Detail\",\n\"config.title\":\"Database Client\",\n- \"config.enableDelimiter\":\"Support delimiter when import sql.\",\n- \"config.defaultSelectLimit\":\"Default limit of query sql.\",\n- \"config.showTotal\": \"Show total on result view.\"\n+ \"config.defaultSelectLimit\":\"Default limit of query sql.\"\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -22,10 +22,8 @@ export enum CacheKey {\n}\nexport enum ConfigKey {\n- ENABLE_DELIMITER = \"enableDelimiter\",\nDEFAULT_LIMIT = \"defaultSelectLimit\",\nDISABLE_SQL_CODELEN = \"disableSqlCodeLen\",\n- SHOW_TOTAL = \"showTotal\",\n}\nexport enum CodeCommand {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/import/importService.ts",
"new_path": "src/service/import/importService.ts",
"diff": "@@ -2,13 +2,16 @@ import { Util } from \"@/common/util\";\nimport { readFileSync } from \"fs\";\nimport { window } from \"vscode\";\nimport { Node } from \"../../model/interface/node\";\n+import { DelimiterHolder } from \"../common/delimiterHolder\";\nimport { ConnectionManager } from \"../connectionManager\";\nexport abstract class ImportService {\npublic importSql(importPath: string, node: Node): void {\n- const sql=readFileSync(importPath,'utf8')\n+ let sql = readFileSync(importPath, 'utf8')\n+ const parseResult = DelimiterHolder.parseBatch(sql, node.getConnectId())\n+ sql = parseResult.sql\nUtil.process(`Importing sql file ${importPath}`, async done => {\ntry {\nconst importSessionId = `import_${new Date().getTime()}`;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Remove legacy config.
|
141,908
|
11.06.2021 21:59:32
| -28,800
|
f94564d687a296902e236b20d73791c43e5bc722
|
Prefre using connection name
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"default\": 100,\n\"description\": \"%config.defaultSelectLimit%\"\n},\n+ \"database-client.prefreConnectionName\": {\n+ \"type\": \"boolean\",\n+ \"default\": true,\n+ \"description\": \"%config.prefreConnectionName%\"\n+ },\n\"database-client.disableSqlCodeLen\": {\n\"type\": \"boolean\",\n\"default\": false,\n"
},
{
"change_type": "MODIFY",
"old_path": "package.nls.json",
"new_path": "package.nls.json",
"diff": "\"command.redis.key.del\": \"Delete Key\",\n\"command.redis.key.detail\": \"View Key Detail\",\n\"config.title\":\"Database Client\",\n+ \"config.prefreConnectionName\":\"Using connection name as connection node name\",\n\"config.defaultSelectLimit\":\"Default limit of query sql.\"\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -23,6 +23,7 @@ export enum CacheKey {\nexport enum ConfigKey {\nDEFAULT_LIMIT = \"defaultSelectLimit\",\n+ PREFRE_CONNECTION_NAME = \"prefreConnectionName\",\nDISABLE_SQL_CODELEN = \"disableSqlCodeLen\",\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/global.ts",
"new_path": "src/common/global.ts",
"diff": "@@ -32,8 +32,8 @@ export class Global {\n* get configuration from vscode setting.\n* @param key config key\n*/\n- public static getConfig<T>(key: string): T {\n- return vscode.workspace.getConfiguration(Constants.CONFIG_PREFIX).get<T>(key);\n+ public static getConfig<T>(key: string,defaultValue?:any): T {\n+ return vscode.workspace.getConfiguration(Constants.CONFIG_PREFIX).get<T>(key,defaultValue);\n}\n/**\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/connectionNode.ts",
"new_path": "src/model/database/connectionNode.ts",
"diff": "@@ -2,7 +2,7 @@ import { Console } from \"@/common/Console\";\nimport { Global } from \"@/common/global\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n-import { Constants, DatabaseType, ModelType } from \"../../common/constants\";\n+import { ConfigKey, Constants, DatabaseType, ModelType } from \"../../common/constants\";\nimport { FileManager } from \"../../common/filesManager\";\nimport { Util } from \"../../common/util\";\nimport { DbTreeDataProvider } from \"../../provider/treeDataProvider\";\n@@ -32,8 +32,9 @@ export class ConnectionNode extends Node implements CopyAble {\n}\nthis.cacheSelf()\nif (parent.name) {\n- this.description = parent.name\nthis.name = parent.name\n+ const prefreName = Global.getConfig(ConfigKey.PREFRE_CONNECTION_NAME, true)\n+ prefreName ? this.label = parent.name : this.description = parent.name;\n}\n// https://www.iloveimg.com/zh-cn/resize-image/resize-svg\nif (this.dbType == DatabaseType.PG) {\n@@ -52,7 +53,7 @@ export class ConnectionNode extends Node implements CopyAble {\n}\nconst lcp = ConnectionManager.activeNode;\nif (lcp && lcp.getConnectId().includes(this.getConnectId())) {\n- this.description = `${parent.name ? parent.name + \" \" : \"\"}Active`\n+ this.description = (this.description || '') + \" Active\"\n}\ntry {\nthis.getChildren()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -27,6 +27,10 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\nreturn element;\n}\n+ public getParent(element?: Node) {\n+ return element?.parent;\n+ }\n+\npublic async getChildren(element?: Node): Promise<Node[]> {\nreturn new Promise(async (res, rej) => {\nif (!element) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Prefre using connection name #215.
|
141,908
|
11.06.2021 22:12:53
| -28,800
|
5b149924019cd69f83378027b9d412ba0bdff22e
|
Don't use utc of mssql
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mssqlConnection.ts",
"new_path": "src/service/connect/mssqlConnection.ts",
"diff": "@@ -19,6 +19,7 @@ export class MSSqlConnnection extends ConnectionPool<Connection>{\noptions: {\nport: node.instanceName?undefined:parseInt(node.port as any),\ninstanceName: node.instanceName,\n+ useUTC: false,\ntrustServerCertificate: true,\ndatabase: node.database || undefined,\nconnectTimeout: node.connectTimeout ? parseInt(node.connectTimeout as any) : 5000,\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Don't use utc of mssql #199.
|
141,908
|
11.06.2021 22:16:06
| -28,800
|
1438e481f1c25f77cc8a6875625947bc594947ad
|
Version 3.8.8.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.8.8 2021-6-11\n+\n+- Fix date incorrect of sqlserver #199.\n+- Prefre using connection name #215.\n+- Postgresql query with quote #217.\n+- Fix export occur undefined #218.\n+\n# 3.8.7 2021-6-8\n- Update toolbar style.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.7\",\n+ \"version\": \"3.8.8\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.8.
|
141,908
|
12.06.2021 02:44:06
| -28,800
|
92390596975e65e4a2c4826f7f28e3e096738910
|
Init document generate.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"title\": \"%command.struct.export%\",\n\"category\": \"MySQL\"\n},\n+ {\n+ \"command\": \"mysql.document.generate\",\n+ \"title\": \"%command.document.generate%\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.db.active\",\n\"title\": \"%command.db.active%\",\n\"when\": \"view =~ /cweijan.+?ql/ && viewItem == database\",\n\"group\": \"mysql@6\"\n},\n+ {\n+ \"command\": \"mysql.document.generate\",\n+ \"when\": \"view =~ /cweijan.+?ql/ && viewItem == database\",\n+ \"group\": \"mysql@7\"\n+ },\n{\n\"command\": \"mysql.data.import\",\n\"when\": \"view =~ /cweijan.+?ql/ && viewItem == database\",\n- \"group\": \"mysql@6\"\n+ \"group\": \"mysql@8\"\n},\n{\n\"command\": \"mysql.table.show\",\n\"lodash.defaults\": \"^4.1.0\",\n\"mongodb\": \"^3.6.3\",\n\"mysql2\": \"^2.2.5\",\n+ \"officegen\": \"^0.6.5\",\n\"pg\": \"^8.5.1\",\n\"portfinder\": \"^1.0.26\",\n\"pretty-bytes\": \"^5.3.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.nls.json",
"new_path": "package.nls.json",
"diff": "\"command.query.switch\": \"Open Query\",\n\"command.data.import\": \"Import Sql\",\n\"command.data.export\": \"Export Data\",\n+ \"command.document.generate\": \"Generate Document\",\n\"command.struct.export\": \"Export Struct\",\n\"command.db.active\": \"Change Active Database\",\n\"command.table.truncate\": \"Truncate Table\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -116,6 +116,9 @@ export function activate(context: vscode.ExtensionContext) {\n\"mysql.struct.export\": (node: SchemaNode | TableNode) => {\nserviceManager.dumpService.dump(node, false)\n},\n+ \"mysql.document.generate\": (node: SchemaNode | TableNode) => {\n+ serviceManager.dumpService.generateDocument(node)\n+ },\n\"mysql.data.import\": (node: SchemaNode | ConnectionNode) => {\nvscode.window.showOpenDialog({ filters: { Sql: ['sql'] }, canSelectMany: false, openLabel: \"Select sql file to import\", canSelectFiles: true, canSelectFolders: false }).then((filePath) => {\nif (filePath) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/dump/dumpService.ts",
"new_path": "src/service/dump/dumpService.ts",
"diff": "@@ -13,6 +13,9 @@ import { Util } from \"@/common/util\";\nimport mysqldump, { Options } from './mysql/main';\nimport { Global } from \"@/common/global\";\nimport { SchemaNode } from \"@/model/database/schemaNode\";\n+import { DumpDocument as GenerateDocument } from \"./generateDocument\";\n+import { createWriteStream } from \"fs\";\n+import { ColumnNode } from \"@/model/other/columnNode\";\nexport class DumpService {\n@@ -85,5 +88,67 @@ export class DumpService {\n}\n+ public async generateDocument(node: Node) {\n+\n+ const exportSqlName = `${format('yyyy-MM-dd_hhmmss', new Date())}_${node.schema}.docx`;\n+\n+ vscode.window.showSaveDialog({ saveLabel: \"Select export file path\", defaultUri: vscode.Uri.file(exportSqlName), filters: { 'docx': ['docx'] } }).then(async (generatePath) => {\n+ if (generatePath) {\n+ const nodes = await new TableGroup(node).getChildren();\n+ const officegen = require('officegen')\n+ var docx = officegen('docx')\n+ docx.on('finalize', (written) => {\n+ console.log(\n+ 'Finish to create Word file.\\nTotal bytes created: ' + written + '\\n'\n+ )\n+ })\n+ docx.on('error', (err) => {\n+ console.log(err)\n+ })\n+ let data = []\n+ for (const tableNode of nodes) {\n+ data.push(...[{\n+ type: 'text',\n+ val: tableNode.label\n+ },\n+ {\n+ type: 'table',\n+ val: [\n+ GenerateDocument.header,\n+ ...(await tableNode.getChildren()).map((child: ColumnNode) => {\n+ const column = child.column;\n+ return [\n+ child.label, child.type, child.isPrimaryKey, column.nullable,\n+ column.defaultValue, column.comment\n+ ]\n+ })\n+ ],\n+ opt: GenerateDocument.tableStyle\n+ },\n+ {\n+ type: 'linebreak'\n+ }, {\n+ type: 'linebreak'\n+ }\n+ ])\n+ }\n+ docx.createByJson(data)\n+ var out = createWriteStream(generatePath.fsPath)\n+ out.on('error', function (err) {\n+ console.log(err)\n+ })\n+ out.on(\"close\", () => {\n+ vscode.window.showInformationMessage(`Generate ${node.schema} document success!`, 'open').then(action => {\n+ if (action == 'open') {\n+ vscode.commands.executeCommand('vscode.open', generatePath);\n+ }\n+ })\n+ })\n+ docx.generate(out)\n+ }\n+ })\n+\n+ }\n+\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/service/dump/generateDocument.ts",
"diff": "+export class DumpDocument {\n+\n+ public static tableStyle = {\n+ tableColWidth: 4261,\n+ sz: 15,\n+ align: 'center',\n+ // tableSize: 24,\n+ // tableColor: 'ada',\n+ tableAlign: 'left',\n+ tableFontFamily: 'Microsoft YaHei'\n+ }\n+\n+ public static header = [\n+ {\n+ val: 'Column',\n+ opts: {\n+ cellColWidth: 20,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Type',\n+ opts: {\n+ cellColWidth: 20,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Comment',\n+ opts: {\n+ cellColWidth: 20,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Primary Key',\n+ opts: {\n+ cellColWidth: 30,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+\n+ {\n+ val: 'Nullable',\n+ opts: {\n+ cellColWidth: 20,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Default',\n+ opts: {\n+ cellColWidth: 20,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ ];\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "test/word.js",
"diff": "+const officegen = require('officegen')\n+\n+var fs = require('fs')\n+var path = require('path')\n+\n+var docx = officegen('docx')\n+\n+var outDir = path.join(__dirname, './')\n+\n+docx.on('finalize', function (written) {\n+ console.log(\n+ 'Finish to create Word file.\\nTotal bytes created: ' + written + '\\n'\n+ )\n+})\n+\n+docx.on('error', function (err) {\n+ console.log(err)\n+})\n+\n+var table = [\n+ [\n+ {\n+ val: 'Column',\n+ opts: {\n+ cellColWidth: 4261,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Type',\n+ opts: {\n+ cellColWidth: 4261,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Comment',\n+ opts: {\n+ cellColWidth: 4261,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Primary Key',\n+ opts: {\n+ cellColWidth: 4261,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+\n+ {\n+ val: 'Nullable',\n+ opts: {\n+ cellColWidth: 4261,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ {\n+ val: 'Default',\n+ opts: {\n+ cellColWidth: 4261,\n+ align: 'center',\n+ b: true,\n+ sz: 16,\n+ shd: {\n+ themeFillTint: '50'\n+ }\n+ }\n+ },\n+ ],\n+ ['name', 'int', 'true', 'true', '0', 'username'],\n+]\n+\n+var tableStyle = {\n+ tableColWidth: 4261,\n+ sz: 15,\n+ align: 'center',\n+ // tableSize: 24,\n+ // tableColor: 'ada',\n+ tableAlign: 'left',\n+ tableFontFamily: 'Microsoft YaHei'\n+}\n+\n+var data = [\n+ {\n+ type: 'text',\n+ val: 'stock'\n+ },\n+ {\n+ type: 'table',\n+ val: table,\n+ opt: tableStyle\n+ },\n+ {\n+ type: 'linebreak'\n+ }, {\n+ type: 'linebreak'\n+ }\n+]\n+\n+docx.createByJson(data)\n+\n+var out = fs.createWriteStream(path.join(outDir, 'example_json.docx'))\n+\n+out.on('error', function (err) {\n+ console.log(err)\n+})\n+\n+docx.generate(out)\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Init document generate.
|
141,905
|
12.06.2021 21:46:41
| -28,800
|
b6f2fd9b9a8182a5debc189e3c85fe3211a208af
|
fix missing field while value is NULL on json export
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/export/exportService.ts",
"new_path": "src/service/export/exportService.ts",
"diff": "@@ -80,6 +80,10 @@ export class ExportService {\n}\nprivate exportToJson(context: ExportContext) {\n+ for (const row of context.rows)\n+ for (const key in row)\n+ if (row[key] === undefined)\n+ row[key] = null;\nfs.writeFileSync(context.exportPath, JSON.stringify(context.rows, null, 2));\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
fix missing field while value is NULL on json export
|
141,908
|
12.06.2021 23:31:07
| -28,800
|
9cae127de33e6b23f81c7e6838aa1be18fe7b5d2
|
Improve export performance.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/export/exportService.ts",
"new_path": "src/service/export/exportService.ts",
"diff": "@@ -80,11 +80,7 @@ export class ExportService {\n}\nprivate exportToJson(context: ExportContext) {\n- for (const row of context.rows)\n- for (const key in row)\n- if (row[key] === undefined)\n- row[key] = null;\n- fs.writeFileSync(context.exportPath, JSON.stringify(context.rows, null, 2));\n+ fs.writeFileSync(context.exportPath, JSON.stringify(context.rows, (k, v)=> { return v === undefined ? null : v; }, 2));\n}\nprivate exportToSql(exportContext: ExportContext) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Improve export performance.
|
141,908
|
15.06.2021 18:02:57
| -28,800
|
515aefb067fd3390193652b9d767a93036187fdf
|
Mongo support paging.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mongoConnection.ts",
"new_path": "src/service/connect/mongoConnection.ts",
"diff": "@@ -63,8 +63,10 @@ export class MongoConnection extends IConnection {\n} else {\ntry {\nconst result = await eval('this.client.' + sql)\n- if (!result) {\n+ if (result == null) {\ncallback(null)\n+ } else if (Number.isInteger(result)) {\n+ callback(null, result)\n} else if (result.insertedCount != undefined) {\ncallback(null, { affectedRows: result.insertedCount })\n} else if (result.updatedCount != undefined) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/dialect/mongoDialect.ts",
"new_path": "src/service/dialect/mongoDialect.ts",
"diff": "@@ -59,7 +59,7 @@ export class MongoDialect implements SqlDialect{\nthrow new Error(\"Method not implemented.\");\n}\nbuildPageSql(database: string, table: string, pageSize: number): string {\n- return `db('${database}').collection('${table}').find({}).toArray()`;\n+ return `db('${database}').collection('${table}').find({}).limit(${pageSize}).toArray()`;\n}\ncountSql(database: string, table: string): string {\nthrow new Error(\"Method not implemented.\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/result/query.ts",
"new_path": "src/service/result/query.ts",
"diff": "@@ -67,9 +67,16 @@ export class QueryPage {\n}).on('copy', value => {\nUtil.copyToBoard(value)\n}).on('count', async (params) => {\n+ if(dbOption.dbType==DatabaseType.MONGO_DB){\n+ const sql=params.sql.replace(/(.+?find\\(.+?\\)).+/i, '$1').replace(\"find\",\"count\");\n+ dbOption.execute(sql).then((count) => {\n+ handler.emit('COUNT', { data: count })\n+ })\n+ }else{\ndbOption.execute(params.sql.replace(/\\bSELECT\\b.+?\\bFROM\\b/i, 'select count(*) count from')).then((rows) => {\nhandler.emit('COUNT', { data: rows[0].count })\n})\n+ }\n}).on('export', (params) => {\nthis.exportService.export({ ...params.option, request: queryParam.res.request, dbOption }).then(() => {\nhandler.emit('EXPORT_DONE')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "@@ -63,7 +63,6 @@ export default {\ndatabase: null,\ntable: null,\ntableCount: null,\n- pageSize: null,\n},\npage: {\npageNum: 1,\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Mongo support paging.
|
141,908
|
15.06.2021 18:10:49
| -28,800
|
4db0bbcbbc1b540e427df06af9b796bfe3f06a66
|
Add shortcut for execute
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "<div id=\"app\">\n<div class=\"hint\">\n<div style=\"width:95%;\">\n- <el-input type=\"textarea\" :autosize=\"{ minRows:2, maxRows:5}\" v-model=\"toolbar.sql\" class=\"sql-pannel\" />\n+ <el-input type=\"textarea\" :autosize=\"{ minRows:2, maxRows:5}\" v-model=\"toolbar.sql\" class=\"sql-pannel\" @keypress.native=\"panelInput\" />\n</div>\n<Toolbar :page=\"page\" :showFullBtn=\"showFullBtn\" :search.sync=\"table.search\" :costTime=\"result.costTime\" @changePage=\"changePage\" @sendToVscode=\"sendToVscode\" @export=\"exportOption.visible = true\" @insert=\"$refs.editor.openInsert()\" @deleteConfirm=\"deleteConfirm\" @run=\"info.message = false;execute(toolbar.sql);\" />\n<div v-if=\"info.message \">\n@@ -219,6 +219,12 @@ export default {\n});\n},\nmethods: {\n+ panelInput(event){\n+ if(event.code=='Enter' && event.ctrlKey){\n+ this.execute(this.toolbar.sql)\n+ event.stopPropagation()\n+ }\n+ },\nselectable({row}) {\nreturn this.editable && !row.isFilter;\n},\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add shortcut for execute #220.
|
141,908
|
16.06.2021 09:42:28
| -28,800
|
9e9175123c269cf7b6448952c989b27c91e34c2f
|
Fix mssql concat fail.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/dialect/mssqlDIalect.ts",
"new_path": "src/service/dialect/mssqlDIalect.ts",
"diff": "@@ -123,7 +123,7 @@ ALTER TABLE ${table} ALTER COLUMN ${column} ${type} ${defaultDefinition};\nTABLE_NAME 'name',ds.row_count rows\nFROM\nINFORMATION_SCHEMA.TABLES t\n- join sys.dm_db_partition_stats ds on ds.object_id = object_id(concat(t.TABLE_SCHEMA, '.', t.TABLE_NAME))\n+ join sys.dm_db_partition_stats ds on ds.object_id = object_id(t.TABLE_SCHEMA+ '.'+ t.TABLE_NAME)\nand ds.index_id IN (0, 1)\nWHERE\nTABLE_TYPE = 'BASE TABLE'\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix mssql concat fail.
|
141,908
|
16.06.2021 10:21:07
| -28,800
|
177623731c05e7ea955b23698841b9c613a7e8c7
|
Fix pagination fail.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/component/Toolbar/index.vue",
"new_path": "src/vue/result/component/Toolbar/index.vue",
"diff": "Cost: {{costTime}}ms\n</div>\n<div style=\"display:inline-block\">\n- <el-pagination @size-change=\"changePageSize\" @current-change=\"page=>$emit('changePage',page,true)\" @next-click=\"()=>$emit('changePage',1)\" @prev-click=\"()=>$emit('changePage',-1)\" :current-page.sync=\"page.pageNum\" :small=\"true\" :page-size=\"page.pageSize\" :page-sizes=\"[100,30,50,300,500]\" :layout=\"page.total!=null?'prev,pager, next, total':'sizes,prev, next'\" :total=\"page.total\">\n+ <el-pagination @size-change=\"changePageSize\" @current-change=\"page=>$emit('changePage',page,true)\" @next-click=\"()=>$emit('changePage',1)\" @prev-click=\"()=>$emit('changePage',-1)\" :current-page.sync=\"page.pageNum\" :small=\"true\" :page-size=\"page.pageSize\" :layout=\"page.total!=null?'prev,pager, next, total':'prev, next'\" :total=\"page.total\">\n</el-pagination>\n</div>\n</div>\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix pagination fail.
|
141,908
|
16.06.2021 10:39:05
| -28,800
|
fb5c0d4ccd607c67e587a647d735f8c94acf12a7
|
Mongo support change pagination.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/service/page/mongoPageService.ts",
"diff": "+import { AbstractPageSerivce } from \"./pageService\";\n+\n+export class MongoPageService extends AbstractPageSerivce{\n+ protected buildPageSql(sql: string, start: number, limit: number): string {\n+ if (sql.match(/\\.skip.+?\\)/i)) {\n+ return sql.replace(/\\.skip.+?\\)/i, `.skip(${start})`)\n+ }\n+ return sql.replace(/(\\.find.+?\\))/,`$1.skip(${start})`);\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "@@ -35,6 +35,7 @@ import { MysqlSettingService } from \"./setting/MysqlSettingService\";\nimport { SettingService } from \"./setting/settingService\";\nimport ConnectionProvider from \"@/model/ssh/connectionProvider\";\nimport { SqliTeDialect } from \"./dialect/sqliteDialect\";\n+import { MongoPageService } from \"./page/mongoPageService\";\nexport class ServiceManager {\n@@ -146,6 +147,8 @@ export class ServiceManager {\nreturn new MssqlPageService();\ncase DatabaseType.PG:\nreturn new PostgreSqlPageService();\n+ case DatabaseType.MONGO_DB:\n+ return new MongoPageService();\ncase DatabaseType.ES:\nreturn new EsPageService();\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Mongo support change pagination.
|
141,908
|
16.06.2021 10:47:04
| -28,800
|
78a9d34349496342d9eb50525f37b47981a10b9b
|
Support show empty rows.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/main/tableNode.ts",
"new_path": "src/model/main/tableNode.ts",
"diff": "@@ -22,7 +22,7 @@ export class TableNode extends Node implements CopyAble {\nconstructor(readonly meta: TableMeta, readonly parent: Node) {\nsuper(`${meta.name}`)\nthis.table = meta.name\n- this.description = `${meta.comment || ''} ${(meta.rows && meta.rows != '0') ? `Rows ${meta.rows}` : ''}`\n+ this.description = `${meta.comment || ''} ${(meta.rows!=null) ? `Rows ${meta.rows}` : ''}`\nthis.init(parent)\nthis.tooltip = this.getToolTipe(meta)\nthis.cacheSelf()\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support show empty rows.
|
141,908
|
16.06.2021 10:50:24
| -28,800
|
64478e4ecde3a5c2f60db2745b58be44bec15e1b
|
Remove sqlite binary.
|
[
{
"change_type": "DELETE",
"old_path": "sqlite/sqlite-v3.26.0-linux-x64",
"new_path": "sqlite/sqlite-v3.26.0-linux-x64",
"diff": "Binary files a/sqlite/sqlite-v3.26.0-linux-x64 and /dev/null differ\n"
},
{
"change_type": "DELETE",
"old_path": "sqlite/sqlite-v3.26.0-linux-x86",
"new_path": "sqlite/sqlite-v3.26.0-linux-x86",
"diff": "Binary files a/sqlite/sqlite-v3.26.0-linux-x86 and /dev/null differ\n"
},
{
"change_type": "DELETE",
"old_path": "sqlite/sqlite-v3.26.0-osx-x86",
"new_path": "sqlite/sqlite-v3.26.0-osx-x86",
"diff": "Binary files a/sqlite/sqlite-v3.26.0-osx-x86 and /dev/null differ\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Remove sqlite binary.
|
141,908
|
16.06.2021 10:52:04
| -28,800
|
630228b8148ca92d7b789ae9619565ae915159ad
|
Version 3.8.9.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.8.9 2021-6-16\n+\n+- Add shortcut of run sql on result view(ctrl+enter).\n+- Support generate database document.\n+- Fix bugs.\n+\n# 3.8.8 2021-6-11\n- Fix date incorrect of sqlserver #199.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.8.8\",\n+ \"version\": \"3.8.9\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.8.9.
|
141,908
|
16.06.2021 11:26:06
| -28,800
|
6a4c45c3b9ddf3ed10ca4a2af7b7b247d34140ce
|
Support pagination of input sql.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/page/mongoPageService.ts",
"new_path": "src/service/page/mongoPageService.ts",
"diff": "@@ -8,4 +8,8 @@ export class MongoPageService extends AbstractPageSerivce{\nreturn sql.replace(/(\\.find.+?\\))/,`$1.skip(${start})`);\n}\n+ protected pageMatch() {\n+ return /limit\\((\\d+)\\)/i;\n+ }\n+\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/page/pageService.ts",
"new_path": "src/service/page/pageService.ts",
"diff": "+import { ConfigKey } from \"@/common/constants\";\n+import { Global } from \"@/common/global\";\nexport interface PageService {\n/**\n@@ -9,6 +11,8 @@ export interface PageService {\n*/\nbuild(sql: string, page: number, pageSize: number): string;\n+ getPageSize(sql: string): number;\n+\n}\nexport abstract class AbstractPageSerivce implements PageService {\n@@ -31,6 +35,20 @@ export abstract class AbstractPageSerivce implements PageService {\nreturn this.buildPageSql(sql, start, pageSize)\n}\n+ public getPageSize(sql: string): number {\n+\n+ const limitBlock = sql.match(this.pageMatch())\n+ if (limitBlock) {\n+ return parseInt(limitBlock[1])\n+ }\n+\n+ return Global.getConfig(ConfigKey.DEFAULT_LIMIT);\n+ }\n+\n+ protected pageMatch() {\n+ return /limit\\s*(\\d+)/i;\n+ }\n+\nprotected abstract buildPageSql(sql: string, start: number, limit: number): string;\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/queryUnit.ts",
"new_path": "src/service/queryUnit.ts",
"diff": "@@ -104,7 +104,7 @@ export class QueryUnit {\nconst isSqliteEmptyQuery = fields.length == 0 && sql.match(/\\bselect\\b/i);\nconst isMongoEmptyQuery = fields.length == 0 && sql.match(/\\.collection\\b/i);\nif (isQuery || isSqliteEmptyQuery || isMongoEmptyQuery) {\n- QueryPage.send({ connection: connectionNode, type: MessageType.DATA, queryOption, res: { sql, costTime, data, fields, total, pageSize: Global.getConfig(ConfigKey.DEFAULT_LIMIT) } as DataResponse });\n+ QueryPage.send({ connection: connectionNode, type: MessageType.DATA, queryOption, res: { sql, costTime, data, fields, total} as DataResponse });\nreturn;\n}\n}\n@@ -115,7 +115,7 @@ export class QueryUnit {\nif (data.length > 2 && Util.is(lastEle, 'ResultSetHeader') && Util.is(data[0], 'TextRow')) {\ndata = data[data.length - 2]\nfields = fields[fields.length - 2] as any as FieldInfo[]\n- QueryPage.send({ connection: connectionNode, type: MessageType.DATA, queryOption, res: { sql, costTime, data, fields, total, pageSize: Global.getConfig(ConfigKey.DEFAULT_LIMIT) } as DataResponse });\n+ QueryPage.send({ connection: connectionNode, type: MessageType.DATA, queryOption, res: { sql, costTime, data, fields, total} as DataResponse });\nreturn;\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/result/query.ts",
"new_path": "src/service/result/query.ts",
"diff": "@@ -112,6 +112,7 @@ export class QueryPage {\n} else {\nawait this.loadColumnList(queryParam);\n}\n+ ((queryParam.res)as DataResponse).pageSize=ServiceManager.getPageService(queryParam.connection.dbType).getPageSize(queryParam.res.sql)\nbreak;\ncase MessageType.MESSAGE_BLOCK:\nqueryParam.res.message = `EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}`;\n@@ -191,6 +192,7 @@ export class QueryPage {\nif (fields && fields[0]?.orgTable) {\ntableName = fields[0].orgTable;\ndatabase = fields[0].schema || fields[0].db;\n+ queryParam.res.database = database;\n}else{\ntableName=tableName.replace(/^\"?(.+?)\"?$/,'$1')\n}\n@@ -216,7 +218,6 @@ export class QueryPage {\n}\nqueryParam.res.tableCount = sqlList.length;\nqueryParam.res.table = tableName;\n- queryParam.res.database = database;\n}\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support pagination of input sql.
|
141,908
|
17.06.2021 16:21:43
| -28,800
|
5df2ffa3d926e607836a22837ab063916bfca126
|
Fix terminal occur context menu.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/xterm/index.vue",
"new_path": "src/vue/xterm/index.vue",
"diff": "}\n}))\n- terminal.open(document.getElementById('terminal-container'))\n+ const container=document.getElementById('terminal-container');\n+ terminal.open(container)\nfitAddon.fit()\nterminal.focus()\nterminal.onData((data) => {\n}\n});\n- window.addEventListener(\"contextmenu\", async () => {\n+ container.oncontextmenu=async (event)=>{\n+ event.stopPropagation()\nif (terminal.hasSelection()) {\ndocument.execCommand('copy')\nterminal.clearSelection()\n} else {\nthis.emit('data', await navigator.clipboard.readText())\n}\n- })\n+ }\nconst status = document.getElementById('status')\nthis\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix terminal occur context menu.
|
141,908
|
17.06.2021 16:21:48
| -28,800
|
74918efe1525aea39f8787948a306f70b1c94075
|
Trim warning.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/design/IndexPanel.vue",
"new_path": "src/vue/design/IndexPanel.vue",
"diff": "<el-form :inline='true'>\n<el-form-item label=\"Column\">\n<el-select v-model=\"index.column\">\n- <el-option :label=\"column.name\" :value=\"column.name\" v-for=\"column in designData.columnList\"></el-option>\n+ <el-option :label=\"column.name\" :value=\"column.name\" :key=\"column.name\" v-for=\"column in designData.columnList\"></el-option>\n</el-select>\n</el-form-item>\n<el-form-item label=\"Index Type\">\n"
},
{
"change_type": "MODIFY",
"old_path": "webpack.config.js",
"new_path": "webpack.config.js",
"diff": "@@ -34,7 +34,7 @@ module.exports = [\n}\n},\nplugins: [\n- new webpack.IgnorePlugin(/^(pg-native|supports-color|cardinal|encoding)$/),\n+ new webpack.IgnorePlugin(/^(pg-native|supports-color|cardinal|encoding|aws4)$/),\nnew CopyWebpackPlugin({\npatterns: [{ from: 'src/bin', to: './bin' }]\n}),\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Trim warning.
|
141,908
|
17.06.2021 20:25:25
| -28,800
|
fa9a85185639a6cb0a6365cba8186e1b0b41d9d6
|
Sqlserver remove row count show.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/dialect/mssqlDIalect.ts",
"new_path": "src/service/dialect/mssqlDIalect.ts",
"diff": "@@ -119,15 +119,21 @@ ALTER TABLE ${table} ALTER COLUMN ${column} ${type} ${defaultDefinition};\nreturn `SELECT count(*) count FROM ${database}.${table};`;\n}\nshowTables(database: string): string {\n- return `SELECT\n- TABLE_NAME 'name',ds.row_count rows\n+ return `SELECT TABLE_NAME 'name'\nFROM\nINFORMATION_SCHEMA.TABLES t\n- join sys.dm_db_partition_stats ds on ds.object_id = object_id(t.TABLE_SCHEMA+ '.'+ t.TABLE_NAME)\n- and ds.index_id IN (0, 1)\nWHERE\nTABLE_TYPE = 'BASE TABLE'\nAND TABLE_SCHEMA = '${database}' order by TABLE_NAME`\n+ // return `SELECT\n+ // TABLE_NAME 'name',ds.row_count rows\n+ // FROM\n+ // INFORMATION_SCHEMA.TABLES t\n+ // join sys.dm_db_partition_stats ds on ds.object_id = object_id(t.TABLE_SCHEMA+ '.'+ t.TABLE_NAME)\n+ // and ds.index_id IN (0, 1)\n+ // WHERE\n+ // TABLE_TYPE = 'BASE TABLE'\n+ // AND TABLE_SCHEMA = '${database}' order by TABLE_NAME`\n}\nshowDatabases(){\nreturn \"SELECT name 'Database' FROM sys.databases\"\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Sqlserver remove row count show.
|
141,908
|
17.06.2021 21:28:16
| -28,800
|
f84c19bdd8f4912759d66fe7e445a63c20de38d4
|
Codelen skip block comment.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/sqlCodeLensProvider.ts",
"new_path": "src/provider/sqlCodeLensProvider.ts",
"diff": "@@ -26,14 +26,33 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\nlet start: vscode.Position;\nlet end: vscode.Position;\nlet sql: string = \"\";\n+ let inBlockComment = false;\nconst lineCount = Math.min(document.lineCount, 3000);\nfor (var i = 0; i < lineCount; i++) {\n+ let col = 0;\nvar line = document.lineAt(i)\nvar text = line.text?.replace(/(--|#).+/, '');\n+ if (inBlockComment) {\n+ const blockEndMatch = text.match(/.*?(\\*\\/)/)\n+ if (!blockEndMatch) {\n+ continue;\n+ }\n+ inBlockComment = false;\n+ text = text.replace(/.*?(\\*\\/)/, '')\n+ col = blockEndMatch[0].length\n+ } else {\n+ const blockComment = text.match(/(\\/\\*).*?(\\*\\/)?/)\n+ inBlockComment = blockComment && blockComment[2] == null;\n+ if (inBlockComment) {\n+ continue;\n+ }\n+ }\n+\n+ if (text == '') continue;\nsql = sql + \"\\n\" + text;\nif (text?.trim() && !start) {\n- start = new vscode.Position(i, 0)\n+ start = new vscode.Position(i, col)\n}\nlet sep = text.indexOf(delimter)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Codelen skip block comment.
|
141,908
|
17.06.2021 21:35:42
| -28,800
|
c9787345c763f46f6fcc74f647cde211bb156271
|
Init history provider.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"id\": \"github.cweijan.mysql\",\n\"name\": \"Database\"\n}\n+\n],\n\"github-cweijan-nosql\": [\n{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -15,10 +15,14 @@ export class Pattern {\n}\nexport enum CacheKey {\n+ // sql\nConectionsKey = \"mysql.connections\",\nCollapseSate = \"mysql.database.cache.collapseState\",\n+ // nosql\nNOSQL_CONNECTION = \"redis.connections\",\nCOLLAPSE_SATE = \"redis.cache.collapseState\",\n+ // history\n+ GLOBAL_HISTORY=\"sql.history\"\n}\nexport enum ConfigKey {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -38,6 +38,7 @@ import { DatabaseCache } from \"./service/common/databaseCache\";\nimport { FileNode } from \"./model/ssh/fileNode\";\nimport { SSHConnectionNode } from \"./model/ssh/sshConnectionNode\";\nimport { FTPFileNode } from \"./model/ftp/ftpFileNode\";\n+import { HistoryNode } from \"./provider/history/historyNode\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -177,6 +178,12 @@ export function activate(context: vscode.ExtensionContext) {\nuserNode.selectSqlTemplate();\n},\n},\n+ // history\n+ ...{\n+ \"mysql.history.view\":(historyNode:HistoryNode)=>{\n+ historyNode.view()\n+ }\n+ },\n// query node\n...{\n\"mysql.runQuery\": (sql) => {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/history/historyNode.ts",
"diff": "+import { FileManager, FileModel } from \"@/common/filesManager\";\n+import * as vscode from \"vscode\";\n+import { ThemeIcon, TreeItem } from \"vscode\";\n+\n+export class HistoryNode extends TreeItem {\n+ public iconPath = new ThemeIcon(\"history\")\n+ constructor(public sql: string, public date: string, public costTime: number) {\n+ super(sql.replace(\"\\n\",\" \"))\n+ this.tooltip = `Date: ${date}`\n+ this.description = `${costTime}ms`\n+ this.command = {\n+ command: \"mysql.history.view\",\n+ title: \"View History\",\n+ arguments: [this, true],\n+ }\n+ }\n+\n+ public async view() {\n+ const content = `/* ${this.date} [${this.costTime} ms] */\\n${this.sql}`;\n+ const sqlDocument = await vscode.workspace.openTextDocument(await FileManager.record(`history_view.sql`, content, FileModel.WRITE))\n+ await vscode.window.showTextDocument(sqlDocument);\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/history/historyProvider.ts",
"diff": "+import { CacheKey } from \"@/common/constants\";\n+import { Global } from \"@/common/global\";\n+import * as vscode from \"vscode\";\n+import { HistoryNode } from \"./historyNode\";\n+\n+export class HistoryProvider implements vscode.TreeDataProvider<HistoryNode>{\n+\n+ public static _onDidChangeTreeData: vscode.EventEmitter<HistoryNode> = new vscode.EventEmitter<HistoryNode>();\n+ public readonly onDidChangeTreeData: vscode.Event<HistoryNode> = HistoryProvider._onDidChangeTreeData.event;\n+ constructor(protected context: vscode.ExtensionContext) {\n+ }\n+\n+ getTreeItem(element: HistoryNode): vscode.TreeItem | Thenable<vscode.TreeItem> {\n+ return element;\n+ }\n+ getChildren(element?: HistoryNode): vscode.ProviderResult<HistoryNode[]> {\n+ let globalHistories = this.context.globalState.get<Array<HistoryNode>>(CacheKey.GLOBAL_HISTORY, []);\n+ return globalHistories.map(history => {\n+ return new HistoryNode(history.sql, history.date, history.costTime)\n+ })\n+ }\n+ getParent?(element: HistoryNode): vscode.ProviderResult<HistoryNode> {\n+ return null;\n+ }\n+\n+ public static recordHistory(historyNode: HistoryNode) {\n+ let glboalHistoryies = Global.context.globalState.get<Array<HistoryNode>>(CacheKey.GLOBAL_HISTORY, []);\n+ glboalHistoryies.unshift(historyNode)\n+ if(glboalHistoryies.length>100){\n+ glboalHistoryies=glboalHistoryies.splice(-1,1)\n+ }\n+ Global.context.globalState.update(CacheKey.GLOBAL_HISTORY, glboalHistoryies);\n+ HistoryProvider._onDidChangeTreeData.fire(null)\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/common/historyRecorder.ts",
"new_path": "src/service/common/historyRecorder.ts",
"diff": "+import { HistoryNode } from \"@/provider/history/historyNode\";\n+import { HistoryProvider } from \"@/provider/history/historyProvider\";\nimport { TextEditor, Selection } from \"vscode\";\nimport { FileManager } from \"../../common/filesManager\";\nexport class HistoryRecorder {\n@@ -17,6 +19,7 @@ export class HistoryRecorder {\nif (!sql || sql==this.preSql) { return; }\nthis.preSql=sql;\nFileManager.record('history.sql', `/* ${this.getNowDate()} [${costTime} ms] */ ${sql.replace(/[\\r\\n]/g, \" \")}\\n`);\n+ HistoryProvider.recordHistory(new HistoryNode(sql,this.getNowDate(),costTime))\n}\nprivate getNowDate(): string {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "@@ -36,6 +36,7 @@ import { SettingService } from \"./setting/settingService\";\nimport ConnectionProvider from \"@/model/ssh/connectionProvider\";\nimport { SqliTeDialect } from \"./dialect/sqliteDialect\";\nimport { MongoPageService } from \"./page/mongoPageService\";\n+import { HistoryProvider } from \"@/provider/history/historyProvider\";\nexport class ServiceManager {\n@@ -71,6 +72,7 @@ export class ServiceManager {\nthis.initMysqlService();\nres.push(this.initTreeView())\nres.push(this.initTreeProvider())\n+ // res.push(vscode.window.createTreeView(\"github.cweijan.history\",{treeDataProvider:new HistoryProvider(this.context)}))\nServiceManager.instance = this;\nthis.isInit = true\nreturn res\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Init history provider.
|
141,903
|
17.06.2021 21:23:43
| -19,080
|
8a97985fec1664fd3d2a345bdbd00fca6d975307
|
Corrected spelling of prefer. So that it can display correctly on Extension settings.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"default\": 100,\n\"description\": \"%config.defaultSelectLimit%\"\n},\n- \"database-client.prefreConnectionName\": {\n+ \"database-client.preferConnectionName\": {\n\"type\": \"boolean\",\n\"default\": true,\n- \"description\": \"%config.prefreConnectionName%\"\n+ \"description\": \"%config.preferConnectionName%\"\n},\n\"database-client.disableSqlCodeLen\": {\n\"type\": \"boolean\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.nls.json",
"new_path": "package.nls.json",
"diff": "\"command.redis.key.del\": \"Delete Key\",\n\"command.redis.key.detail\": \"View Key Detail\",\n\"config.title\":\"Database Client\",\n- \"config.prefreConnectionName\":\"Using connection name as connection node name\",\n+ \"config.preferConnectionName\":\"Using connection name as connection node name\",\n\"config.defaultSelectLimit\":\"Default limit of query sql.\"\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -27,7 +27,7 @@ export enum CacheKey {\nexport enum ConfigKey {\nDEFAULT_LIMIT = \"defaultSelectLimit\",\n- PREFRE_CONNECTION_NAME = \"prefreConnectionName\",\n+ PREFER_CONNECTION_NAME = \"preferConnectionName\",\nDISABLE_SQL_CODELEN = \"disableSqlCodeLen\",\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/connectionNode.ts",
"new_path": "src/model/database/connectionNode.ts",
"diff": "@@ -33,8 +33,8 @@ export class ConnectionNode extends Node implements CopyAble {\nthis.cacheSelf()\nif (parent.name) {\nthis.name = parent.name\n- const prefreName = Global.getConfig(ConfigKey.PREFRE_CONNECTION_NAME, true)\n- prefreName ? this.label = parent.name : this.description = parent.name;\n+ const preferName = Global.getConfig(ConfigKey.PREFER_CONNECTION_NAME, true)\n+ preferName ? this.label = parent.name : this.description = parent.name;\n}\n// https://www.iloveimg.com/zh-cn/resize-image/resize-svg\nif (this.dbType == DatabaseType.PG) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Corrected spelling of prefer. So that it can display correctly on Extension settings.
|
141,908
|
18.06.2021 09:39:27
| -28,800
|
3dfb6385ef77cb07beb44348c5b7eb174b835d42
|
split edit and connect.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/connectService.ts",
"new_path": "src/service/connect/connectService.ts",
"diff": "@@ -24,7 +24,7 @@ export class ConnectService {\n}\n}\nViewManager.createWebviewPanel({\n- path: \"app\", title: \"connect\",\n+ path: \"app\", title: connectionNode?\"edit\":\"connect\",\nsplitView: false, iconPath: Global.getExtPath(\"resources\", \"icon\", \"connection.svg\"),\neventHandler: (handler) => {\nhandler.on(\"init\", () => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
split edit and connect.
|
141,908
|
18.06.2021 17:22:32
| -28,800
|
e66310b2e3647ec46686c85838ba136838a28213
|
Split with remote and local.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -19,7 +19,8 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\npublic readonly onDidChangeTreeData: vscode.Event<Node> = this._onDidChangeTreeData.event;\npublic static instances: DbTreeDataProvider[] = []\n- constructor(protected context: vscode.ExtensionContext, public readonly connectionKey: string) {\n+ constructor(protected context: vscode.ExtensionContext, public connectionKey: string) {\n+ this.connectionKey+=vscode.env.remoteName||\"\"\nDbTreeDataProvider.instances.push(this)\n}\n@@ -87,9 +88,9 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\nprivate getKeyByNode(connectionNode: Node): string {\nconst dbType = connectionNode.dbType;\nif (dbType == DatabaseType.ES || dbType == DatabaseType.REDIS || dbType == DatabaseType.SSH || dbType == DatabaseType.FTP || dbType == DatabaseType.MONGO_DB) {\n- return CacheKey.NOSQL_CONNECTION;\n+ return CacheKey.NOSQL_CONNECTION+(vscode.env.remoteName||\"\");\n}\n- return CacheKey.ConectionsKey;\n+ return CacheKey.ConectionsKey+(vscode.env.remoteName||\"\");\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Split with remote and local.
|
141,908
|
19.06.2021 12:35:41
| -28,800
|
40b7ac007e728dd9c62574b227f80400c449ed2f
|
Terminal don't get focus when input data.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/xterm/index.vue",
"new_path": "src/vue/xterm/index.vue",
"diff": "this\n.on('connecting', content => {\nterminal.write(content)\n- terminal.focus()\n+ // terminal.focus()\n})\n.on('data', (content) => {\nterminal.write(content)\n- terminal.focus()\n+ // terminal.focus()\n})\n.on('path', path => {\nthis.emit('data', `cd ${path}\\n`)\nresizeScreen()\nstatus.innerHTML = data\nstatus.style.backgroundColor = '#338c33'\n- terminal.focus()\n+ // terminal.focus()\n})\n.on('ssherror', (data) => {\nstatus.innerHTML = data\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Terminal don't get focus when input data.
|
141,908
|
19.06.2021 14:21:46
| -28,800
|
e58e2f6fd1857a71a1a7f39a8bce99ebb5071619
|
Add sqlite3 exists check.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/connectService.ts",
"new_path": "src/service/connect/connectService.ts",
"diff": "-import { ConnectionNode } from \"../../model/database/connectionNode\";\n-import { DbTreeDataProvider } from \"../../provider/treeDataProvider\";\n+import { DatabaseType } from \"@/common/constants\";\n+import { ConnectionManager } from \"@/service/connectionManager\";\n+import * as os from \"os\";\n+import { platform } from \"os\";\n+import { window } from \"vscode\";\n+import { Global } from \"../../common/global\";\n+import { Util } from \"../../common/util\";\nimport { ViewManager } from \"../../common/viewManager\";\n+import { ConnectionNode } from \"../../model/database/connectionNode\";\nimport { Node } from \"../../model/interface/node\";\nimport { NodeUtil } from \"../../model/nodeUtil\";\n-import { Util } from \"../../common/util\";\n-import { Global } from \"../../common/global\";\n-import { ConnectionManager } from \"@/service/connectionManager\";\n-import { DatabaseType } from \"@/common/constants\";\n+import { DbTreeDataProvider } from \"../../provider/treeDataProvider\";\nimport { ClientManager } from \"../ssh/clientManager\";\n-import { window } from \"vscode\";\n+var commandExistsSync = require('command-exists').sync;\nexport class ConnectService {\n@@ -23,6 +26,7 @@ export class ConnectService {\n}\n}\n}\n+ let plat:string = platform();\nViewManager.createWebviewPanel({\npath: \"app\", title: connectionNode ? \"edit\" : \"connect\",\nsplitView: false, iconPath: Global.getExtPath(\"resources\", \"icon\", \"connection.svg\"),\n@@ -35,6 +39,30 @@ export class ConnectService {\n} else {\nhandler.emit(\"connect\")\n}\n+ const exists = plat == 'win32' ? true : commandExistsSync(\"sqlite\");\n+ handler.emit(\"sqliteState\", exists)\n+ }).on(\"installSqlite\", () => {\n+ let command: string;\n+ switch (plat) {\n+ case 'darwin':\n+ command = `brew install sqlite3`\n+ break;\n+ case 'linux':\n+ if (commandExistsSync(\"apt\")) {\n+ command = `sudo apt -y install sqlite`;\n+ } else if (commandExistsSync(\"yum\")) {\n+ command = `sudo yum -y install sqlite3`;\n+ } else if (commandExistsSync(\"dnf\")) {\n+ command = `sudo dnf install sqlite` // Fedora\n+ } else {\n+ command = `sudo pkg install -y sqlite3` // freebsd\n+ }\n+ break;\n+ default: return;\n+ }\n+ const terminal = window.createTerminal(\"installSqlite\")\n+ terminal.sendText(command)\n+ terminal.show()\n}).on(\"connecting\", async (data) => {\nconst connectionOption = data.connectionOption\nconst connectNode = Util.trim(NodeUtil.of(connectionOption))\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/sqlite/index.ts",
"new_path": "src/service/connect/sqlite/index.ts",
"diff": "@@ -9,7 +9,7 @@ import { FieldInfo } from \"../../../common/typeDef\";\n// TODO: Improve how the sqlite command is set\nclass SQLite {\n- private dbPath: string;\n+ public readonly dbPath: string;\nprivate sqliteCommand!: string;\nconstructor(dbPath: string) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/sqliteConnection.ts",
"new_path": "src/service/connect/sqliteConnection.ts",
"diff": "@@ -35,6 +35,10 @@ export class SqliteConnection extends IConnection {\nreturn event;\n}\nconnect(callback: (err: Error) => void): void {\n+ if(!this.sqlite.dbPath){\n+ callback(new Error(\"Sqlite db path cannot be null!\"))\n+ return;\n+ }\ncallback(null)\nthis.conneted = true;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/connect/index.vue",
"new_path": "src/vue/connect/index.vue",
"diff": "<label class=\"block font-bold\">Database Type</label>\n<ul class=\"tab\">\n<li class=\"tab__item \" :class=\"{'tab__item--active':supportDatabase==connectionOption.dbType}\"\n- v-for=\"supportDatabase in supportDatabases\" :key=\"supportDatabase\" @click=\"connectionOption.dbType=supportDatabase\">\n+ v-for=\"supportDatabase in supportDatabases\" :key=\"supportDatabase\"\n+ @click=\"connectionOption.dbType=supportDatabase\">\n{{supportDatabase}}\n</li>\n</ul>\n<template v-if=\"connectionOption.dbType=='SQLite'\">\n<div>\n+ <section class=\"mb-2\" v-if=\"!sqliteState\">\n+ <div class=\"font-bold mr-5 inline-block w-1/4\">\n+ <el-alert title=\"sqlite not installed\" type=\"warning\" show-icon/>\n+ </div>\n+ <div class=\"font-bold mr-5 inline-block w-36\">\n+ <button class=\"button button--primary w-128 inline\" @click=\"installSqlite\">Install Sqlite</button>\n+ </div>\n+ </section>\n<section class=\"mb-2\">\n<div class=\"inline-block mr-10\">\n<label class=\"font-bold mr-5 inline-block w-28\">SQLite File Path</label>\n</div>\n<div class=\"inline-block mr-10\" v-if=\"connectionOption.dbType!='Redis' \">\n<label class=\"font-bold mr-5 inline-block w-32\">Include Databases</label>\n- <input class=\"w-64 field__input\" placeholder=\"Which databases need to be displayed\" title=\"Example: mysql,test\"\n- v-model=\"connectionOption.includeDatabases\" />\n+ <input class=\"w-64 field__input\" placeholder=\"Which databases need to be displayed\"\n+ title=\"Example: mysql,test\" v-model=\"connectionOption.includeDatabases\" />\n</div>\n</section>\n},\n},\n},\n+ sqliteState: false,\ntype: \"password\",\nsupportDatabases: [\n\"MySQL\",\n}\nthis.$forceUpdate()\n})\n+ .on(\"sqliteState\", sqliteState => {\n+ this.sqliteState = sqliteState;\n+ })\n.on(\"error\", (err) => {\nthis.connect.loading = false;\nthis.connect.success = false;\nvscodeEvent.destroy();\n},\nmethods: {\n+ installSqlite() {\n+ vscodeEvent.emit(\"installSqlite\")\n+ this.sqliteState=true;\n+ },\ntryConnect() {\nthis.connect.loading = true;\nvscodeEvent.emit(\"connecting\", {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add sqlite3 exists check.
|
141,908
|
19.06.2021 17:04:25
| -28,800
|
2b1b002d9443730a576e5e6645a308a6a422a12e
|
Support load data when over timeout.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -39,15 +39,20 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\nreturn;\n}\ntry {\n- const mark = setTimeout(() => {\n+ let mark = setTimeout(() => {\nres([new InfoNode(`Connect time out!`)])\n+ mark=null;\n}, element.connectTimeout || 5000);\nconst children = await element.getChildren();\n+ if(mark){\nclearTimeout(mark)\nfor (const child of children) {\nchild.parent = element;\n}\nres(children);\n+ }else{\n+ this.reload(element)\n+ }\n} catch (error) {\nres([new InfoNode(error)])\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support load data when over timeout.
|
141,908
|
19.06.2021 17:09:36
| -28,800
|
6917583de9b68e821664e499cd2c7ada70d1a62e
|
Fix ssh child load fail.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/ssh/clientManager.ts",
"new_path": "src/service/ssh/clientManager.ts",
"diff": "@@ -36,6 +36,7 @@ export class ClientManager {\n}\n}).on('error', (err) => {\n+ this.activeClient[key] = null\nvscode.window.showErrorMessage(err.message)\nreject(err)\n}).on('end', () => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix ssh child load fail.
|
141,908
|
19.06.2021 17:32:04
| -28,800
|
53b8479a1ce64f61d9dab11b7bd03c576fee9f53
|
Better active database item.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/database/connectionNode.ts",
"new_path": "src/model/database/connectionNode.ts",
"diff": "@@ -114,7 +114,7 @@ export class ConnectionNode extends Node implements CopyAble {\npublic async newQuery() {\n- await FileManager.show(`${new Date().getTime()}.sql`);\n+ await FileManager.show(`${this.label}.sql`);\nlet childMap = {};\nconst dbNameList = (await this.getChildren()).filter((databaseNode) => (databaseNode instanceof SchemaNode || databaseNode instanceof CatalogNode)).map((databaseNode) => {\nchildMap[databaseNode.uid] = databaseNode\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -161,24 +161,39 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\n}\nconst dbIdList: string[] = [];\n- const dbIdMap = new Map<string, SchemaNode>();\n- const numbers = (await this.getConnectionNodes()).length > 1\n- for (const dbNode of DatabaseCache.getDatabaseNodeList()) {\n- if (dbNode instanceof UserGroup || dbNode instanceof CatalogNode) { continue }\n- const uid = numbers ? dbNode.uid : dbNode.schema\n+ const dbIdMap = new Map<string, Node>();\n+ const connectionNodes = await this.getConnectionNodes()\n+ for (const cNode of connectionNodes) {\n+ if (cNode.dbType == DatabaseType.SQLITE) {\n+ const uid = cNode.label;\ndbIdList.push(uid)\n- dbIdMap.set(uid, dbNode)\n+ dbIdMap.set(uid, cNode)\n+ continue;\n}\n- if (dbIdList) {\n+\n+ const schemaList = DatabaseCache.getSchemaListOfConnection(cNode.uid)\n+ for (const schemaNode of schemaList) {\n+ if (schemaNode instanceof UserGroup || schemaNode instanceof CatalogNode) { continue }\n+ let uid = `${cNode.label}#${schemaNode.schema}`\n+ if (cNode.dbType == DatabaseType.PG || cNode.dbType == DatabaseType.MSSQL) {\n+ uid = `${cNode.label}#${schemaNode.database}#${schemaNode.schema}`\n+ }\n+ dbIdList.push(uid)\n+ dbIdMap.set(uid, schemaNode)\n+ }\n+\n+ }\n+\n+ if (dbIdList.length == 0) {\n+ return;\n+ }\n+\nvscode.window.showQuickPick(dbIdList).then(async (dbId) => {\nif (dbId) {\nconst dbNode = dbIdMap.get(dbId);\nConnectionManager.changeActive(dbNode)\n- vscode.window.showInformationMessage(`Change active schema to ${dbNode.schema} success!`)\n}\n-\n})\n- }\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Better active database item.
|
141,908
|
19.06.2021 17:36:42
| -28,800
|
775fe74af1fd137a144f369cdc6d90508205d1a6
|
Remove sqlite desc from readme.
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -61,14 +61,6 @@ Click the history button to open the list of recently executed query history rec\n\n-## Sqlite\n-\n-If you using Linux or MacOS that must install sqlite3 first.\n-\n-- Debian, Ubuntu:`sudo apt-get install sqlite`\n-- CentOS, Fedora, RedHat:`sudo yum install sqlite3`\n-- MacOS:`brew install sqlite3`\n-\n## Backup/Import\nMove to ant DatabaseNode or TableNode. The export/import options are listed in the context menu (right click to open).\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Remove sqlite desc from readme.
|
141,908
|
19.06.2021 18:24:22
| -28,800
|
503d3077118c0d8747ce9568e24f103e7f921c80
|
Init connecton config edit.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"title\": \"%command.connection.edit%\",\n\"category\": \"MySQL\"\n},\n+ {\n+ \"command\": \"mysql.connection.config\",\n+ \"title\": \"%command.connection.config%\",\n+ \"icon\": \"$(gear)\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.connection.disable\",\n\"title\": \"%command.connection.disable%\",\n\"when\": \"view == github.cweijan.mysql\",\n\"group\": \"navigation@-2\"\n},\n+ {\n+ \"command\": \"mysql.connection.config\",\n+ \"when\": \"view == github.cweijan.mysql\",\n+ \"group\": \"navigation@-3\"\n+ },\n{\n\"command\": \"mysql.util.github\",\n- \"when\": \"view =~ /cweijan.+?ql/\",\n+ \"when\": \"view == github.cweijan.nosql\",\n\"group\": \"navigation@-3\"\n}\n],\n"
},
{
"change_type": "MODIFY",
"old_path": "package.nls.json",
"new_path": "package.nls.json",
"diff": "\"command.diagram.drop\": \"Drop Diagram\",\n\"command.connection.add\": \"Add Connection\",\n\"command.connection.edit\": \"Edit Connection\",\n+ \"command.connection.config\": \"Edit Connection Config\",\n\"command.connection.disable\": \"Close Connection\",\n\"command.struct.diff\": \"Database Struct Sync\",\n\"command.server.info\": \"Server Status\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -16,8 +16,8 @@ export class Pattern {\nexport enum CacheKey {\n// sql\n- ConectionsKey = \"mysql.connections\",\n- CollapseSate = \"mysql.database.cache.collapseState\",\n+ DATBASE_CONECTIONS = \"mysql.connections\",\n+ DATABASE_SATE = \"mysql.database.cache.collapseState\",\n// nosql\nNOSQL_CONNECTION = \"redis.connections\",\nCOLLAPSE_SATE = \"redis.cache.collapseState\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/filesManager.ts",
"new_path": "src/common/filesManager.ts",
"diff": "@@ -45,6 +45,9 @@ export class FileManager {\n});\n}\n+ public static getPath(fileName:string){\n+ return `${this.storagePath}/${fileName}`;\n+ }\nprivate static check(checkPath: string) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -39,6 +39,7 @@ import { FileNode } from \"./model/ssh/fileNode\";\nimport { SSHConnectionNode } from \"./model/ssh/sshConnectionNode\";\nimport { FTPFileNode } from \"./model/ftp/ftpFileNode\";\nimport { HistoryNode } from \"./provider/history/historyNode\";\n+import { ConnectService } from \"./service/connect/connectService\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -46,7 +47,6 @@ export function activate(context: vscode.ExtensionContext) {\nactiveEs(context)\n-\nConnectionNode.init()\ncontext.subscriptions.push(\n...serviceManager.init(),\n@@ -56,7 +56,7 @@ export function activate(context: vscode.ExtensionContext) {\nConnectionManager.changeActive(fileNode)\n}\n}),\n-\n+ ConnectService.listenConfig(),\n...initCommand({\n// util\n...{\n@@ -90,6 +90,9 @@ export function activate(context: vscode.ExtensionContext) {\n\"mysql.connection.edit\": (connectionNode: ConnectionNode) => {\nserviceManager.connectService.openConnect(connectionNode.provider, connectionNode)\n},\n+ \"mysql.connection.config\": () => {\n+ serviceManager.connectService.openConfig()\n+ },\n\"mysql.connection.open\": (connectionNode: ConnectionNode) => {\nconnectionNode.provider.openConnection(connectionNode)\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -20,6 +20,7 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\npublic static instances: DbTreeDataProvider[] = []\nconstructor(protected context: vscode.ExtensionContext, public connectionKey: string) {\n+ // TODO remote key\nthis.connectionKey += vscode.env.remoteName || \"\"\nDbTreeDataProvider.instances.push(this)\n}\n@@ -91,11 +92,12 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\n}\nprivate getKeyByNode(connectionNode: Node): string {\n+ // TODO remote key\nconst dbType = connectionNode.dbType;\nif (dbType == DatabaseType.ES || dbType == DatabaseType.REDIS || dbType == DatabaseType.SSH || dbType == DatabaseType.FTP || dbType == DatabaseType.MONGO_DB) {\nreturn CacheKey.NOSQL_CONNECTION + (vscode.env.remoteName || \"\");\n}\n- return CacheKey.ConectionsKey + (vscode.env.remoteName || \"\");\n+ return CacheKey.DATBASE_CONECTIONS + (vscode.env.remoteName || \"\");\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/common/databaseCache.ts",
"new_path": "src/service/common/databaseCache.ts",
"diff": "@@ -51,10 +51,10 @@ export class DatabaseCache {\nif (element.global === false) {\nthis.workspaceCollpaseState[element.uid] = collapseState;\n- this.context.workspaceState.update(CacheKey.CollapseSate, this.globalCollpaseState);\n+ this.context.workspaceState.update(CacheKey.DATABASE_SATE, this.globalCollpaseState);\n} else {\nthis.globalCollpaseState[element.uid] = collapseState;\n- this.context.globalState.update(CacheKey.CollapseSate, this.globalCollpaseState);\n+ this.context.globalState.update(CacheKey.DATABASE_SATE, this.globalCollpaseState);\n}\n}\n@@ -65,8 +65,8 @@ export class DatabaseCache {\n*/\npublic static initCache(context: ExtensionContext) {\nthis.context = context;\n- this.globalCollpaseState = this.context.globalState.get(CacheKey.CollapseSate, {});\n- this.workspaceCollpaseState = this.context.workspaceState.get(CacheKey.CollapseSate, {});\n+ this.globalCollpaseState = this.context.globalState.get(CacheKey.DATABASE_SATE, {});\n+ this.workspaceCollpaseState = this.context.workspaceState.get(CacheKey.DATABASE_SATE, {});\n}\npublic static clearCache() {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/service/connect/config/connnetionConfig.ts",
"diff": "+import { Node } from \"@/model/interface/node\";\n+\n+export class ConnnetionConfig {\n+ database: ConnectionTarget;\n+ nosql: ConnectionTarget;\n+}\n+\n+export class ConnectionTarget {\n+ global: { [key: string]: Node };\n+ workspace: { [key: string]: Node };\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/connectService.ts",
"new_path": "src/service/connect/connectService.ts",
"diff": "-import { DatabaseType } from \"@/common/constants\";\n+import { CacheKey, CodeCommand, DatabaseType } from \"@/common/constants\";\n+import { FileManager, FileModel } from \"@/common/filesManager\";\nimport { ConnectionManager } from \"@/service/connectionManager\";\n-import * as os from \"os\";\n+import { resolve } from \"path\";\nimport { platform } from \"os\";\n-import { window } from \"vscode\";\n+import { commands, Disposable, window, workspace } from \"vscode\";\nimport { Global } from \"../../common/global\";\nimport { Util } from \"../../common/util\";\nimport { ViewManager } from \"../../common/viewManager\";\n@@ -11,6 +12,8 @@ import { Node } from \"../../model/interface/node\";\nimport { NodeUtil } from \"../../model/nodeUtil\";\nimport { DbTreeDataProvider } from \"../../provider/treeDataProvider\";\nimport { ClientManager } from \"../ssh/clientManager\";\n+import { ConnnetionConfig } from \"./config/connnetionConfig\";\n+import { readFileSync } from \"fs\";\nvar commandExistsSync = require('command-exists').sync;\nexport class ConnectService {\n@@ -100,4 +103,81 @@ export class ConnectService {\nawait ConnectionManager.getConnection(connectionNode)\n}\n+ static listenConfig(): Disposable {\n+ const configPath = resolve(FileManager.getPath(\"config.json\"))\n+ return workspace.onDidSaveTextDocument(e => {\n+ const changePath = resolve(e.uri.fsPath);\n+ if (changePath == configPath) {\n+ this.saveConfig(configPath)\n+ }\n+ });\n+ }\n+\n+ private static async saveConfig(path: string) {\n+ const configContent = readFileSync(path, { encoding: 'utf8' })\n+ try {\n+ const connectonConfig: ConnnetionConfig = JSON.parse(configContent)\n+ await Global.context.globalState.update(CacheKey.DATBASE_CONECTIONS,connectonConfig.database.global);\n+ await Global.context.workspaceState.update(CacheKey.DATBASE_CONECTIONS,connectonConfig.database.workspace);\n+ await Global.context.globalState.update(CacheKey.NOSQL_CONNECTION,connectonConfig.nosql.global);\n+ await Global.context.workspaceState.update(CacheKey.NOSQL_CONNECTION,connectonConfig.nosql.workspace);\n+ DbTreeDataProvider.refresh();\n+ } catch (error) {\n+ window.showErrorMessage(\"Parse connect config fail!\")\n+ }\n+ }\n+\n+ public openConfig() {\n+\n+ // TODO remote suffix\n+\n+ const connectonConfig: ConnnetionConfig = {\n+ database: {\n+ global: Global.context.globalState.get(CacheKey.DATBASE_CONECTIONS),\n+ workspace: Global.context.workspaceState.get(CacheKey.DATBASE_CONECTIONS),\n+ },\n+ nosql: {\n+ global: Global.context.globalState.get(CacheKey.NOSQL_CONNECTION),\n+ workspace: Global.context.workspaceState.get(CacheKey.NOSQL_CONNECTION),\n+ }\n+ };\n+\n+ FileManager.record(\"config.json\", JSON.stringify(connectonConfig, this.trim, 2), FileModel.WRITE).then(filePath => {\n+ FileManager.show(filePath)\n+ })\n+\n+ }\n+\n+ public trim(key: string, value: any): any {\n+ switch (key) {\n+ case \"iconPath\":\n+ case \"contextValue\":\n+ case \"parent\":\n+ case \"key\":\n+ case \"label\":\n+ case \"id\":\n+ case \"resourceUri\":\n+ case \"pattern\":\n+ case \"level\":\n+ case \"tooltip\":\n+ case \"descriptionz\":\n+ case \"collapsibleState\":\n+ case \"terminalService\":\n+ case \"forwardService\":\n+ case \"file\":\n+ case \"parentName\":\n+ case \"connectionKey\":\n+ case \"sshConfig\":\n+ case \"fullPath\":\n+ case \"uid\":\n+ case \"command\":\n+ case \"dialect\":\n+ case \"provider\":\n+ case \"context\":\n+ case \"isGlobal\":\n+ return undefined;\n+ }\n+ return value;\n+ }\n+\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "@@ -80,7 +80,7 @@ export class ServiceManager {\nprivate initTreeView() {\n- this.provider = new DbTreeDataProvider(this.context, CacheKey.ConectionsKey);\n+ this.provider = new DbTreeDataProvider(this.context, CacheKey.DATBASE_CONECTIONS);\nconst treeview = vscode.window.createTreeView(\"github.cweijan.mysql\", {\ntreeDataProvider: this.provider,\n});\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Init connecton config edit.
|
141,908
|
21.06.2021 10:50:34
| -28,800
|
2bbced7a2ea449b6e02031e34abc491e01ee6037
|
Isolate the configuration of vscode and remote.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/common/state.ts",
"diff": "+import { Global } from \"./global\";\n+import * as vscode from \"vscode\";\n+\n+export class GlobalState {\n+ public static update(key: string, value: any): Thenable<void> {\n+ key = getKey(key)\n+ return Global.context.globalState.update(key, value)\n+ }\n+\n+ public static get<T>(key: string, defaultValue?: T): T {\n+ key = getKey(key)\n+ return Global.context.globalState.get(key, defaultValue)\n+ }\n+}\n+\n+export class WorkState {\n+\n+ public static update(key: string, value: any): Thenable<void> {\n+ key = getKey(key)\n+ return Global.context.workspaceState.update(key, value)\n+ }\n+\n+ public static get<T>(key: string, defaultValue?: T): T {\n+ key = getKey(key)\n+ return Global.context.workspaceState.get(key, defaultValue)\n+ }\n+\n+}\n+export function getKey(key: string): string {\n+\n+ if (vscode.env.remoteName == \"ssh-remote\" && key.indexOf(\"ssh-remote\") == -1) {\n+ return key + \"ssh-remote\";\n+ }\n+\n+ return key;\n+}\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/util.ts",
"new_path": "src/common/util.ts",
"diff": "@@ -6,6 +6,7 @@ import { Confirm, Constants, DatabaseType } from \"./constants\";\nimport { Global } from \"./global\";\nimport { compare } from 'compare-versions';\nimport { wrapByDb } from \"./wrapper.js\";\n+import { GlobalState } from \"./state\";\nexport class Util {\n@@ -99,10 +100,10 @@ export class Util {\n}\npublic static getStore(key: string): any {\n- return Global.context.globalState.get(key);\n+ return GlobalState.get(key);\n}\npublic static store(key: string, object: any) {\n- Global.context.globalState.update(key, object)\n+ GlobalState.update(key, object)\n}\npublic static is(object: any, type: string): boolean {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -50,12 +50,7 @@ export function activate(context: vscode.ExtensionContext) {\nConnectionNode.init()\ncontext.subscriptions.push(\n...serviceManager.init(),\n- vscode.window.onDidChangeActiveTextEditor((e) => {\n- const fileNode = ConnectionManager.getByActiveFile()\n- if (fileNode) {\n- ConnectionManager.changeActive(fileNode)\n- }\n- }),\n+ vscode.window.onDidChangeActiveTextEditor(detectActive),\nConnectService.listenConfig(),\n...initCommand({\n// util\n@@ -325,7 +320,6 @@ export function activate(context: vscode.ExtensionContext) {\n},\n},\n}),\n-\n);\n}\n@@ -333,6 +327,13 @@ export function activate(context: vscode.ExtensionContext) {\nexport function deactivate() {\n}\n+function detectActive(): void {\n+ const fileNode = ConnectionManager.getByActiveFile();\n+ if (fileNode) {\n+ ConnectionManager.changeActive(fileNode);\n+ }\n+}\n+\nfunction commandWrapper(commandDefinition: any, command: string): (...args: any[]) => any {\nreturn (...args: any[]) => {\ntry {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/interface/node.ts",
"new_path": "src/model/interface/node.ts",
"diff": "import { Console } from \"@/common/Console\";\nimport { DatabaseType, ModelType } from \"@/common/constants\";\n+import { getKey } from \"@/common/state\";\nimport { Util } from \"@/common/util\";\nimport { DbTreeDataProvider } from \"@/provider/treeDataProvider\";\nimport { getSqliteBinariesPath } from \"@/service/connect/sqlite/sqliteCommandValidation\";\n@@ -159,7 +160,7 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\npublic async indent(command: IndentCommand) {\ntry {\n- const connectionKey = command.connectionKey || this.connectionKey;\n+ const connectionKey = getKey(command.connectionKey || this.connectionKey);\nconst connections = this.context.get<{ [key: string]: Node }>(connectionKey, {});\nconst key = this.key\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/redis/keyNode.ts",
"new_path": "src/model/redis/keyNode.ts",
"diff": "@@ -25,9 +25,6 @@ export default class KeyNode extends RedisBaseNode {\n}\n}\n- /**\n- * @todo Split the key by ':' and group them\n- */\nasync getChildren(): Promise<RedisBaseNode[]> {\nreturn [];\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/history/historyProvider.ts",
"new_path": "src/provider/history/historyProvider.ts",
"diff": "import { CacheKey } from \"@/common/constants\";\nimport { Global } from \"@/common/global\";\n+import { GlobalState } from \"@/common/state\";\nimport * as vscode from \"vscode\";\nimport { HistoryNode } from \"./historyNode\";\n@@ -14,7 +15,7 @@ export class HistoryProvider implements vscode.TreeDataProvider<HistoryNode>{\nreturn element;\n}\ngetChildren(element?: HistoryNode): vscode.ProviderResult<HistoryNode[]> {\n- let globalHistories = this.context.globalState.get<Array<HistoryNode>>(CacheKey.GLOBAL_HISTORY, []);\n+ let globalHistories = GlobalState.get<Array<HistoryNode>>(CacheKey.GLOBAL_HISTORY, []);\nreturn globalHistories.map(history => {\nreturn new HistoryNode(history.sql, history.date, history.costTime)\n})\n@@ -24,12 +25,12 @@ export class HistoryProvider implements vscode.TreeDataProvider<HistoryNode>{\n}\npublic static recordHistory(historyNode: HistoryNode) {\n- let glboalHistoryies = Global.context.globalState.get<Array<HistoryNode>>(CacheKey.GLOBAL_HISTORY, []);\n+ let glboalHistoryies = GlobalState.get<Array<HistoryNode>>(CacheKey.GLOBAL_HISTORY, []);\nglboalHistoryies.unshift(historyNode)\nif (glboalHistoryies.length > 100) {\nglboalHistoryies = glboalHistoryies.splice(-1, 1)\n}\n- Global.context.globalState.update(CacheKey.GLOBAL_HISTORY, glboalHistoryies);\n+ GlobalState.update(CacheKey.GLOBAL_HISTORY, glboalHistoryies);\nHistoryProvider._onDidChangeTreeData.fire(null)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "+import { GlobalState, WorkState } from \"@/common/state\";\nimport { CatalogNode } from \"@/model/database/catalogNode\";\nimport { EsConnectionNode } from \"@/model/es/model/esConnectionNode\";\nimport { FTPConnectionNode } from \"@/model/ftp/ftpConnectionNode\";\n@@ -20,8 +21,6 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\npublic static instances: DbTreeDataProvider[] = []\nconstructor(protected context: vscode.ExtensionContext, public connectionKey: string) {\n- // TODO remote key\n- this.connectionKey += vscode.env.remoteName || \"\"\nDbTreeDataProvider.instances.push(this)\n}\n@@ -92,12 +91,11 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\n}\nprivate getKeyByNode(connectionNode: Node): string {\n- // TODO remote key\nconst dbType = connectionNode.dbType;\nif (dbType == DatabaseType.ES || dbType == DatabaseType.REDIS || dbType == DatabaseType.SSH || dbType == DatabaseType.FTP || dbType == DatabaseType.MONGO_DB) {\n- return CacheKey.NOSQL_CONNECTION + (vscode.env.remoteName || \"\");\n+ return CacheKey.NOSQL_CONNECTION;\n}\n- return CacheKey.DATBASE_CONECTIONS + (vscode.env.remoteName || \"\");\n+ return CacheKey.DATBASE_CONECTIONS;\n}\n@@ -121,8 +119,8 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\npublic async getConnectionNodes(): Promise<Node[]> {\nconst connetKey = this.connectionKey;\n- let globalConnections = this.context.globalState.get<{ [key: string]: Node }>(connetKey, {});\n- let workspaceConnections = this.context.workspaceState.get<{ [key: string]: Node }>(connetKey, {});\n+ let globalConnections = GlobalState.get<{ [key: string]: Node }>(connetKey, {});\n+ let workspaceConnections = WorkState.get<{ [key: string]: Node }>(connetKey, {});\nreturn Object.keys(workspaceConnections).map(key => this.getNode(workspaceConnections[key], key, false, connetKey)).concat(\nObject.keys(globalConnections).map(key => this.getNode(globalConnections[key], key, true, connetKey))\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/common/databaseCache.ts",
"new_path": "src/service/common/databaseCache.ts",
"diff": "+import { GlobalState, WorkState } from \"@/common/state\";\nimport { ExtensionContext, TreeItemCollapsibleState } from \"vscode\";\nimport { CacheKey, ModelType } from \"../../common/constants\";\nimport { SchemaNode } from \"../../model/database/schemaNode\";\n@@ -5,7 +6,6 @@ import { Node } from \"../../model/interface/node\";\nexport class DatabaseCache {\n- private static context: ExtensionContext;\nprivate static cache = { database: {} };\nprivate static childCache = {};\nprivate static globalCollpaseState: { key?: TreeItemCollapsibleState };\n@@ -51,22 +51,20 @@ export class DatabaseCache {\nif (element.global === false) {\nthis.workspaceCollpaseState[element.uid] = collapseState;\n- this.context.workspaceState.update(CacheKey.DATABASE_SATE, this.globalCollpaseState);\n+ WorkState.update(CacheKey.DATABASE_SATE, this.globalCollpaseState);\n} else {\nthis.globalCollpaseState[element.uid] = collapseState;\n- this.context.globalState.update(CacheKey.DATABASE_SATE, this.globalCollpaseState);\n+ GlobalState.update(CacheKey.DATABASE_SATE, this.globalCollpaseState);\n}\n}\n/**\n* cache init, Mainly initializing context object\n- * @param context\n*/\n- public static initCache(context: ExtensionContext) {\n- this.context = context;\n- this.globalCollpaseState = this.context.globalState.get(CacheKey.DATABASE_SATE, {});\n- this.workspaceCollpaseState = this.context.workspaceState.get(CacheKey.DATABASE_SATE, {});\n+ public static initCache() {\n+ this.globalCollpaseState = GlobalState.get(CacheKey.DATABASE_SATE, {});\n+ this.workspaceCollpaseState = WorkState.get(CacheKey.DATABASE_SATE, {});\n}\npublic static clearCache() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/connectService.ts",
"new_path": "src/service/connect/connectService.ts",
"diff": "@@ -14,6 +14,7 @@ import { DbTreeDataProvider } from \"../../provider/treeDataProvider\";\nimport { ClientManager } from \"../ssh/clientManager\";\nimport { ConnnetionConfig } from \"./config/connnetionConfig\";\nimport { readFileSync } from \"fs\";\n+import { GlobalState, WorkState } from \"@/common/state\";\nvar commandExistsSync = require('command-exists').sync;\nexport class ConnectService {\n@@ -117,10 +118,10 @@ export class ConnectService {\nconst configContent = readFileSync(path, { encoding: 'utf8' })\ntry {\nconst connectonConfig: ConnnetionConfig = JSON.parse(configContent)\n- await Global.context.globalState.update(CacheKey.DATBASE_CONECTIONS,connectonConfig.database.global);\n- await Global.context.workspaceState.update(CacheKey.DATBASE_CONECTIONS,connectonConfig.database.workspace);\n- await Global.context.globalState.update(CacheKey.NOSQL_CONNECTION,connectonConfig.nosql.global);\n- await Global.context.workspaceState.update(CacheKey.NOSQL_CONNECTION,connectonConfig.nosql.workspace);\n+ await GlobalState.update(CacheKey.DATBASE_CONECTIONS, connectonConfig.database.global);\n+ await WorkState.update(CacheKey.DATBASE_CONECTIONS, connectonConfig.database.workspace);\n+ await GlobalState.update(CacheKey.NOSQL_CONNECTION, connectonConfig.nosql.global);\n+ await WorkState.update(CacheKey.NOSQL_CONNECTION, connectonConfig.nosql.workspace);\nDbTreeDataProvider.refresh();\n} catch (error) {\nwindow.showErrorMessage(\"Parse connect config fail!\")\n@@ -129,16 +130,14 @@ export class ConnectService {\npublic openConfig() {\n- // TODO remote suffix\n-\nconst connectonConfig: ConnnetionConfig = {\ndatabase: {\n- global: Global.context.globalState.get(CacheKey.DATBASE_CONECTIONS),\n- workspace: Global.context.workspaceState.get(CacheKey.DATBASE_CONECTIONS),\n+ global: GlobalState.get(CacheKey.DATBASE_CONECTIONS),\n+ workspace: WorkState.get(CacheKey.DATBASE_CONECTIONS),\n},\nnosql: {\n- global: Global.context.globalState.get(CacheKey.NOSQL_CONNECTION),\n- workspace: Global.context.workspaceState.get(CacheKey.NOSQL_CONNECTION),\n+ global: GlobalState.get(CacheKey.NOSQL_CONNECTION),\n+ workspace: WorkState.get(CacheKey.NOSQL_CONNECTION),\n}\n};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/sqlite/index.ts",
"new_path": "src/service/connect/sqlite/index.ts",
"diff": "@@ -6,7 +6,6 @@ import { Result, ResultNew, ResultSet } from \"./common\";\nimport { validateSqliteCommand } from \"./sqliteCommandValidation\";\nimport { FieldInfo } from \"../../../common/typeDef\";\n-// TODO: Improve how the sqlite command is set\nclass SQLite {\npublic readonly dbPath: string;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/sqlite/sqliteCommandValidation.ts",
"new_path": "src/service/connect/sqlite/sqliteCommandValidation.ts",
"diff": "@@ -59,7 +59,6 @@ export function getSqliteBinariesPath(): string {\nlet os_arch = arch();\nlet sqliteBin: string;\n- // TODO: move sqlite version number to package.json and import it from there\nswitch (plat) {\ncase 'win32':\nsqliteBin = 'sqlite-v3.26.0-win32-x86.exe';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "import { CacheKey, DatabaseType } from \"@/common/constants\";\n-import { EsIndexGroup } from \"@/model/es/model/esIndexGroupNode\";\nimport { SqlCodeLensProvider } from \"@/provider/sqlCodeLensProvider\";\nimport * as vscode from \"vscode\";\nimport { ExtensionContext } from \"vscode\";\n@@ -54,7 +53,7 @@ export class ServiceManager {\nconstructor(private readonly context: ExtensionContext) {\nGlobal.context = context;\nthis.mockRunner = new MockRunner();\n- DatabaseCache.initCache(context);\n+ DatabaseCache.initCache();\nViewManager.initExtesnsionPath(context.extensionPath);\nFileManager.init(context)\nnew ConnectionProvider();\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Isolate the configuration of vscode and remote.
|
141,908
|
21.06.2021 11:15:06
| -28,800
|
cf20cc6a62a6f1b12dfafbe559dcc952499d653c
|
Fix key gone.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/interface/node.ts",
"new_path": "src/model/interface/node.ts",
"diff": "@@ -141,7 +141,9 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\nif (this.disable) {\nthis.command = { command: \"mysql.connection.open\", title: \"Open Connection\", arguments: [this] }\n}\n+ if(source.key){\nthis.key = source.key;\n+ }\nthis.initUid();\n// init tree state\nthis.collapsibleState = DatabaseCache.getElementState(this)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix key gone.
|
141,908
|
22.06.2021 09:53:36
| -28,800
|
6d5f89dce381100317c7506e95cf372c63642481
|
Fix ssh terminal cannot search.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"id\": \"github.cweijan.mysql\",\n\"name\": \"Database\"\n}\n-\n],\n\"github-cweijan-nosql\": [\n{\n\"xregexp\": \"2.0.0\",\n\"xterm\": \"^4.12.0\",\n\"xterm-addon-fit\": \"^0.5.0\",\n- \"xterm-addon-search\": \"^0.5.0\",\n+ \"xterm-addon-search\": \"^0.8.0\",\n\"xterm-addon-search-bar\": \"^0.2.0\",\n\"xterm-addon-web-links\": \"^0.4.0\"\n},\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix ssh terminal cannot search.
|
141,908
|
22.06.2021 10:45:58
| -28,800
|
66b8678594de43b4b4bbaad38cd3fd80d2f4859f
|
Fix mongo export data fail.
|
[
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -119,9 +119,10 @@ export function activate(context: vscode.ExtensionContext) {\nserviceManager.dumpService.generateDocument(node)\n},\n\"mysql.data.import\": (node: SchemaNode | ConnectionNode) => {\n- vscode.window.showOpenDialog({ filters: { Sql: ['sql'] }, canSelectMany: false, openLabel: \"Select sql file to import\", canSelectFiles: true, canSelectFolders: false }).then((filePath) => {\n+ const importService=ServiceManager.getImportService(node.dbType);\n+ vscode.window.showOpenDialog({ filters: importService.filter(), canSelectMany: false, openLabel: \"Select sql file to import\", canSelectFiles: true, canSelectFolders: false }).then((filePath) => {\nif (filePath) {\n- ServiceManager.getImportService(node.dbType).importSql(filePath[0].fsPath, node)\n+ importService.importSql(filePath[0].fsPath, node)\n}\n});\n},\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/export/exportService.ts",
"new_path": "src/service/export/exportService.ts",
"diff": "@@ -5,6 +5,7 @@ import { Console } from \"../../common/Console\";\nimport { ExportContext, ExportType } from \"./exportContext\";\nimport { ProgressLocation } from \"vscode\";\nimport { ConnectionManager } from \"../connectionManager\";\n+import { DatabaseType } from \"@/common/constants\";\nexport class ExportService {\n@@ -16,7 +17,7 @@ export class ExportService {\nif (filePath) {\ncontext.exportPath = filePath.fsPath;\nif (context.withOutLimit) {\n- context.sql = context.sql.replace(/\\blimit\\b.+/gi, \"\")\n+ context.sql = context.sql.replace(/\\blimit\\s.+/gi, \"\")\n}\nvscode.window.withProgress({ title: `Start exporting data to ${context.type}...`, location: ProgressLocation.Notification }, () => {\nreturn new Promise((resolve) => {\n@@ -80,7 +81,12 @@ export class ExportService {\n}\nprivate exportToJson(context: ExportContext) {\n- fs.writeFileSync(context.exportPath, JSON.stringify(context.rows, (k, v)=> { return v === undefined ? null : v; }, 2));\n+ fs.writeFileSync(context.exportPath, JSON.stringify(context.rows, (k, v:any) => {\n+ if(context.dbOption.dbType==DatabaseType.MONGO_DB && v.indexOf && v.indexOf(\"ObjectID\")!=-1){\n+ return undefined;\n+ }\n+ return v === undefined ? null : v;\n+ }, 2));\n}\nprivate exportToSql(exportContext: ExportContext) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/import/importService.ts",
"new_path": "src/service/import/importService.ts",
"diff": "@@ -25,4 +25,8 @@ export abstract class ImportService {\n}\n+ public filter():any {\n+ return { Sql: ['sql'] };\n+ }\n+\n}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/service/import/mongoImportService.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { Console } from \"@/common/Console\";\n+import { Node } from \"@/model/interface/node\";\n+import { NodeUtil } from \"@/model/nodeUtil\";\n+import { exec } from \"child_process\";\n+import { ImportService } from \"./importService\";\n+var commandExistsSync = require('command-exists').sync;\n+\n+export class MongoImportService extends ImportService {\n+\n+ public importSql(importPath: string, node: Node): void {\n+\n+ if (commandExistsSync('mongoimport')) {\n+ NodeUtil.of(node)\n+ const host = node.usingSSH ? \"127.0.0.1\" : node.host\n+ const port = node.usingSSH ? NodeUtil.getTunnelPort(node.getConnectId()) : node.port;\n+ const command = `mongoimport -h ${host}:${port} --db ${node.database} --jsonArray -c identitycounters --type json ${importPath}`\n+ Console.log(`Executing: ${command}`);\n+ exec(command, (err,stdout,stderr) => {\n+ if (err) {\n+ Console.log(err);\n+ }else if(stderr){\n+ Console.log(stderr);\n+ } else {\n+ Console.log(`Import Success!`);\n+ }\n+ })\n+ } else {\n+ vscode.window.showErrorMessage(\"Command mongoimport not found!\")\n+ }\n+\n+ }\n+\n+ public filter() {\n+ return { json: ['json'] }\n+ }\n+\n+\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix mongo export data fail.
|
141,908
|
22.06.2021 14:45:01
| -28,800
|
994808c157c132b5abe6cb297098410f2dff6e09
|
Fix change connect target fail.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -78,15 +78,19 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\nconst isGlobal = (node as any).isGlobal;\nconst configNotChange = newKey == node.connectionKey && isGlobal == node.global\nif (configNotChange) {\n- node.indent({ command: CommandKey.update })\n+ await node.indent({ command: CommandKey.update })\nreturn;\n- } else if (isGlobal != null) {\n+ }\n+\n// config has change, remove old connection.\n+ if (isGlobal != null) {\nnode.context = isGlobal ? this.context.globalState : this.context.workspaceState\n- await node.indent({ command: CommandKey.delete, connectionKey: node.connectionKey })\n+ await node.indent({ command: CommandKey.delete, connectionKey: node.connectionKey, refresh: false })\n+ node.context = node.global ? this.context.globalState : this.context.workspaceState\n}\n- node.indent({ command: CommandKey.add, connectionKey: newKey })\n+ node.connectionKey=newKey\n+ await node.indent({ command: CommandKey.add, connectionKey: newKey })\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/connectService.ts",
"new_path": "src/service/connect/connectService.ts",
"diff": "@@ -73,7 +73,8 @@ export class ConnectService {\ntry {\nawait this.connect(connectNode)\nawait provider.addConnection(connectNode)\n- handler.emit(\"success\", { message: 'connect success!', key: connectNode.key })\n+ const { key, connectionKey } = connectNode\n+ handler.emit(\"success\", { message: 'connect success!', key, connectionKey })\n} catch (err) {\nif (err?.message) {\nhandler.emit(\"error\", err.message)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/vue/connect/index.vue",
"new_path": "src/vue/connect/index.vue",
"diff": "this.connect.error = false;\nthis.connect.success = true;\nthis.connect.successMessage = res.message;\n+ this.connectionOption.connectionKey = res.connectionKey;\nthis.connectionOption.key = res.key;\n+ this.connectionOption.isGlobal = this.connectionOption.global;\n});\nvscodeEvent.emit(\"route-\" + this.$route.name);\nwindow.onkeydown = (e) => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix change connect target fail.
|
141,908
|
22.06.2021 17:39:09
| -28,800
|
61296d0e7c6b27d3cbf6aade62b8187e405a9e6a
|
Enhance codelen detect.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"es\"\n],\n\"configuration\": \"./syntaxes/es.configuration.json\"\n+ },{\n+ \"id\": \"sql\",\n+ \"extensions\": [ \".sql\", \".dsql\" ],\n+ \"aliases\": [ \"SQL\" ],\n+ \"configuration\": \"./syntaxes/language-configuration.json\"\n}\n],\n\"snippets\": [\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/sqlCodeLensProvider.ts",
"new_path": "src/provider/sqlCodeLensProvider.ts",
"diff": "@@ -31,7 +31,7 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\nfor (var i = 0; i < lineCount; i++) {\nlet col = 0;\nvar line = document.lineAt(i)\n- var text = line.text?.replace(/(--|#).+/, '');\n+ var text = line.text?.replace(/(--|#).+/, '')?.replace(/(\\/\\*).*?(\\*\\/)/g,'');\nif (inBlockComment) {\nconst blockEndMatch = text.match(/.*?(\\*\\/)/)\nif (!blockEndMatch) {\n@@ -41,7 +41,7 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\ntext = text.replace(/.*?(\\*\\/)/, '')\ncol = blockEndMatch[0].length\n} else {\n- const blockComment = text.match(/(\\/\\*).*?(\\*\\/)?/)\n+ const blockComment = text.match(/(\\/\\*)/)\ninBlockComment = blockComment && blockComment[2] == null;\nif (inBlockComment) {\ncontinue;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "@@ -47,6 +47,7 @@ export class ServiceManager {\npublic nosqlProvider: DbTreeDataProvider;\npublic settingService: SettingService;\npublic statusService: StatusService;\n+ public codeLenProvider: SqlCodeLensProvider;\npublic dumpService: DumpService;\nprivate isInit = false;\n@@ -61,9 +62,11 @@ export class ServiceManager {\npublic init(): vscode.Disposable[] {\nif (this.isInit) { return [] }\n+ const codeLenProvider = new SqlCodeLensProvider();\n+ this.codeLenProvider=codeLenProvider;\nconst res: vscode.Disposable[] = [\nvscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormattingProvider()),\n- vscode.languages.registerCodeLensProvider('sql', new SqlCodeLensProvider()),\n+ vscode.languages.registerCodeLensProvider('sql', codeLenProvider),\nvscode.languages.registerHoverProvider('sql', new TableInfoHoverProvider()),\nvscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.', \">\", \"<\", \"=\", \"(\")\n]\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "syntaxes/language-configuration.json",
"diff": "+{\n+ \"comments\": {\n+ \"lineComment\": \"--\",\n+ \"blockComment\": [ \"/*\", \"*/\" ]\n+ },\n+ \"brackets\": [\n+ [\"{\", \"}\"],\n+ [\"[\", \"]\"],\n+ [\"(\", \")\"]\n+ ],\n+ \"autoClosingPairs\": [\n+ [\"{\", \"}\"],\n+ [\"[\", \"]\"],\n+ [\"(\", \")\"],\n+ { \"open\": \"\\\"\", \"close\": \"\\\"\", \"notIn\": [\"string\"] },\n+ { \"open\": \"N'\", \"close\": \"'\", \"notIn\": [\"string\", \"comment\"] },\n+ { \"open\": \"'\", \"close\": \"'\", \"notIn\": [\"string\", \"comment\"] }\n+ ],\n+ \"surroundingPairs\": [\n+ [\"{\", \"}\"],\n+ [\"[\", \"]\"],\n+ [\"(\", \")\"],\n+ [\"\\\"\", \"\\\"\"],\n+ [\"'\", \"'\"],\n+ [\"`\", \"`\"]\n+ ],\n+ \"folding\": {\n+ \"markers\": {\n+ \"start\": \"\\\\/\\\\*\",\n+ \"end\": \"\\\\*\\\\/\"\n+ }\n+ }\n+ // enhancedBrackets:[\n+ // { openTrigger: 'n', open: /begin$/i, closeComplete: 'end', matchCase: true },\n+ // { openTrigger: 'e', open: /case$/i, closeComplete: 'end', matchCase: true },\n+ // { openTrigger: 'n', open: /when$/i, closeComplete: 'then', matchCase: true }\n+ // ],\n+ // noindentBrackets: '()',\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Enhance codelen detect.
|
141,908
|
23.06.2021 10:07:16
| -28,800
|
67d6825012719e782a37521c495ff3a6c7e8f357
|
Fix record history fail.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/nodeUtil.ts",
"new_path": "src/model/nodeUtil.ts",
"diff": "@@ -27,11 +27,7 @@ export abstract class NodeUtil {\nreturn NodeUtil.of( { ...nodes, parent: null, provider: null, context: null, command: null })\n}\nif (nodes instanceof Array) {\n- let tempNodes = []\n- for (const node of nodes) {\n- tempNodes.push(this.removeParent(node))\n- }\n- return tempNodes;\n+ return nodes.map(this.removeParent)\n}\n// if is node object map\nlet result = {};\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/history/historyProvider.ts",
"new_path": "src/provider/history/historyProvider.ts",
"diff": "import { CacheKey } from \"@/common/constants\";\nimport { Global } from \"@/common/global\";\nimport { GlobalState } from \"@/common/state\";\n+import { NodeUtil } from \"@/model/nodeUtil\";\nimport * as vscode from \"vscode\";\nimport { HistoryNode } from \"./historyNode\";\n@@ -30,7 +31,7 @@ export class HistoryProvider implements vscode.TreeDataProvider<HistoryNode>{\nif (glboalHistoryies.length > 100) {\nglboalHistoryies = glboalHistoryies.splice(-1, 1)\n}\n- GlobalState.update(CacheKey.GLOBAL_HISTORY, glboalHistoryies);\n+ GlobalState.update(CacheKey.GLOBAL_HISTORY, NodeUtil.removeParent(glboalHistoryies));\nHistoryProvider._onDidChangeTreeData.fire(null)\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix record history fail.
|
141,908
|
23.06.2021 10:44:54
| -28,800
|
8491c5318c260be9dfb48ec2e0c3118b2f06198d
|
Fix ssh connection cannot identify.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/interface/node.ts",
"new_path": "src/model/interface/node.ts",
"diff": "@@ -53,7 +53,7 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\npublic disable?: boolean;\n/**\n- * context\n+ * using to distingush connectHolder, childCache, elementState\n*/\npublic uid: string;\npublic key: string;\n@@ -101,7 +101,6 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\nthis.port = source.port\nthis.user = source.user\nthis.password = source.password\n- if (!this.database) this.database = source.database\nthis.timezone = source.timezone\nthis.useSSL = source.useSSL\nthis.clientCertPath = source.clientCertPath\n@@ -111,9 +110,6 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\nthis.scheme = source.scheme\nthis.encoding = source.encoding\nthis.showHidden = source.showHidden\n- if (!this.schema) {\n- this.schema = source.schema\n- }\nthis.connectionKey = source.connectionKey\nthis.global = source.global\nthis.dbType = source.dbType\n@@ -132,6 +128,8 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\nthis.authType = source.authType\nthis.disable = source.disable\nthis.includeDatabases = source.includeDatabases\n+ if (!this.database) this.database = source.database\n+ if (!this.schema) this.schema = source.schema\nif (!this.provider) this.provider = source.provider\nif (!this.context) this.context = source.context\n// init dialect\n@@ -141,9 +139,7 @@ export abstract class Node extends vscode.TreeItem implements CopyAble {\nif (this.disable) {\nthis.command = { command: \"mysql.connection.open\", title: \"Open Connection\", arguments: [this] }\n}\n- if(source.key){\n- this.key = source.key;\n- }\n+ this.key = source.key || this.key;\nthis.initUid();\n// init tree state\nthis.collapsibleState = DatabaseCache.getElementState(this)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/interface/sshConfig.ts",
"new_path": "src/model/interface/sshConfig.ts",
"diff": "@@ -14,6 +14,10 @@ export interface SSHConfig {\nprivateKey?: Buffer;\npassphrase?: string;\nalgorithms?: Algorithms;\n+ /**\n+ * only ssh connection\n+ */\n+ key: string;\n}\nexport interface Algorithms {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -71,7 +71,6 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\npublic async addConnection(node: Node) {\n- node.initKey();\nconst newKey = this.getKeyByNode(node)\nnode.context = node.global ? this.context.globalState : this.context.workspaceState\n@@ -140,6 +139,7 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\n} else if (connectInfo.dbType == DatabaseType.REDIS) {\nnode = new RedisConnectionNode(key, connectInfo)\n} else if (connectInfo.dbType == DatabaseType.SSH) {\n+ connectInfo.ssh.key = connectInfo.key\nnode = new SSHConnectionNode(key, connectInfo, connectInfo.ssh, connectInfo.name)\n} else if (connectInfo.dbType == DatabaseType.FTP) {\nnode = new FTPConnectionNode(key, connectInfo)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connect/connectService.ts",
"new_path": "src/service/connect/connectService.ts",
"diff": "@@ -69,11 +69,12 @@ export class ConnectService {\nterminal.show()\n}).on(\"connecting\", async (data) => {\nconst connectionOption = data.connectionOption\n- const connectNode = Util.trim(NodeUtil.of(connectionOption))\n+ const node:Node = Util.trim(NodeUtil.of(connectionOption))\ntry {\n- await this.connect(connectNode)\n- await provider.addConnection(connectNode)\n- const { key, connectionKey } = connectNode\n+ node.initKey();\n+ await this.connect(node)\n+ await provider.addConnection(node)\n+ const { key, connectionKey } = node\nhandler.emit(\"success\", { message: 'connect success!', key, connectionKey })\n} catch (err) {\nif (err?.message) {\n@@ -98,7 +99,8 @@ export class ConnectService {\npublic async connect(connectionNode: Node): Promise<void> {\nif (connectionNode.dbType == DatabaseType.SSH) {\n- await ClientManager.getSSH(connectionNode.ssh, false)\n+ connectionNode.ssh.key=connectionNode.key;\n+ await ClientManager.getSSH(connectionNode.ssh, {withSftp:false})\nreturn;\n}\nConnectionManager.removeConnection(connectionNode.getConnectId())\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/ssh/clientManager.ts",
"new_path": "src/service/ssh/clientManager.ts",
"diff": "@@ -8,13 +8,17 @@ class SSH {\nsftp: SFTPWrapper;\n}\n+class SSHOption {\n+ withSftp: boolean = false;\n+}\n+\nexport class ClientManager {\nprivate static activeClient: { [key: string]: SSH } = {};\n- public static getSSH(sshConfig: SSHConfig,withSftp:boolean=true): Promise<SSH> {\n+ public static getSSH(sshConfig: SSHConfig, option: SSHOption = { withSftp: true }): Promise<SSH> {\n- const key = `${sshConfig.host}_${sshConfig.port}_${sshConfig.username}`;\n+ const key = `${sshConfig.key}_${sshConfig.host}_${sshConfig.port}_${sshConfig.username}`;\nif (this.activeClient[key]) {\nreturn Promise.resolve(this.activeClient[key]);\n}\n@@ -25,7 +29,7 @@ export class ClientManager {\nconst client = new Client();\nreturn new Promise((resolve, reject) => {\nclient.on('ready', () => {\n- if(withSftp){\n+ if (option.withSftp) {\nclient.sftp((err, sftp) => {\nif (err) throw err;\nthis.activeClient[key] = { client, sftp };\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix ssh connection cannot identify.
|
141,908
|
23.06.2021 20:21:09
| -28,800
|
2b9855430c9cb117252193ac47824010089b8f90
|
Fix change active database not show pg and mssql.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/treeDataProvider.ts",
"new_path": "src/provider/treeDataProvider.ts",
"diff": "@@ -175,7 +175,18 @@ export class DbTreeDataProvider implements vscode.TreeDataProvider<Node> {\ncontinue;\n}\n- const schemaList = DatabaseCache.getSchemaListOfConnection(cNode.uid)\n+ let schemaList: Node[];\n+ if (cNode.dbType == DatabaseType.MSSQL || cNode.dbType == DatabaseType.PG) {\n+ const tempList = DatabaseCache.getSchemaListOfConnection(cNode.uid);\n+ schemaList = [];\n+ for (const catalogNode of tempList) {\n+ if (catalogNode instanceof UserGroup) continue;\n+ schemaList.push(...(await catalogNode.getChildren()))\n+ }\n+ } else {\n+ schemaList = DatabaseCache.getSchemaListOfConnection(cNode.uid)\n+ }\n+\nfor (const schemaNode of schemaList) {\nif (schemaNode instanceof UserGroup || schemaNode instanceof CatalogNode) { continue }\nlet uid = `${cNode.label}#${schemaNode.schema}`\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix change active database not show pg and mssql.
|
141,908
|
24.06.2021 10:37:25
| -28,800
|
a1285d969ac43c8516256ffffe7e2f657ab56f18
|
Fix loading data when occur error.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/result/App.vue",
"new_path": "src/vue/result/App.vue",
"diff": "@@ -161,6 +161,7 @@ export default {\nif (!data) return;\nconst response = data.content;\nconsole.log(data);\n+ this.result.transId=response.transId;\nthis.table.loading = false;\nswitch (data.type) {\ncase \"EXPORT_DONE\":\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix loading data when occur error.
|
141,908
|
24.06.2021 10:56:27
| -28,800
|
244b0b522bc383a530b38aa4e385f63890125579
|
Init sql highlight.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"default\": 100,\n\"description\": \"%config.defaultSelectLimit%\"\n},\n+ \"database-client.highlightSQLBlock\": {\n+ \"type\": \"boolean\",\n+ \"default\": false,\n+ \"description\": \"Highlight SQL Code block.\"\n+ },\n\"database-client.preferConnectionName\": {\n\"type\": \"boolean\",\n\"default\": true,\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -26,6 +26,7 @@ export enum CacheKey {\n}\nexport enum ConfigKey {\n+ HIGHLIGHT_SQL_BLOCK = \"highlightSQLBlock\",\nDEFAULT_LIMIT = \"defaultSelectLimit\",\nPREFER_CONNECTION_NAME = \"preferConnectionName\",\nDISABLE_SQL_CODELEN = \"disableSqlCodeLen\",\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/codelen/highlightCreator.ts",
"diff": "+import { ConfigKey } from '@/common/constants';\n+import { Global } from '@/common/global';\n+import * as vscode from 'vscode';\n+import { SqlCodeLensProvider } from \"./sqlCodeLensProvider\";\n+\n+export class HighlightCreator {\n+\n+ private highLightColor: vscode.TextEditorDecorationType;\n+\n+ constructor(private codeLensProvider: SqlCodeLensProvider) {\n+\n+ this.highLightColor = vscode.window.createTextEditorDecorationType({\n+ light: { backgroundColor: '#5B8DDE20' },\n+ dark: { backgroundColor: '#0AAAF420' },\n+ });\n+\n+ vscode.workspace.onDidChangeTextDocument(() => { this.updateDecoration(vscode.window.activeTextEditor) });\n+ vscode.window.onDidChangeActiveTextEditor(this.updateDecoration);\n+ vscode.window.onDidChangeTextEditorSelection((e) => {\n+ const selections = e.selections;\n+ if (e.textEditor.document.languageId != 'sql') {\n+ return\n+ }\n+ if (selections.length > 0 && !selections[0].start.isEqual(selections[0].end)) {\n+ this.updateDecoration(e.textEditor, selections.map(sel => new vscode.Range(sel.start, sel.end)))\n+ } else {\n+ this.updateDecoration(e.textEditor)\n+ }\n+ });\n+ this.updateDecoration(vscode.window.activeTextEditor)\n+\n+ }\n+\n+ async updateDecoration(textEditor: vscode.TextEditor, ranges?: vscode.Range[]) {\n+\n+ if (!Global.getConfig(ConfigKey.HIGHLIGHT_SQL_BLOCK)) {\n+ return;\n+ }\n+\n+ const document = textEditor.document;\n+ if (document.languageId != 'sql') {\n+ return;\n+ }\n+\n+ if (!ranges) {\n+ const range = (await this.codeLensProvider.parseCodeLens(document))\n+ .map(len => len.range)\n+ .find(range => range.contains(textEditor.selection) || range.start.line > textEditor.selection.start.line)\n+ ranges = [range]\n+ }\n+\n+ if (ranges?.length > 0) {\n+ textEditor.setDecorations(this.highLightColor, ranges)\n+ }\n+\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "RENAME",
"old_path": "src/provider/sqlCodeLensProvider.ts",
"new_path": "src/provider/codelen/sqlCodeLensProvider.ts",
"diff": "@@ -5,6 +5,8 @@ import { ConnectionManager } from '@/service/connectionManager';\nimport * as vscode from 'vscode';\nexport class SqlCodeLensProvider implements vscode.CodeLensProvider {\n+\n+\nonDidChangeCodeLenses?: vscode.Event<void>;\nprovideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CodeLens[]> {\nreturn this.parseCodeLens(document)\n@@ -19,14 +21,18 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\npublic parseCodeLensEnhance(document: vscode.TextDocument, current?: vscode.Position): vscode.ProviderResult<vscode.CodeLens[]> | string {\n- // DelimiterHolder.parseBatch(sql, connectionNode.getConnectId())\n-\nif (Global.getConfig<number>(ConfigKey.DISABLE_SQL_CODELEN)) {\nreturn []\n}\nconst delimter = this.getDelimter();\n+ /**\n+ * TODO\n+ * 1. if string include delimter\n+ * 2. if one line include two sql.\n+ */\n+\nconst codeLens: vscode.CodeLens[] = []\nlet start: vscode.Position;\n@@ -36,11 +42,9 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\nconst lineCount = Math.min(document.lineCount, 3000);\nfor (var i = 0; i < lineCount; i++) {\nlet col = 0;\n- var line = document.lineAt(i)\n- var text = line.text?.replace(/(--|#).+/, '')\n+ var originText = document.lineAt(i).text\n+ var text = originText?.replace(/(--|#).+/, '')\n?.replace(/\\/\\*.*?\\*\\//g, '')\n- ?.replace(/'.*?'/g, '')\n- ?.replace(/\".*?\"/g, '')\nif (inBlockComment) {\nconst blockEndMatch = text.match(/.*?\\*\\//)\nif (!blockEndMatch) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "import { CacheKey, DatabaseType } from \"@/common/constants\";\n-import { SqlCodeLensProvider } from \"@/provider/sqlCodeLensProvider\";\n+import { SqlCodeLensProvider } from \"@/provider/codelen/sqlCodeLensProvider\";\nimport * as vscode from \"vscode\";\nimport { ExtensionContext } from \"vscode\";\nimport { FileManager } from \"../common/filesManager\";\n@@ -35,7 +35,7 @@ import { SettingService } from \"./setting/settingService\";\nimport ConnectionProvider from \"@/model/ssh/connectionProvider\";\nimport { SqliTeDialect } from \"./dialect/sqliteDialect\";\nimport { MongoPageService } from \"./page/mongoPageService\";\n-import { HistoryProvider } from \"@/provider/history/historyProvider\";\n+import { HighlightCreator } from \"@/provider/codelen/highlightCreator\";\nexport class ServiceManager {\n@@ -64,6 +64,7 @@ export class ServiceManager {\nif (this.isInit) { return [] }\nconst codeLenProvider = new SqlCodeLensProvider();\nthis.codeLenProvider=codeLenProvider;\n+ new HighlightCreator(codeLenProvider)\nconst res: vscode.Disposable[] = [\nvscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormattingProvider()),\nvscode.languages.registerCodeLensProvider('sql', codeLenProvider),\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Init sql highlight.
|
141,908
|
24.06.2021 11:36:28
| -28,800
|
16e8a5373139428eb968e7a136c39e853a71fdae
|
Version 3.9.1.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.9.1 2021-6-24\n+\n+- Enhance sql detect.\n+- Update run query shortcut.\n+\n# 3.9.0 2021-6-22\n- Support edit connection config.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.9.0\",\n+ \"version\": \"3.9.1\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.9.1.
|
141,908
|
24.06.2021 11:58:49
| -28,800
|
07ab8bfdf55938179d88954c62b3a6fba5d05939
|
Fix query file content gone.
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/database/catalogNode.ts",
"new_path": "src/model/database/catalogNode.ts",
"diff": "+import { FileModel } from \"@/common/filesManager\";\nimport { DbTreeDataProvider } from \"@/provider/treeDataProvider\";\nimport { DatabaseCache } from \"@/service/common/databaseCache\";\nimport { QueryUnit } from \"@/service/queryUnit\";\n@@ -37,7 +38,7 @@ export class CatalogNode extends Node implements CopyAble {\npublic async newQuery() {\n- QueryUnit.showSQLTextDocument(this,'',`${this.database}.sql`)\n+ QueryUnit.showSQLTextDocument(this,'',`${this.database}.sql`,FileModel.APPEND)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/schemaNode.ts",
"new_path": "src/model/database/schemaNode.ts",
"diff": "+import { FileModel } from \"@/common/filesManager\";\nimport { Global } from \"@/common/global\";\nimport * as vscode from \"vscode\";\nimport { DatabaseType, ModelType } from \"../../common/constants\";\n@@ -109,7 +110,7 @@ export class SchemaNode extends Node implements CopyAble {\npublic async newQuery() {\n- QueryUnit.showSQLTextDocument(this, '', `${this.schema}.sql`)\n+ QueryUnit.showSQLTextDocument(this,'',`${this.schema}.sql`,FileModel.APPEND)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/codelen/highlightCreator.ts",
"new_path": "src/provider/codelen/highlightCreator.ts",
"diff": "@@ -37,15 +37,17 @@ export class HighlightCreator {\nreturn;\n}\n- const document = textEditor.document;\n- if (document.languageId != 'sql') {\n+ const document = textEditor?.document;\n+ if (document?.languageId != 'sql') {\nreturn;\n}\nif (!ranges) {\n+ if (!this) return;\nconst range = (await this.codeLensProvider.parseCodeLens(document))\n.map(len => len.range)\n.find(range => range.contains(textEditor.selection) || range.start.line > textEditor.selection.start.line)\n+ if (range)\nranges = [range]\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/queryUnit.ts",
"new_path": "src/service/queryUnit.ts",
"diff": "@@ -151,9 +151,9 @@ export class QueryUnit {\nreturn ServiceManager.instance.codeLenProvider.parseCodeLensEnhance(editor.document, editor.selection.active) as string;\n}\n- public static async showSQLTextDocument(node: Node, sql: string, template = \"template.sql\"): Promise<vscode.TextEditor> {\n+ public static async showSQLTextDocument(node: Node, sql: string, template = \"template.sql\",fileMode?:FileModel): Promise<vscode.TextEditor> {\n- const document = await vscode.workspace.openTextDocument(await FileManager.record(`${node.uid}/${template}`, sql, FileModel.WRITE));\n+ const document = await vscode.workspace.openTextDocument(await FileManager.record(`${node.uid}/${template}`, sql, fileMode));\nreturn await vscode.window.showTextDocument(document);\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix query file content gone.
|
141,908
|
24.06.2021 14:53:06
| -28,800
|
9051a2a7407158ab973e6efd31103021764b880b
|
Sql detect skip white space.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/codelen/sqlCodeLensProvider.ts",
"new_path": "src/provider/codelen/sqlCodeLensProvider.ts",
"diff": "@@ -73,6 +73,7 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\n}\nif (!context.start) {\n+ if (ch.match(/\\s/)) continue;\ncontext.start = new vscode.Position(i, j)\n}\ncontext.sql = context.sql + ch;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Sql detect skip white space.
|
141,908
|
24.06.2021 14:58:43
| -28,800
|
17e6b6ee2d1a44ccf5c736762ba5f2528c4f7642
|
Fix sql detect ignore string.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/codelen/sqlCodeLensProvider.ts",
"new_path": "src/provider/codelen/sqlCodeLensProvider.ts",
"diff": "@@ -45,12 +45,11 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\n// string check\nif (ch == `'`) {\ncontext.inSingleQuoteString = !context.inSingleQuoteString;\n- continue;\n} else if (ch == `\"`) {\ncontext.inDoubleQuoteString = !context.inDoubleQuoteString;\n- continue;\n}\n- if (context.inSingleQuoteString || context.inDoubleQuoteString) continue;\n+ const inString = context.inSingleQuoteString || context.inDoubleQuoteString;\n+ if (!inString) {\n// line comment\nif (ch == '-' && text.charAt(j + 1) == '-') break;\n// block comment start\n@@ -71,6 +70,7 @@ export class SqlCodeLensProvider implements vscode.CodeLensProvider {\ncontext.start = null\ncontinue;\n}\n+ }\nif (!context.start) {\nif (ch.match(/\\s/)) continue;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix sql detect ignore string.
|
141,908
|
24.06.2021 15:05:25
| -28,800
|
53546c8c8c807985b8967f9cfc9647facb2f6a46
|
Add outline provider.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/sqlSymbolProvide.ts",
"diff": "+import * as vscode from 'vscode';\n+import { SqlCodeLensProvider } from './codelen/sqlCodeLensProvider';\n+\n+export class SQLSymbolProvide implements vscode.DocumentSymbolProvider {\n+\n+ constructor(private codeLensProvider: SqlCodeLensProvider) { }\n+\n+ provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[] | vscode.DocumentSymbol[]> {\n+\n+ return (this.codeLensProvider.parseCodeLens(document) as Array<vscode.CodeLens>).map(codeLen => {\n+ return new vscode.SymbolInformation(codeLen.command.arguments[0], vscode.SymbolKind.Function, null,\n+ new vscode.Location(document.uri, codeLen.range.start)\n+ )\n+ })\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "@@ -36,6 +36,7 @@ import ConnectionProvider from \"@/model/ssh/connectionProvider\";\nimport { SqliTeDialect } from \"./dialect/sqliteDialect\";\nimport { MongoPageService } from \"./page/mongoPageService\";\nimport { HighlightCreator } from \"@/provider/codelen/highlightCreator\";\n+import { SQLSymbolProvide } from \"@/provider/sqlSymbolProvide\";\nexport class ServiceManager {\n@@ -68,6 +69,7 @@ export class ServiceManager {\nconst res: vscode.Disposable[] = [\nvscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormattingProvider()),\nvscode.languages.registerCodeLensProvider('sql', codeLenProvider),\n+ vscode.languages.registerDocumentSymbolProvider('sql', new SQLSymbolProvide(codeLenProvider)),\nvscode.languages.registerHoverProvider('sql', new TableInfoHoverProvider()),\nvscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.', \">\", \"<\", \"=\", \"(\")\n]\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add outline provider.
|
141,908
|
24.06.2021 15:19:05
| -28,800
|
4a7e2b781d007a70d8970dc39020af3c8c1e4218
|
Fix pagesize not correct.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/result/query.ts",
"new_path": "src/service/result/query.ts",
"diff": "@@ -112,7 +112,9 @@ export class QueryPage {\n} else {\nawait this.loadColumnList(queryParam);\n}\n- ((queryParam.res)as DataResponse).pageSize=ServiceManager.getPageService(queryParam.connection.dbType).getPageSize(queryParam.res.sql)\n+ const pageSize = ServiceManager.getPageService(queryParam.connection.dbType).getPageSize(queryParam.res.sql);\n+ ((queryParam.res) as DataResponse).pageSize = (queryParam.res.data?.length && queryParam.res.data.length > pageSize)\n+ ? queryParam.res.data.length : pageSize;\nbreak;\ncase MessageType.MESSAGE_BLOCK:\nqueryParam.res.message = `EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}`;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix pagesize not correct.
|
141,908
|
24.06.2021 15:43:20
| -28,800
|
5dc0706b08821ef14b904925b5f35fa93813f826
|
Fix sql detect ignore line break.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/queryUnit.ts",
"new_path": "src/service/queryUnit.ts",
"diff": "@@ -50,6 +50,10 @@ export class QueryUnit {\nsql = this.getSqlFromEditor(connectionNode, queryOption.runAll);\nqueryOption.recordHistory = true;\n}\n+ if(!sql){\n+ vscode.window.showErrorMessage(\"Not sql found!\")\n+ return;\n+ }\nsql = sql.replace(/^\\s*--.+/igm, '').trim();\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix sql detect ignore line break.
|
141,908
|
28.06.2021 20:13:53
| -28,800
|
19f4e4cafa30ca7cc8c29d2f22cdc4d2e1cfc535
|
Add more wrapper keywords.
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/wrapper.js",
"new_path": "src/common/wrapper.js",
"diff": "@@ -7,14 +7,14 @@ export function wrapByDb(origin, databaseType) {\nif (databaseType == 'PostgreSQL') {\nreturn origin.split(\".\").map(text => `\"${text}\"`).join(\".\")\n}\n+ if (databaseType == 'MongoDB') {\n+ return origin;\n+ }\n- if (origin.match(/\\b[-\\s]+\\b/ig) || origin.match(/^( |if|key|desc|length)$/i)) {\n+ if (origin.match(/\\b[-\\s]+\\b/ig) || origin.match(/^( |if|key|desc|length|group|order)$/i)) {\nif (databaseType == 'SqlServer') {\nreturn origin.split(\".\").map(text => `[${text}]`).join(\".\")\n}\n- if (databaseType == 'MongoDB') {\n- return origin;\n- }\nreturn `\\`${origin}\\``;\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add more wrapper keywords.
|
141,908
|
28.06.2021 20:14:29
| -28,800
|
94539152804ceadf2ef3aa132b8f48367fa52a92
|
Remove legacy text from sql.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/queryUnit.ts",
"new_path": "src/service/queryUnit.ts",
"diff": "@@ -151,7 +151,7 @@ export class QueryUnit {\nreturn ServiceManager.instance.codeLenProvider.parseCodeLensEnhance(editor.document, editor.selection.active) as string;\n}\n- public static async showSQLTextDocument(node: Node, sql: string, template = \"template.sql\",fileMode?:FileModel): Promise<vscode.TextEditor> {\n+ public static async showSQLTextDocument(node: Node, sql: string, template = \"template.sql\",fileMode:FileModel=FileModel.WRITE): Promise<vscode.TextEditor> {\nconst document = await vscode.workspace.openTextDocument(await FileManager.record(`${node.uid}/${template}`, sql, fileMode));\nreturn await vscode.window.showTextDocument(document);\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Remove legacy text from sql.
|
141,908
|
28.06.2021 20:42:55
| -28,800
|
6accf6e9aedfe382f7b0a1471d4e2a8d5dc4c86b
|
Support load data local file.
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/mysqlConnection.ts",
"new_path": "src/service/connect/mysqlConnection.ts",
"diff": "@@ -38,7 +38,7 @@ export class MysqlConnection extends IConnection {\nquery(sql: string, callback?: queryCallback): void;\nquery(sql: string, values: any, callback?: queryCallback): void;\nquery(sql: any, values?: any, callback?: any) {\n- return this.con.query(sql, values, callback)\n+ return this.con.query({ sql, infileStreamFactory: (path: string) => fs.createReadStream(path) } as any, values, callback)\n}\nconnect(callback: (err: Error) => void): void {\nthis.con.connect(callback)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support load data local file.
|
141,908
|
29.06.2021 18:26:05
| -28,800
|
2204eb1de9fa4a3b06e7fb354a8bc1650453b661
|
Init tokens.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlBlcok.ts",
"new_path": "src/provider/parser/sqlBlcok.ts",
"diff": "@@ -3,4 +3,11 @@ import { Range } from \"vscode\";\nexport class SQLBlock {\nsql: string;\nrange: Range;\n+ tokens: SQLToken[];\n+}\n+\n+export class SQLToken{\n+ content:string;\n+ type?:string='text';\n+ range: Range;\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlParser.ts",
"new_path": "src/provider/parser/sqlParser.ts",
"diff": "import { DelimiterHolder } from '@/service/common/delimiterHolder';\nimport { ConnectionManager } from '@/service/connectionManager';\nimport * as vscode from 'vscode';\n-import { SQLBlock } from './sqlBlcok';\n+import { SQLBlock, SQLToken } from './sqlBlcok';\nexport class SQLParser {\n@@ -17,6 +17,8 @@ export class SQLParser {\nconst blocks: SQLBlock[] = []\nlet lastLineLength: number;\nconst context = { inSingleQuoteString: false, inDoubleQuoteString: false, inComment: false, sql: '', start: null }\n+ let tokens: SQLToken[] = []\n+ const tokenContext = { word: '', wordStart: null }\nconst lineCount = Math.min(document.lineCount, 5000);\nfor (var i = 0; i < lineCount; i++) {\n@@ -50,21 +52,44 @@ export class SQLParser {\n// check sql end\nif (ch == delimter) {\nif (!context.start) continue;\n+ if (tokenContext.wordStart) {\n+ tokens.push({\n+ content: tokenContext.word,\n+ range: new vscode.Range(tokenContext.wordStart, new vscode.Position(i, j))\n+ })\n+ }\nconst range = new vscode.Range(context.start, new vscode.Position(i, j + 1));\n- const block = { sql: context.sql, range };\n+ const block = { sql: context.sql, range, tokens };\nif (current && (range.contains(current) || range.start.line > current.line)) {\nreturn [block];\n}\nblocks.push(block);\ncontext.sql = ''\ncontext.start = null\n+ tokens = []\n+ tokenContext.wordStart = null;\n+ tokenContext.word = ''\ncontinue;\n}\n}\nif (!context.start) {\n- if (ch.match(/\\s/)) continue;\n+ if (!ch.match(/\\s/)) {\ncontext.start = new vscode.Position(i, j)\n+ if (!tokenContext.wordStart) {\n+ tokenContext.wordStart = new vscode.Position(i, j)\n+ }\n+ tokenContext.word = tokenContext.word + ch\n+ continue;\n+ }\n+ if (tokenContext.wordStart) {\n+ tokens.push({\n+ content: tokenContext.word,\n+ range: new vscode.Range(tokenContext.wordStart, new vscode.Position(i, j))\n+ })\n+ tokenContext.wordStart = null;\n+ tokenContext.word = ''\n+ }\n}\ncontext.sql = context.sql + ch;\n}\n@@ -76,7 +101,7 @@ export class SQLParser {\n// if end withtout delimter\nif (context.start) {\nconst range = new vscode.Range(context.start, new vscode.Position(lineCount, lastLineLength));\n- const block = { sql: context.sql, range };\n+ const block = { sql: context.sql, range, tokens };\nif (current) return [block];\nblocks.push(block)\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Init tokens.
|
141,908
|
29.06.2021 21:34:27
| -28,800
|
1ec87ba0e428d54e7efc73a2d06594114ab8d5ff
|
Redesign auto complete.
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/complete/chain/baseChain.ts",
"diff": "+import { CompletionItem, CompletionItemKind } from \"vscode\";\n+import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n+\n+export abstract class BaseChain implements ComplectionChain {\n+ protected needStop: boolean = false;\n+ abstract getComplection(complectionContext: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]>;\n+ stop(): boolean {\n+ return this.needStop;\n+ }\n+ protected strToComplection(complections: string[], kind: CompletionItemKind = CompletionItemKind.Keyword): CompletionItem[] {\n+ return complections.map(item => {\n+ const complectionItem = new CompletionItem(item + \" \");\n+ complectionItem.kind = kind;\n+ return complectionItem;\n+ })\n+ }\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/complete/chain/ddlChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { CompletionItem } from \"vscode\";\n+import { ComplectionContext } from \"../complectionContext\";\n+import { BaseChain } from \"./baseChain\";\n+\n+export class DDLChain extends BaseChain {\n+\n+ private keywordComplectionItems: vscode.CompletionItem[] = this.strToComplection([\"Table\", \"Procedure\", \"View\", \"Function\", \"Trigger\"])\n+\n+ getComplection(complectionContext: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]> {\n+\n+ const firstToken = complectionContext.tokens[0]?.content?.toLowerCase()\n+ if (!firstToken) return []\n+ const secondToken = complectionContext.tokens[1]?.content?.toLowerCase()\n+\n+ if (['create', 'alter', 'drop'].indexOf(firstToken) == -1) {\n+ return []\n+ }\n+\n+ this.needStop = true;\n+ if (!secondToken) {\n+ return this.keywordComplectionItems;\n+ }\n+\n+ if (firstToken == 'create') {\n+ switch (secondToken) {\n+ case 'table':\n+ return this.strToComplection([\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"REFERENCES\",\n+ \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\", \"FOREIGN\", \"CASCADE\", \"RESTRICT\", \"UNSIGNED\", \"CURRENT_TIMESTAMP\"])\n+ }\n+ } else {\n+ switch (secondToken) {\n+ case 'table': break;\n+ case 'view': break;\n+ case 'procedure': break;\n+ case 'function': break;\n+ case 'trigger': break;\n+ }\n+ }\n+\n+\n+ return [];\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "src/provider/complete/chain/tableCreatingChain.ts",
"new_path": null,
"diff": "-import * as vscode from \"vscode\";\n-import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n-\n-export class TableCreateChain implements ComplectionChain {\n-\n- private tableKeywordList: string[] = [\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"REFERENCES\",\n- \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\", \"FOREIGN\", \"CASCADE\", \"RESTRICT\", \"UNSIGNED\", \"CURRENT_TIMESTAMP\"];\n- private tableKeywordComplectionItems: vscode.CompletionItem[] = [];\n-\n- constructor() {\n-\n- this.tableKeywordList.forEach((keyword) => {\n- const keywordComplectionItem = new vscode.CompletionItem(keyword + \" \");\n- keywordComplectionItem.kind = vscode.CompletionItemKind.Keyword;\n- this.tableKeywordComplectionItems.push(keywordComplectionItem);\n- });\n- }\n-\n- public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n- const sql = complectionContext.currentSql;\n- if (sql && sql.match(/CREATE TABLE/ig)) {\n- return this.tableKeywordComplectionItems;\n- }\n- return null;\n- }\n-\n- public stop(): boolean {\n- return false;\n- }\n-\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/complectionContext.ts",
"new_path": "src/provider/complete/complectionContext.ts",
"diff": "import { Cursor } from \"@/common/constants\";\nimport * as vscode from \"vscode\";\nimport { QueryUnit } from \"../../service/queryUnit\";\n+import { SQLBlock, SQLToken } from \"../parser/sqlBlcok\";\n+import { SQLParser } from \"../parser/sqlParser\";\nexport interface ComplectionChain {\ngetComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]>;\n@@ -15,11 +17,23 @@ export class ComplectionContext {\npublic currentWord: string;\npublic currentSql: string;\npublic currentSqlFull: string;\n+ public position: vscode.Position;\n+ public currentToken: SQLToken;\n+ public tokens: SQLToken[];\n+ public sqlBlock: SQLBlock;\npublic static build(document: vscode.TextDocument, position: vscode.Position): ComplectionContext {\nconst context = new ComplectionContext();\nconst currentSql = this.obtainCursorSql(document, position).trim();\n+ context.position = position;\n+ context.sqlBlock = SQLParser.parseBlockSingle(document, position)\n+ context.tokens=context.sqlBlock.tokens\n+ for (const token of context.sqlBlock.tokens) {\n+ if (token.range.contains(position)) {\n+ context.currentToken = token;\n+ }\n+ }\ncontext.currentSqlFull = this.obtainCursorSql(document, position, document.getText()).trim();\nif (!context.currentSqlFull) { return context; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/completionProvider.ts",
"new_path": "src/provider/complete/completionProvider.ts",
"diff": "@@ -2,13 +2,13 @@ import * as vscode from \"vscode\";\nimport { ColumnChain } from \"./chain/columnChain\";\nimport { KeywordChain } from \"./chain/keywordChain\";\nimport { TableChain } from \"./chain/tableChain\";\n-import { TableCreateChain } from \"./chain/tableCreatingChain\";\nimport { TypeKeywordChain } from \"./chain/typeKeywordChain\";\nimport { ComplectionChain, ComplectionContext } from \"./complectionContext\";\nimport { TableDetecherChain } from \"./chain/tableDetecherChain\";\nimport { FunctionChain } from \"./chain/functionChain\";\nimport { Console } from \"../../common/Console\";\nimport { SchemaChain } from \"./chain/schemaChain\";\n+import { DDLChain } from \"./chain/ddlChain\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\nconstructor() {\n@@ -20,7 +20,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nprivate initDefaultComplectionItem() {\n// The chain is orderly\nthis.fullChain = [\n- new TableCreateChain(),\n+ new DDLChain(),\nnew TypeKeywordChain(),\nnew SchemaChain(),\nnew TableChain(),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlParser.ts",
"new_path": "src/provider/parser/sqlParser.ts",
"diff": "@@ -73,15 +73,7 @@ export class SQLParser {\n}\n}\n- if (!context.start) {\n- if (!ch.match(/\\s/)) {\n- context.start = new vscode.Position(i, j)\n- if (!tokenContext.wordStart) {\n- tokenContext.wordStart = new vscode.Position(i, j)\n- }\n- tokenContext.word = tokenContext.word + ch\n- continue;\n- }\n+ if (ch.match(/\\s/)) {\nif (tokenContext.wordStart) {\ntokens.push({\ncontent: tokenContext.word,\n@@ -90,7 +82,18 @@ export class SQLParser {\ntokenContext.wordStart = null;\ntokenContext.word = ''\n}\n+ context.sql = context.sql + ch;\n+ continue;\n}\n+\n+ if (!tokenContext.wordStart) {\n+ tokenContext.wordStart = new vscode.Position(i, j)\n+ }\n+\n+ if (!context.start) {\n+ context.start = new vscode.Position(i, j)\n+ }\n+ tokenContext.word = tokenContext.word + ch\ncontext.sql = context.sql + ch;\n}\nif (context.sql)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Redesign auto complete.
|
141,908
|
29.06.2021 21:49:08
| -28,800
|
b7106858c37db1c4bdbc8ab9cd03701a5a8cb934
|
Reduce typekey chain.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/baseChain.ts",
"new_path": "src/provider/complete/chain/baseChain.ts",
"diff": "@@ -3,7 +3,7 @@ import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\nexport abstract class BaseChain implements ComplectionChain {\nprotected needStop: boolean = false;\n- abstract getComplection(complectionContext: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]>;\n+ abstract getComplection(context: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]>;\nstop(): boolean {\nreturn this.needStop;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/ddlChain.ts",
"new_path": "src/provider/complete/chain/ddlChain.ts",
"diff": "@@ -6,6 +6,8 @@ import { BaseChain } from \"./baseChain\";\nexport class DDLChain extends BaseChain {\nprivate keywordComplectionItems: vscode.CompletionItem[] = this.strToComplection([\"Table\", \"Procedure\", \"View\", \"Function\", \"Trigger\"])\n+ private typeList: vscode.CompletionItem[] = this.strToComplection([\"INTEGER\", \"CHAR\", \"VARCHAR\", \"DECIMAL\", \"SMALLINT\", \"TINYINT\", \"MEDIUMINT\", \"BIGINT\", \"CHARACTER\",\n+ \"NUMERIC\", \"BIT\", \"INT\", \"FLOAT\", \"DOUBLE\", \"TEXT\", \"SET\", \"BLOB\", \"TIMESTAMP\", \"DATE\", \"TIME\", \"YEAR\", \"DATETIME\"],vscode.CompletionItemKind.Variable);\ngetComplection(complectionContext: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]> {\n@@ -26,14 +28,17 @@ export class DDLChain extends BaseChain {\nswitch (secondToken) {\ncase 'table':\nreturn this.strToComplection([\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"REFERENCES\",\n- \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\", \"FOREIGN\", \"CASCADE\", \"RESTRICT\", \"UNSIGNED\", \"CURRENT_TIMESTAMP\"])\n+ \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\", \"FOREIGN\", \"CASCADE\", \"RESTRICT\", \"UNSIGNED\", \"CURRENT_TIMESTAMP\"]).concat(this.typeList)\n}\n} else {\nswitch (secondToken) {\n- case 'table': break;\n+ case 'table':\n+ return this.typeList;\n+ case 'procedure':\n+ return this.typeList;\n+ case 'function':\n+ return this.typeList;\ncase 'view': break;\n- case 'procedure': break;\n- case 'function': break;\ncase 'trigger': break;\n}\n}\n"
},
{
"change_type": "DELETE",
"old_path": "src/provider/complete/chain/typeKeywordChain.ts",
"new_path": null,
"diff": "-import * as vscode from \"vscode\";\n-import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n-\n-export class TypeKeywordChain implements ComplectionChain {\n-\n- private typeList: string[] = [\"INTEGER\", \"CHAR\", \"VARCHAR\", \"DECIMAL\", \"SMALLINT\", \"TINYINT\", \"MEDIUMINT\", \"BIGINT\",\"CHARACTER\",\n- \"NUMERIC\", \"BIT\", \"INT\", \"FLOAT\", \"DOUBLE\", \"TEXT\", \"SET\", \"BLOB\", \"TIMESTAMP\", \"DATE\", \"TIME\", \"YEAR\", \"DATETIME\"];\n- private typeComplectionItems: vscode.CompletionItem[] = [];\n- private needStop = false;\n-\n- constructor() {\n- this.typeList.forEach((columnType) => {\n- const columnTypeComplectionItem = new vscode.CompletionItem(columnType + \" \");\n- columnTypeComplectionItem.kind = vscode.CompletionItemKind.Variable;\n- this.typeComplectionItems.push(columnTypeComplectionItem);\n- });\n- }\n-\n- public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n- const sql = complectionContext.currentSql;\n- if (sql && sql.match(/CREATE TABLE/ig)) {\n- this.needStop = true;\n- return this.typeComplectionItems;\n- }\n- if (sql && sql.match(/\\b(FUNCTION|PROCEDURE)\\b/ig)) {\n- this.needStop = false;\n- return this.typeComplectionItems;\n- }\n- return null;\n- }\n-\n- public stop(): boolean {\n- return this.needStop;\n- }\n-\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/complectionContext.ts",
"new_path": "src/provider/complete/complectionContext.ts",
"diff": "@@ -5,7 +5,7 @@ import { SQLBlock, SQLToken } from \"../parser/sqlBlcok\";\nimport { SQLParser } from \"../parser/sqlParser\";\nexport interface ComplectionChain {\n- getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]>;\n+ getComplection(context: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]>;\nstop(): boolean;\n}\n@@ -18,6 +18,7 @@ export class ComplectionContext {\npublic currentSql: string;\npublic currentSqlFull: string;\npublic position: vscode.Position;\n+ public previousToken: SQLToken;\npublic currentToken: SQLToken;\npublic tokens: SQLToken[];\npublic sqlBlock: SQLBlock;\n@@ -29,11 +30,16 @@ export class ComplectionContext {\ncontext.position = position;\ncontext.sqlBlock = SQLParser.parseBlockSingle(document, position)\ncontext.tokens=context.sqlBlock.tokens\n- for (const token of context.sqlBlock.tokens) {\n+ for (let i = 0; i < context.tokens.length; i++) {\n+ const token = context.tokens[i];\nif (token.range.contains(position)) {\ncontext.currentToken = token;\n+ if(context.tokens[i-1]){\n+ context.previousToken = context.tokens[i-1];\n}\n}\n+\n+ }\ncontext.currentSqlFull = this.obtainCursorSql(document, position, document.getText()).trim();\nif (!context.currentSqlFull) { return context; }\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/completionProvider.ts",
"new_path": "src/provider/complete/completionProvider.ts",
"diff": "@@ -2,7 +2,6 @@ import * as vscode from \"vscode\";\nimport { ColumnChain } from \"./chain/columnChain\";\nimport { KeywordChain } from \"./chain/keywordChain\";\nimport { TableChain } from \"./chain/tableChain\";\n-import { TypeKeywordChain } from \"./chain/typeKeywordChain\";\nimport { ComplectionChain, ComplectionContext } from \"./complectionContext\";\nimport { TableDetecherChain } from \"./chain/tableDetecherChain\";\nimport { FunctionChain } from \"./chain/functionChain\";\n@@ -21,7 +20,6 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\n// The chain is orderly\nthis.fullChain = [\nnew DDLChain(),\n- new TypeKeywordChain(),\nnew SchemaChain(),\nnew TableChain(),\nnew ColumnChain(),\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Reduce typekey chain.
|
141,908
|
29.06.2021 21:57:39
| -28,800
|
2e9ff5d684be6fd622538121258d65159a0cd6fa
|
Update schema detect rule.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/schemaChain.ts",
"new_path": "src/provider/complete/chain/schemaChain.ts",
"diff": "@@ -3,19 +3,22 @@ import { SchemaNode } from \"@/model/database/schemaNode\";\nimport * as vscode from \"vscode\";\nimport { UserGroup } from \"../../../model/database/userGroup\";\nimport { ConnectionManager } from \"../../../service/connectionManager\";\n-import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n+import { ComplectionContext } from \"../complectionContext\";\n+import { BaseChain } from \"./baseChain\";\n-export class SchemaChain implements ComplectionChain {\n+export class SchemaChain extends BaseChain {\n- public getComplection(complectionContext: ComplectionContext) {\n- if (complectionContext.preWord && complectionContext.preWord.match(/into|from|update|table|join/ig)) {\n- return this.generateDatabaseComplectionItem();\n- }\n+ public getComplection(context: ComplectionContext) {\n+ const firstToken = context.tokens[0]?.content?.toLowerCase()\n+ if (!firstToken || ['select', 'insert', 'update', 'delete', 'call', 'execute'].indexOf(firstToken) == -1) {\nreturn null;\n}\n+ const previous = context.previousToken?.content?.toLowerCase()\n+ if (previous && previous.match(/into|from|update|table|join/ig)) {\n+ return this.generateDatabaseComplectionItem();\n+ }\n- public stop(): boolean {\n- return false;\n+ return null;\n}\nprivate async generateDatabaseComplectionItem() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/complectionContext.ts",
"new_path": "src/provider/complete/complectionContext.ts",
"diff": "@@ -38,7 +38,9 @@ export class ComplectionContext {\ncontext.previousToken = context.tokens[i - 1];\n}\n}\n-\n+ }\n+ if (!context.previousToken && context.tokens.length > 1) {\n+ context.previousToken = context.tokens[context.tokens.length - 1]\n}\ncontext.currentSqlFull = this.obtainCursorSql(document, position, document.getText()).trim();\nif (!context.currentSqlFull) { return context; }\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Update schema detect rule.
|
141,908
|
29.06.2021 22:20:49
| -28,800
|
611d71b67bec640b8abf77102469c9c71ec027fb
|
Redsign token detect.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlBlcok.ts",
"new_path": "src/provider/parser/sqlBlcok.ts",
"diff": "-import { Range } from \"vscode\";\n+import { Position, Range } from \"vscode\";\nexport class SQLBlock {\nsql: string;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlParser.ts",
"new_path": "src/provider/parser/sqlParser.ts",
"diff": "@@ -2,6 +2,7 @@ import { DelimiterHolder } from '@/service/common/delimiterHolder';\nimport { ConnectionManager } from '@/service/connectionManager';\nimport * as vscode from 'vscode';\nimport { SQLBlock, SQLToken } from './sqlBlcok';\n+import { TokenContext } from './tokenContext';\nexport class SQLParser {\n@@ -17,8 +18,7 @@ export class SQLParser {\nconst blocks: SQLBlock[] = []\nlet lastLineLength: number;\nconst context = { inSingleQuoteString: false, inDoubleQuoteString: false, inComment: false, sql: '', start: null }\n- let tokens: SQLToken[] = []\n- const tokenContext = { word: '', wordStart: null }\n+ let tokenContext = new TokenContext()\nconst lineCount = Math.min(document.lineCount, 5000);\nfor (var i = 0; i < lineCount; i++) {\n@@ -52,48 +52,26 @@ export class SQLParser {\n// check sql end\nif (ch == delimter) {\nif (!context.start) continue;\n- if (tokenContext.wordStart) {\n- tokens.push({\n- content: tokenContext.word,\n- range: new vscode.Range(tokenContext.wordStart, new vscode.Position(i, j))\n- })\n- }\n+ tokenContext.endToken(i, j)\nconst range = new vscode.Range(context.start, new vscode.Position(i, j + 1));\n- const block = { sql: context.sql, range, tokens };\n+ const block = { sql: context.sql, range, tokens: tokenContext.tokens };\nif (current && (range.contains(current) || range.start.line > current.line)) {\nreturn [block];\n}\nblocks.push(block);\ncontext.sql = ''\ncontext.start = null\n- tokens = []\n- tokenContext.wordStart = null;\n- tokenContext.word = ''\n+ tokenContext = new TokenContext()\ncontinue;\n}\n}\n- if (ch.match(/\\s/)) {\n- if (tokenContext.wordStart) {\n- tokens.push({\n- content: tokenContext.word,\n- range: new vscode.Range(tokenContext.wordStart, new vscode.Position(i, j))\n- })\n- tokenContext.wordStart = null;\n- tokenContext.word = ''\n- }\n- context.sql = context.sql + ch;\n- continue;\n- }\n-\n- if (!tokenContext.wordStart) {\n- tokenContext.wordStart = new vscode.Position(i, j)\n- }\n+ tokenContext.appendChar(i, j, ch)\nif (!context.start) {\n+ if (ch.match(/\\s/)) continue;\ncontext.start = new vscode.Position(i, j)\n}\n- tokenContext.word = tokenContext.word + ch\ncontext.sql = context.sql + ch;\n}\nif (context.sql)\n@@ -104,7 +82,7 @@ export class SQLParser {\n// if end withtout delimter\nif (context.start) {\nconst range = new vscode.Range(context.start, new vscode.Position(lineCount, lastLineLength));\n- const block = { sql: context.sql, range, tokens };\n+ const block = { sql: context.sql, range, tokens: tokenContext.tokens };\nif (current) return [block];\nblocks.push(block)\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/parser/tokenContext.ts",
"diff": "+import { timeStamp } from \"node:console\";\n+import { Position, Range } from \"vscode\";\n+import { SQLToken } from \"./sqlBlcok\";\n+\n+export class TokenContext {\n+ tokens: SQLToken[] = []; word: string = ''; wordStart: Position;\n+\n+ public appendChar(i: number, j: number, char: string) {\n+ if (char.match(/\\s/)) {\n+ this.endToken(i, j)\n+ } else if (char.match(/[\\.,]/)) {\n+ this.endToken(i, j)\n+ this.addChar(i, j, char)\n+ this.endToken(i, j + 1)\n+ } else {\n+ this.addChar(i, j, char)\n+ }\n+ }\n+\n+ private addChar(i: number, j: number, char: string) {\n+ if (!this.wordStart) {\n+ this.wordStart = new Position(i, j)\n+ }\n+ this.word = this.word + char;\n+ }\n+\n+ public endToken(i: number, j: number) {\n+ if (!this.wordStart) return;\n+ this.tokens.push({\n+ content: this.word,\n+ range: new Range(this.wordStart, new Position(i, j))\n+ })\n+ this.word = '';\n+ this.wordStart = null;\n+ }\n+\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Redsign token detect.
|
141,908
|
30.06.2021 09:33:04
| -28,800
|
4b0208b1420039d00ac342840e59013c2030b181
|
Support detect table token.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlParser.ts",
"new_path": "src/provider/parser/sqlParser.ts",
"diff": "@@ -74,8 +74,10 @@ export class SQLParser {\n}\ncontext.sql = context.sql + ch;\n}\n- if (context.sql)\n+ if (context.sql){\ncontext.sql = context.sql + '\\n';\n+ tokenContext.appendChar(i, text.length, '\\n')\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/tokenContext.ts",
"new_path": "src/provider/parser/tokenContext.ts",
"diff": "-import { timeStamp } from \"node:console\";\nimport { Position, Range } from \"vscode\";\nimport { SQLToken } from \"./sqlBlcok\";\nexport class TokenContext {\n- tokens: SQLToken[] = []; word: string = ''; wordStart: Position;\n+ tokens: SQLToken[] = [];\n+ preivous: SQLToken = null;\n+ word: string = '';\n+ wordStart: Position;\npublic appendChar(i: number, j: number, char: string) {\nif (char.match(/\\s/)) {\nthis.endToken(i, j)\n- } else if (char.match(/[\\.,]/)) {\n- this.endToken(i, j)\n- this.addChar(i, j, char)\n- this.endToken(i, j + 1)\n+ } else if (char == '.') {\n+ const pre = this.preivous;\n+ this.splitToken(i, j, char)\n+ if (pre?.content?.match(/into|from|update|table|join/i)) {\n+ this.getToken(-1).type = 'schema_dot'\n+ this.getToken(-2).type = 'schema'\n+ }\n+ } else if (char.match(/[\\(\\),]/)) {\n+ this.splitToken(i, j, char)\n} else {\nthis.addChar(i, j, char)\n}\n@@ -24,14 +31,38 @@ export class TokenContext {\nthis.word = this.word + char;\n}\n+ public splitToken(i: number, j: number, divide: string) {\n+ this.endToken(i, j)\n+ this.addChar(i, j, divide)\n+ this.endToken(i, j + 1)\n+ }\npublic endToken(i: number, j: number) {\nif (!this.wordStart) return;\n- this.tokens.push({\n- content: this.word,\n+ const token: SQLToken = {\n+ content: this.word, type: this.getType(),\nrange: new Range(this.wordStart, new Position(i, j))\n- })\n+ };\n+ this.preivous = token;\n+ this.tokens.push(token)\nthis.word = '';\nthis.wordStart = null;\n}\n+ private getToken(index: number): SQLToken {\n+ if (index > 0) return this.tokens[index];\n+ return this.tokens[this.tokens.length + index]\n+ }\n+\n+ private getType(): string {\n+ if (this.preivous) {\n+ if (\n+ (this.preivous.content.match(/into|from|update|table|join/i)) ||\n+ (this.preivous.type == 'schema_dot')\n+ ) {\n+ return 'table'\n+ }\n+ }\n+ return 'text'\n+ }\n+\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support detect table token.
|
141,908
|
30.06.2021 10:22:40
| -28,800
|
b25353849e734d09223fbf2a1f786ae40627c9b7
|
Support detect subquery.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlBlcok.ts",
"new_path": "src/provider/parser/sqlBlcok.ts",
"diff": "@@ -4,6 +4,7 @@ export class SQLBlock {\nsql: string;\nrange: Range;\ntokens: SQLToken[];\n+ scopes: Range[] = [];\n}\nexport class SQLToken {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/sqlParser.ts",
"new_path": "src/provider/parser/sqlParser.ts",
"diff": "@@ -54,7 +54,7 @@ export class SQLParser {\nif (!context.start) continue;\ntokenContext.endToken(i, j)\nconst range = new vscode.Range(context.start, new vscode.Position(i, j + 1));\n- const block = { sql: context.sql, range, tokens: tokenContext.tokens };\n+ const block: SQLBlock = { sql: context.sql, range, tokens: tokenContext.tokens, scopes: tokenContext.scopes };\nif (current && (range.contains(current) || range.start.line > current.line)) {\nreturn [block];\n}\n@@ -84,7 +84,7 @@ export class SQLParser {\n// if end withtout delimter\nif (context.start) {\nconst range = new vscode.Range(context.start, new vscode.Position(lineCount, lastLineLength));\n- const block = { sql: context.sql, range, tokens: tokenContext.tokens };\n+ const block: SQLBlock = { sql: context.sql, range, tokens: tokenContext.tokens, scopes: tokenContext.scopes };\nif (current) return [block];\nblocks.push(block)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/tokenContext.ts",
"new_path": "src/provider/parser/tokenContext.ts",
"diff": "@@ -3,24 +3,42 @@ import { SQLToken } from \"./sqlBlcok\";\nexport class TokenContext {\ntokens: SQLToken[] = [];\n- preivous: SQLToken = null;\n+ scopes: Range[] = [];\nword: string = '';\nwordStart: Position;\n+ bracketStart: SQLToken[]=[];\npublic appendChar(i: number, j: number, char: string) {\nif (char.match(/\\s/)) {\nthis.endToken(i, j)\n- } else if (char == '.') {\n- const pre = this.preivous;\n+ return;\n+ }\n+\n+ switch (char) {\n+ case \".\":\n+ const pre = this.getToken(-1);\nthis.splitToken(i, j, char)\nif (pre?.content?.match(/into|from|update|table|join/i)) {\nthis.getToken(-1).type = 'schema_dot'\nthis.getToken(-2).type = 'schema'\n}\n- } else if (char.match(/[\\(\\),]/)) {\n- this.splitToken(i, j, char)\n- } else {\n- this.addChar(i, j, char)\n+ break;\n+ case \",\":\n+ this.splitToken(i, j, char);\n+ break;\n+ case \"(\":\n+ const token = this.splitToken(i, j, char);\n+ this.bracketStart.push(token)\n+ break;\n+ case \")\":\n+ const startToken = this.bracketStart.pop()\n+ const endToken = this.splitToken(i, j, char);\n+ if (startToken?.type == 'bracketStart') {\n+ this.scopes.push(new Range(startToken.range.start, endToken.range.end))\n+ }\n+ break;\n+ default:\n+ this.addChar(i, j, char);\n}\n}\n@@ -31,21 +49,21 @@ export class TokenContext {\nthis.word = this.word + char;\n}\n- public splitToken(i: number, j: number, divide: string) {\n+ public splitToken(i: number, j: number, divide: string): SQLToken {\nthis.endToken(i, j)\nthis.addChar(i, j, divide)\n- this.endToken(i, j + 1)\n+ return this.endToken(i, j + 1)\n}\n- public endToken(i: number, j: number) {\n+ public endToken(i: number, j: number): SQLToken {\nif (!this.wordStart) return;\nconst token: SQLToken = {\ncontent: this.word, type: this.getType(),\nrange: new Range(this.wordStart, new Position(i, j))\n};\n- this.preivous = token;\nthis.tokens.push(token)\nthis.word = '';\nthis.wordStart = null;\n+ return token;\n}\nprivate getToken(index: number): SQLToken {\n@@ -54,13 +72,14 @@ export class TokenContext {\n}\nprivate getType(): string {\n- if (this.preivous) {\n- if (\n- (this.preivous.content.match(/into|from|update|table|join/i)) ||\n- (this.preivous.type == 'schema_dot')\n- ) {\n+ const preivous = this.getToken(-1);\n+ if (preivous) {\n+ if ((preivous.content.match(/into|from|update|table|join/i)) || (preivous.type == 'schema_dot')) {\nreturn 'table'\n}\n+ if (preivous.content == '(' && this.word.toLowerCase() == 'select') {\n+ preivous.type = 'bracketStart'\n+ }\n}\nreturn 'text'\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support detect subquery.
|
141,908
|
30.06.2021 10:36:06
| -28,800
|
4eed994ade83a1b0d95bad0d8b4f971c7d071509
|
Enhance ddl detect.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/ddlChain.ts",
"new_path": "src/provider/complete/chain/ddlChain.ts",
"diff": "+import { ModelType } from \"@/common/constants\";\nimport * as vscode from \"vscode\";\nimport { CompletionItem } from \"vscode\";\nimport { ComplectionContext } from \"../complectionContext\";\n+import { NodeFinder } from \"../nodeFinder\";\nimport { BaseChain } from \"./baseChain\";\nexport class DDLChain extends BaseChain {\n@@ -9,12 +11,15 @@ export class DDLChain extends BaseChain {\nprivate typeList: vscode.CompletionItem[] = this.strToComplection([\"INTEGER\", \"CHAR\", \"VARCHAR\", \"DECIMAL\", \"SMALLINT\", \"TINYINT\", \"MEDIUMINT\", \"BIGINT\", \"CHARACTER\",\n\"NUMERIC\", \"BIT\", \"INT\", \"FLOAT\", \"DOUBLE\", \"TEXT\", \"SET\", \"BLOB\", \"TIMESTAMP\", \"DATE\", \"TIME\", \"YEAR\", \"DATETIME\"], vscode.CompletionItemKind.Variable);\n- getComplection(complectionContext: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]> {\n+ async getComplection(complectionContext: ComplectionContext): Promise<CompletionItem[]> {\nconst firstToken = complectionContext.tokens[0]?.content?.toLowerCase()\nif (!firstToken) return []\nconst secondToken = complectionContext.tokens[1]?.content?.toLowerCase()\n+ const isCreate = firstToken == 'create';\n+ const isAlter = firstToken == 'alter';\n+ const isDrop = firstToken == 'drop';\nif (['create', 'alter', 'drop'].indexOf(firstToken) == -1) {\nreturn []\n}\n@@ -24,22 +29,37 @@ export class DDLChain extends BaseChain {\nreturn this.keywordComplectionItems;\n}\n- if (firstToken == 'create') {\n+ if (isCreate) {\nswitch (secondToken) {\ncase 'table':\nreturn this.strToComplection([\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"REFERENCES\",\n\"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\", \"FOREIGN\", \"CASCADE\", \"RESTRICT\", \"UNSIGNED\", \"CURRENT_TIMESTAMP\"]).concat(this.typeList)\n}\n} else {\n+ let modelType: ModelType;\nswitch (secondToken) {\ncase 'table':\n- return this.typeList;\n+ modelType = ModelType.TABLE;\n+ break;\ncase 'procedure':\n- return this.typeList;\n+ modelType = ModelType.PROCEDURE;\n+ break;\ncase 'function':\n- return this.typeList;\n- case 'view': break;\n- case 'trigger': break;\n+ modelType = ModelType.FUNCTION;\n+ break;\n+ case 'view':\n+ modelType = ModelType.VIEW;\n+ break;\n+ case 'trigger':\n+ modelType = ModelType.TRIGGER;\n+ break;\n+ }\n+ if (modelType) {\n+ if (isAlter) {\n+ return this.nodeToComplection(await NodeFinder.findNodes(null, modelType), vscode.CompletionItemKind.Function).concat(this.typeList)\n+ } else {\n+ return this.nodeToComplection(await NodeFinder.findNodes(null, modelType), vscode.CompletionItemKind.Function)\n+ }\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/tableChain.ts",
"new_path": "src/provider/complete/chain/tableChain.ts",
"diff": "@@ -19,10 +19,6 @@ export class TableChain implements ComplectionChain {\n} else {\nreturn await this.generateTableComplectionItem(complectionContext.preWord);\n}\n-\n- }\n- if (complectionContext.preWord && complectionContext.preWord.match(/\\b(into|from|update|table|join)\\b/ig)) {\n- return await this.generateTableComplectionItem();\n}\nreturn null;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/completionProvider.ts",
"new_path": "src/provider/complete/completionProvider.ts",
"diff": "@@ -10,15 +10,13 @@ import { SchemaChain } from \"./chain/schemaChain\";\nimport { DDLChain } from \"./chain/ddlChain\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\n- constructor() {\n- this.initDefaultComplectionItem();\n- }\n-\n- private fullChain: ComplectionChain[];\n- private initDefaultComplectionItem() {\n- // The chain is orderly\n- this.fullChain = [\n+ /**\n+ * The chain is orderly\n+ * @returns\n+ */\n+ private completeChain() {\n+ return [\nnew DDLChain(),\nnew SchemaChain(),\nnew TableChain(),\n@@ -38,7 +36,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nconst context = ComplectionContext.build(document, position);\nlet completionItemList = [];\n- for (const chain of this.fullChain) {\n+ for (const chain of this.completeChain()) {\ntry {\nconst tempComplection = await chain.getComplection(context);\nif (tempComplection != null) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Enhance ddl detect.
|
141,908
|
30.06.2021 16:07:30
| -28,800
|
489f063b6f0e91059a46ab858ba501dbc820520d
|
Enhance DML detect.
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/baseChain.ts",
"new_path": "src/provider/complete/chain/baseChain.ts",
"diff": "import { Node } from \"@/model/interface/node\";\n-import { CompletionItem, CompletionItemKind } from \"vscode\";\n+import { CompletionItem, CompletionItemKind, SnippetString } from \"vscode\";\nimport { ComplectionChain, ComplectionContext } from \"../complectionContext\";\nexport abstract class BaseChain implements ComplectionChain {\nprotected needStop: boolean = false;\n+ protected functionList: CompletionItem[] = this.strToComplection([\"CHAR_LENGTH\", \"CONCAT\", \"NOW\", \"DATE_ADD\", \"DATE_SUB\", \"MAX\", \"COUNT\", \"MIN\", \"SUM\", \"AVG\", \"LENGTH\", \"IF\", \"IFNULL\", \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\", \"TRIM\", \"LAST_INSERT_ID\", \"MOD\"], CompletionItemKind.Function, '($1)');\nabstract getComplection(context: ComplectionContext): CompletionItem[] | Promise<CompletionItem[]>;\nstop(): boolean {\nreturn this.needStop;\n@@ -11,16 +12,18 @@ export abstract class BaseChain implements ComplectionChain {\nprotected requestStop() {\nthis.needStop = true;\n}\n- protected strToComplection(complections: string[], kind: CompletionItemKind = CompletionItemKind.Keyword): CompletionItem[] {\n+ protected strToComplection(complections: string[], kind: CompletionItemKind = CompletionItemKind.Keyword, span = ' '): CompletionItem[] {\nreturn complections.map(item => {\n- const completionItem = new CompletionItem(item + \" \");\n+ const completionItem = new CompletionItem(item + ' ');\n+ completionItem.insertText = new SnippetString(item + span);\ncompletionItem.kind = kind;\nreturn completionItem;\n})\n}\n- protected nodeToComplection(nodes: Node[], kind: CompletionItemKind): CompletionItem[] {\n+ protected nodeToComplection(nodes: Node[], kind: CompletionItemKind, span = ' '): CompletionItem[] {\nreturn nodes.map(item => {\n- const completionItem = new CompletionItem(item.label + \" \");\n+ const completionItem = new CompletionItem(item.label + ' ');\n+ completionItem.insertText = new SnippetString(item + span);\ncompletionItem.kind = kind;\ncompletionItem.insertText = item.wrap(item.label);\nreturn completionItem;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/columnChain.ts",
"new_path": "src/provider/complete/chain/columnChain.ts",
"diff": "@@ -8,13 +8,13 @@ import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\nexport class ColumnChain implements ComplectionChain {\nprivate needStop = true;\n- public async getComplection(complectionContext: ComplectionContext): Promise<vscode.CompletionItem[]> {\n+ public async getComplection(context: ComplectionContext): Promise<vscode.CompletionItem[]> {\n- if (complectionContext.preChart === \".\") {\n- let subComplectionItems = await this.generateColumnComplectionItem(complectionContext.preWord);\n+ if (context.preChart === \".\") {\n+ let subComplectionItems = await this.generateColumnComplectionItem(context.preWord);\nif (subComplectionItems != null && subComplectionItems.length > 0) { this.needStop = true }\n- const tableReg = new RegExp(Pattern.TABLE_PATTERN + \"(?=\\\\s*\\\\b\" + complectionContext.preWord + \"\\\\b)\", \"ig\");\n- let result = tableReg.exec(complectionContext.currentSqlFull);\n+ const tableReg = new RegExp(Pattern.TABLE_PATTERN + \"(?=\\\\s*\\\\b\" + context.preWord + \"\\\\b)\", \"ig\");\n+ let result = tableReg.exec(context.currentSqlFull);\nwhile (result != null && subComplectionItems.length === 0) {\nsubComplectionItems = await this.generateColumnComplectionItem(\nUtil.getTableName(result[0], Pattern.TABLE_PATTERN)\n@@ -23,26 +23,23 @@ export class ColumnChain implements ComplectionChain {\nif (subComplectionItems.length > 0) {\nbreak;\n}\n- result = tableReg.exec(complectionContext.currentSqlFull);\n+ result = tableReg.exec(context.currentSqlFull);\n}\nreturn subComplectionItems;\n}\n- if (complectionContext.currentSqlFull.match(/\\bwhere\\b/ig)) {\n- const updateTableName = Util.getTableName(complectionContext.currentSql, Pattern.TABLE_PATTERN)\n+ const condtionTokens = context.sqlBlock.tokens.filter(token => token.content.match(/\\b(on|where)\\b/i) ||\n+ (token.content == 'set' && context.position.isAfter(token.range.end)))\n+ for (const token of condtionTokens) {\n+ if (context.position.isAfter(token.range.end)) {\n+ const updateTableName = Util.getTableName(context.currentSql, Pattern.TABLE_PATTERN)\nif (updateTableName) {\nthis.needStop = false;\nreturn await this.generateColumnComplectionItem(updateTableName);\n}\n}\n-\n- const dmlTableName = Util.getTableName(complectionContext.currentSql, Pattern.DML_PATTERN)\n- if (dmlTableName) {\n- this.needStop = complectionContext.currentSql.match(/\\binsert\\b/ig) != null;\n- return await this.generateColumnComplectionItem(dmlTableName);\n}\n-\nreturn null;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/ddlChain.ts",
"new_path": "src/provider/complete/chain/ddlChain.ts",
"diff": "@@ -56,9 +56,9 @@ export class DDLChain extends BaseChain {\n}\nif (modelType) {\nif (isAlter) {\n- return this.nodeToComplection(await NodeFinder.findNodes(null, modelType), vscode.CompletionItemKind.Function).concat(this.typeList)\n+ return this.nodeToComplection(await NodeFinder.findNodes(null, null, modelType), vscode.CompletionItemKind.Function).concat(this.typeList)\n} else {\n- return this.nodeToComplection(await NodeFinder.findNodes(null, modelType), vscode.CompletionItemKind.Function)\n+ return this.nodeToComplection(await NodeFinder.findNodes(null, null, modelType), vscode.CompletionItemKind.Function)\n}\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/complete/chain/dmlChain.ts",
"diff": "+import { ModelType } from \"@/common/constants\";\n+import * as vscode from \"vscode\";\n+import { ComplectionContext } from \"../complectionContext\";\n+import { NodeFinder } from \"../nodeFinder\";\n+import { BaseChain } from \"./baseChain\";\n+\n+export class DMLChain extends BaseChain {\n+\n+ public async getComplection(context: ComplectionContext) {\n+ const firstToken = context.tokens[0]?.content?.toLowerCase()\n+ if (!firstToken || ['select', 'insert', 'update', 'delete', 'call', 'execute'].indexOf(firstToken) == -1) {\n+ return null;\n+ }\n+ const previous = context.previousToken?.content?.toLowerCase()\n+ if (previous && previous.match(/into|from|update|table|join/i)) {\n+ this.requestStop()\n+ return this.nodeToComplection(await NodeFinder.findNodes(null, null, ModelType.SCHEMA), vscode.CompletionItemKind.Folder).concat(\n+ this.nodeToComplection(await NodeFinder.findNodes(null, null, ModelType.TABLE, ModelType.VIEW), vscode.CompletionItemKind.Function)\n+ );\n+ }\n+\n+ switch (firstToken) {\n+ case 'select':\n+ return this.functionList;\n+ case 'update':\n+ return this.functionList;\n+ case 'delete':\n+ // delete from [table] where $1\n+ if (context.sqlBlock.tokens.find(token => token.content == 'where' && context.position.isAfter(token.range.end))) {\n+ return this.functionList;\n+ }\n+ case 'insert':\n+ if (firstToken == 'insert') {\n+ // insert into [table] ($1)\n+ if (context.sqlBlock.scopes.find(scope => scope.contains(context.position))) {\n+ const tables = context.sqlBlock.tokens.filter(token => token.type == 'table');\n+ if (tables.length == 0) return null;\n+ this.requestStop()\n+ return Promise.all(tables.map(async tableToken => {\n+ return this.nodeToComplection(await NodeFinder.findNodes(null, tableToken.content, ModelType.COLUMN), vscode.CompletionItemKind.Field)\n+ })).then(nodes => nodes.flat())\n+ }\n+ // insert into [table] ([columns]) values ($1)\n+ if (context.sqlBlock.tokens.find(token => token.content == 'values' && context.position.isAfter(token.range.end))) {\n+ this.requestStop()\n+ return this.functionList;\n+ }\n+ }\n+ break;\n+ }\n+\n+ return null;\n+ }\n+\n+}\n+\n"
},
{
"change_type": "DELETE",
"old_path": "src/provider/complete/chain/functionChain.ts",
"new_path": null,
"diff": "-import * as vscode from \"vscode\";\n-import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n-\n-export class FunctionChain implements ComplectionChain {\n- private functionList: string[] = [\"CHAR_LENGTH\", \"CONCAT\", \"NOW\", \"DATE_ADD\", \"DATE_SUB\", \"MAX\", \"COUNT\", \"MIN\", \"SUM\", \"AVG\", \"LENGTH\", \"IF\", \"IFNULL\",\n- \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\", \"TRIM\",\"LAST_INSERT_ID\",\"MOD\"];\n- private functionComplectionItems: vscode.CompletionItem[] = [];\n- constructor() {\n- this.functionList.forEach((keyword) => {\n- const functionComplectionItem = new vscode.CompletionItem(keyword + \" \");\n- functionComplectionItem.kind = vscode.CompletionItemKind.Function;\n- functionComplectionItem.insertText = new vscode.SnippetString(keyword + \"($1)\");\n- this.functionComplectionItems.push(functionComplectionItem);\n- });\n- }\n- public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n- if ((complectionContext.preWord && complectionContext.preWord.match(/\\b(select|HAVING|where|and|,|=|<|>)\\b/ig)) ||\n- (complectionContext.currentWord && complectionContext.currentWord.match(/(<|>|,|=)$/))) {\n-\n- return this.functionComplectionItems;\n- }\n-\n- return null;\n- }\n-\n- public stop(): boolean {\n- return false;\n- }\n-\n-}\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "src/provider/complete/chain/schemaChain.ts",
"new_path": null,
"diff": "-import { ModelType } from \"@/common/constants\";\n-import * as vscode from \"vscode\";\n-import { ComplectionContext } from \"../complectionContext\";\n-import { NodeFinder } from \"../nodeFinder\";\n-import { BaseChain } from \"./baseChain\";\n-\n-export class SchemaChain extends BaseChain {\n-\n- public async getComplection(context: ComplectionContext) {\n- const firstToken = context.tokens[0]?.content?.toLowerCase()\n- if (!firstToken || ['select', 'insert', 'update', 'delete', 'call', 'execute'].indexOf(firstToken) == -1) {\n- return null;\n- }\n- const previous = context.previousToken?.content?.toLowerCase()\n- if (previous && previous.match(/into|from|update|table|join/ig)) {\n- this.requestStop()\n- return this.nodeToComplection(await NodeFinder.findNodes(null, ModelType.SCHEMA), vscode.CompletionItemKind.Folder).concat(\n- this.nodeToComplection(await NodeFinder.findNodes(null, ModelType.TABLE, ModelType.VIEW), vscode.CompletionItemKind.Function)\n- );\n- }\n-\n- return null;\n- }\n-\n-}\n-\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/chain/tableChain.ts",
"new_path": "src/provider/complete/chain/tableChain.ts",
"diff": "import { Node } from \"@/model/interface/node\";\nimport { TableGroup } from \"@/model/main/tableGroup\";\nimport { ViewGroup } from \"@/model/main/viewGroup\";\n-import { DatabaseCache } from \"@/service/common/databaseCache\";\nimport * as vscode from \"vscode\";\nimport { DatabaseType, ModelType } from \"../../../common/constants\";\nimport { TableNode } from \"../../../model/main/tableNode\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/complectionContext.ts",
"new_path": "src/provider/complete/complectionContext.ts",
"diff": "@@ -39,7 +39,7 @@ export class ComplectionContext {\n}\n}\n}\n- if (!context.previousToken && context.tokens.length > 1) {\n+ if (!context.previousToken && context.tokens.length > 0) {\ncontext.previousToken = context.tokens[context.tokens.length - 1]\n}\ncontext.currentSqlFull = this.obtainCursorSql(document, position, document.getText()).trim();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/completionProvider.ts",
"new_path": "src/provider/complete/completionProvider.ts",
"diff": "import * as vscode from \"vscode\";\n+import { Console } from \"../../common/Console\";\nimport { ColumnChain } from \"./chain/columnChain\";\n+import { DDLChain } from \"./chain/ddlChain\";\n+import { DMLChain } from \"./chain/dmlChain\";\nimport { KeywordChain } from \"./chain/keywordChain\";\nimport { TableChain } from \"./chain/tableChain\";\n-import { ComplectionChain, ComplectionContext } from \"./complectionContext\";\nimport { TableDetecherChain } from \"./chain/tableDetecherChain\";\n-import { FunctionChain } from \"./chain/functionChain\";\n-import { Console } from \"../../common/Console\";\n-import { SchemaChain } from \"./chain/schemaChain\";\n-import { DDLChain } from \"./chain/ddlChain\";\n+import { ComplectionContext } from \"./complectionContext\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\n@@ -18,10 +17,9 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nprivate completeChain() {\nreturn [\nnew DDLChain(),\n- new SchemaChain(),\n+ new DMLChain(),\nnew TableChain(),\nnew ColumnChain(),\n- new FunctionChain(),\nnew TableDetecherChain(),\nnew KeywordChain(),\n];\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/complete/nodeFinder.ts",
"new_path": "src/provider/complete/nodeFinder.ts",
"diff": "@@ -10,13 +10,13 @@ import { ConnectionManager } from \"@/service/connectionManager\";\nexport class NodeFinder {\n- public static async findNodes(suffix: string, ...types: ModelType[]): Promise<Node[]> {\n+ public static async findNodes(schema: string, table: string, ...types: ModelType[]): Promise<Node[]> {\nlet lcp = ConnectionManager.tryGetConnection();\nif (!lcp) return [];\n- if (suffix) {\n- const connectcionid = lcp.getConnectId({ schema: suffix, withSchema: true });\n+ if (schema) {\n+ const connectcionid = lcp.getConnectId({ schema: schema, withSchema: true });\nlcp = Node.nodeCache[connectcionid]\nif (!lcp) return []\n}\n@@ -25,6 +25,9 @@ export class NodeFinder {\nconst groupNodes = await lcp.getChildren();\nfor (const type of types) {\nswitch (type) {\n+ case ModelType.COLUMN:\n+ nodeList.push(...(await lcp.getByRegion(table)?.getChildren()))\n+ break;\ncase ModelType.SCHEMA:\nif (!lcp || !lcp?.parent?.getChildren) { break; }\nconst databaseNodes = await lcp.parent.getChildren()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/parser/tokenContext.ts",
"new_path": "src/provider/parser/tokenContext.ts",
"diff": "@@ -77,7 +77,9 @@ export class TokenContext {\nif ((preivous.content.match(/into|from|update|table|join/i)) || (preivous.type == 'schema_dot')) {\nreturn 'table'\n}\n- if (preivous.content == '(' && this.word.toLowerCase() == 'select') {\n+ if (preivous.content == '(' &&\n+ (this.word.toLowerCase() == 'select' || this.getToken(-2)?.type=='table')\n+ ) {\npreivous.type = 'bracketStart'\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "tsconfig.json",
"new_path": "tsconfig.json",
"diff": "\"outDir\": \"out\",\n\"lib\": [\n\"es6\",\n- \"es2017\"\n+ \"es2017\",\n+ \"es2019\"\n],\n\"sourceMap\": true,\n\"baseUrl\": \".\",\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Enhance DML detect.
|
141,908
|
02.07.2021 17:18:09
| -28,800
|
ca5d7fcca33e8d88ff23ccb1beaebd68eb2d35c5
|
Version 3.9.3.
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "# CHANGELOG\n+# 3.9.3 2021-7-2\n+\n+- Better sql complection.\n+- Fix multi line space ignored.\n+\n# 3.9.2 2021-6-24\n- Enhance sql detect.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.9.2\",\n+ \"version\": \"3.9.3\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.9.3.
|
141,908
|
04.07.2021 20:03:36
| -28,800
|
f481e83d831f99004abb2b9af95b13caba6447ea
|
Version 3.9.4.
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-client2\",\n\"displayName\": \"MySQL\",\n\"description\": \"Database Client for vscode\",\n- \"version\": \"3.9.3\",\n+ \"version\": \"3.9.4\",\n\"publisher\": \"cweijan\",\n\"icon\": \"resources/logo.png\",\n\"engines\": {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Version 3.9.4.
|
141,908
|
06.07.2021 20:20:41
| -28,800
|
c6fda77b5ff3e062c075af53960c8cf80f9ae556
|
Support copy on ssh terminal.
|
[
{
"change_type": "MODIFY",
"old_path": "src/vue/xterm/index.vue",
"new_path": "src/vue/xterm/index.vue",
"diff": "const container = document.getElementById('terminal-container');\nterminal.onKey(async e => {\nconst event = e.domEvent;\n- if ((event.code == \"KeyC\" && event.ctrlKey && !event.altKey && !event.shiftKey) ||\n- (event.code == \"KeyV\" && event.ctrlKey && !event.altKey && !event.shiftKey) ||\n+ if (event.code == \"KeyC\" && event.ctrlKey && !event.altKey && !event.shiftKey) {\n+ if (terminal.hasSelection()) {\n+ document.execCommand('copy')\n+ }\n+ return;\n+ } else if ((event.code == \"KeyV\" && event.ctrlKey && !event.altKey && !event.shiftKey) ||\n(event.code == \"KeyF\" && event.ctrlKey && !event.altKey && !event.shiftKey)\n) {\nreturn;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support copy on ssh terminal.
|
141,908
|
06.07.2021 21:11:00
| -28,800
|
16a14a5cadd8679f31afd002b03a9b90dba83c78
|
Fix elastic search using ssh tunnel fail
|
[
{
"change_type": "MODIFY",
"old_path": "src/service/connect/esConnection.ts",
"new_path": "src/service/connect/esConnection.ts",
"diff": "@@ -12,7 +12,7 @@ export class EsConnection extends IConnection {\nconstructor(private opt: Node) {\nsuper()\nif (compareVersions(extPackage.version, '3.6.6') === 1) {\n- this.url = `${opt.scheme}://${opt.host}`\n+ this.url = opt.usingSSH ? `${opt.scheme}://${opt.host}:${opt.port}` : `${opt.scheme}://${opt.host}`\n} else {\nthis.url = `${opt.scheme}://${opt.host}:${opt.port}`\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/connectionManager.ts",
"new_path": "src/service/connectionManager.ts",
"diff": "@@ -105,6 +105,7 @@ export class ConnectionManager {\nlet connectOption = connectionNode;\nif (connectOption.usingSSH) {\nconnectOption = await this.tunnelService.createTunnel(connectOption, (err) => {\n+ reject(err?.message || err?.errno);\nif (err.errno == 'EADDRINUSE') { return; }\nthis.alivedConnection[key] = null\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/tunnel/sshTunnelService.ts",
"new_path": "src/service/tunnel/sshTunnelService.ts",
"diff": "@@ -3,6 +3,7 @@ import { Node } from '../../model/interface/node';\nimport { Console } from '../../common/Console';\nimport { existsSync } from 'fs';\nimport * as portfinder from 'portfinder'\n+import { DatabaseType } from '@/common/constants';\nexport class SSHTunnelService {\n@@ -15,23 +16,23 @@ export class SSHTunnelService {\n}\n}\n- public createTunnel(connectionNode: Node, errorCallback: (error) => void): Promise<Node> {\n+ public createTunnel(node: Node, errorCallback: (error) => void): Promise<Node> {\nreturn new Promise(async (resolve, reject) => {\n- const ssh = connectionNode.ssh\n- const key = connectionNode.getConnectId();\n+ const ssh = node.ssh\n+ const key = node.getConnectId();\nif (this.tunelMark[key]) {\n- resolve({ ...connectionNode, host: \"127.0.0.1\", port: this.tunelMark[key].tunnelPort } as Node)\n+ resolve({ ...node, host: \"127.0.0.1\", port: this.tunelMark[key].tunnelPort } as Node)\nreturn;\n}\nconst port = await portfinder.getPortPromise();\n- connectionNode.ssh.tunnelPort = port\n+ node.ssh.tunnelPort = port\nconst config = {\nusername: ssh.username,\npassword: ssh.password,\nhost: ssh.host,\nport: ssh.port,\n- dstHost: connectionNode.host,\n- dstPort: connectionNode.port,\n+ dstHost: node.host,\n+ dstPort: node.port,\nlocalHost: '127.0.0.1',\nlocalPort: port,\nalgorithms: ssh.algorithms,\n@@ -43,6 +44,12 @@ export class SSHTunnelService {\nreturn null\n})()\n};\n+ if (node.dbType == DatabaseType.ES) {\n+ config.dstHost = node.host.split(\":\")[0]\n+ // config.dstPort= (node.host.split(\":\")[1] || '80') as any\n+ const portStr = node.host.split(\":\")[1] || '80'\n+ config.dstPort = parseInt(portStr)\n+ }\nconst localTunnel = tunnel(config, (error, server) => {\nthis.tunelMark[key] = { tunnel: localTunnel, tunnelPort: port }\n@@ -50,7 +57,7 @@ export class SSHTunnelService {\ndelete this.tunelMark[key]\nerrorCallback(error)\n}\n- resolve({ ...connectionNode, host: \"127.0.0.1\", port } as Node)\n+ resolve({ ...node, host: \"127.0.0.1\", port } as Node)\n});\nlocalTunnel.on('error', (err) => {\nConsole.log('Ssh tunel occur error : ' + err);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/tunnel/tunnel-ssh.js",
"new_path": "src/service/tunnel/tunnel-ssh.js",
"diff": "@@ -36,15 +36,15 @@ function createServer(config) {\nnetConnection.on('error', server.emit.bind(server, 'error'));\nnetConnection.on('close', function () {\nconnectionCount--;\n- if (connectionCount === 0) {\n- if (!config.keepAlive) {\n- setTimeout(function () {\n- if (connectionCount === 0) {\n- server.close();\n- }\n- }, 2);\n- }\n- }\n+ // if (connectionCount === 0) {\n+ // if (!config.keepAlive) {\n+ // setTimeout(function () {\n+ // if (connectionCount === 0) {\n+ // server.close();\n+ // }\n+ // }, 2);\n+ // }\n+ // }\n});\nserver.emit('netConnection', netConnection, server);\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fix elastic search using ssh tunnel fail #243.
|
141,908
|
08.07.2021 20:35:56
| -28,800
|
b63a744e118d0349d71a08ce646607aa91805e97
|
Support dump with mysqldump
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/util.ts",
"new_path": "src/common/util.ts",
"diff": "@@ -3,10 +3,11 @@ import { join } from \"path\";\nimport * as vscode from \"vscode\";\nimport { Position, TextDocument } from \"vscode\";\nimport { Confirm, Constants, DatabaseType } from \"./constants\";\n-import { Global } from \"./global\";\n-import { compare } from 'compare-versions';\n+import { exec } from \"child_process\";\nimport { wrapByDb } from \"./wrapper.js\";\nimport { GlobalState } from \"./state\";\n+import { Console } from \"./Console\";\n+import { close } from \"node:fs\";\nexport class Util {\n@@ -130,4 +131,25 @@ export class Util {\nreturn this.supportColor;\n}\n+ public static execute(command: string): Promise<void> {\n+ return new Promise((res, rej) => {\n+ let hasTrigger = false;\n+ exec(command, (err, stdout, stderr) => {\n+ if (hasTrigger) return;\n+ hasTrigger = true;\n+ if (err) {\n+ rej(err)\n+ } else if (stderr) {\n+ rej(stderr)\n+ } else {\n+ res(null)\n+ }\n+ }).on(\"exit\", (code) => {\n+ if (hasTrigger) return;\n+ hasTrigger = true;\n+ code ? rej(null) : res(null);\n+ })\n+ })\n+ }\n+\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -110,13 +110,13 @@ export function activate(context: vscode.ExtensionContext) {\nnew DiffService().startDiff(serviceManager.provider);\n},\n\"mysql.data.export\": (node: SchemaNode | TableNode) => {\n- serviceManager.dumpService.dump(node, true)\n+ ServiceManager.getDumpService(node.dbType).dump(node, true)\n},\n\"mysql.struct.export\": (node: SchemaNode | TableNode) => {\n- serviceManager.dumpService.dump(node, false)\n+ ServiceManager.getDumpService(node.dbType).dump(node, false)\n},\n\"mysql.document.generate\": (node: SchemaNode | TableNode) => {\n- serviceManager.dumpService.generateDocument(node)\n+ ServiceManager.getDumpService(node.dbType).generateDocument(node)\n},\n\"mysql.data.import\": (node: SchemaNode | ConnectionNode) => {\nconst importService=ServiceManager.getImportService(node.dbType);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/dump/dumpService.ts",
"new_path": "src/service/dump/dumpService.ts",
"diff": "@@ -58,7 +58,7 @@ export class DumpService {\n}\n- protected dumpData(node: Node, dumpFilePath: string, withData: boolean, items: vscode.QuickPickItem[]): void {\n+ private dumpData(node: Node, dumpFilePath: string, withData: boolean, items: vscode.QuickPickItem[]): void {\nconst tables = items.filter(item => item.description == ModelType.TABLE).map(item => item.label)\nconst viewList = items.filter(item => item.description == ModelType.VIEW).map(item => item.label)\n@@ -77,7 +77,7 @@ export class DumpService {\noption.dump.data = false;\n}\nUtil.process(`Doing backup ${node.host}_${node.schema}...`, (done) => {\n- mysqldump(option, node).then(() => {\n+ this.processDump(option, node).then(() => {\nvscode.window.showInformationMessage(`Backup ${node.getHost()}_${node.schema} success!`, 'open').then(action => {\nif (action == 'open') {\nvscode.commands.executeCommand('vscode.open', vscode.Uri.file(dumpFilePath));\n@@ -88,6 +88,10 @@ export class DumpService {\n}\n+ protected processDump(option: Options, node: Node): Promise<void> {\n+ return mysqldump(option, node);\n+ }\n+\npublic async generateDocument(node: Node) {\nconst exportSqlName = `${format('yyyy-MM-dd_hhmmss', new Date())}_${node.schema}.docx`;\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/service/dump/mysqlDumpService.ts",
"diff": "+import { Console } from \"@/common/Console\";\n+import { Util } from \"@/common/util\";\n+import { Node } from \"@/model/interface/node\";\n+import { NodeUtil } from \"@/model/nodeUtil\";\n+import { DumpService } from \"./dumpService\";\n+import { Options } from \"./mysql/main\";\n+var commandExistsSync = require('command-exists').sync;\n+\n+export class MysqlDumpService extends DumpService {\n+\n+ protected processDump(option: Options, node: Node): Promise<void> {\n+\n+ if (commandExistsSync('mysqldump')) {\n+ NodeUtil.of(node)\n+ const host = node.usingSSH ? \"127.0.0.1\" : node.host\n+ const port = node.usingSSH ? NodeUtil.getTunnelPort(node.getConnectId()) : node.port;\n+ const command = `mysqldump -h ${host} -P ${port} -u ${node.user} -p${node.password} ${node.schema}>${option.dumpToFile}`\n+ Console.log(`Executing: ${command}`);\n+ return Util.execute(command)\n+ }\n+\n+ return super.processDump(option, node);\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/service/serviceManager.ts",
"new_path": "src/service/serviceManager.ts",
"diff": "@@ -37,6 +37,7 @@ import { SqliTeDialect } from \"./dialect/sqliteDialect\";\nimport { MongoPageService } from \"./page/mongoPageService\";\nimport { HighlightCreator } from \"@/provider/codelen/highlightCreator\";\nimport { SQLSymbolProvide } from \"@/provider/sqlSymbolProvide\";\n+import { MysqlDumpService } from \"./dump/mysqlDumpService\";\nexport class ServiceManager {\n@@ -49,7 +50,6 @@ export class ServiceManager {\npublic settingService: SettingService;\npublic statusService: StatusService;\npublic codeLenProvider: SqlCodeLensProvider;\n- public dumpService: DumpService;\nprivate isInit = false;\nconstructor(private readonly context: ExtensionContext) {\n@@ -115,10 +115,18 @@ export class ServiceManager {\nprivate initMysqlService() {\nthis.settingService = new MysqlSettingService();\n- this.dumpService = new DumpService();\nthis.statusService = new MysqlStatusService()\n}\n+ public static getDumpService(dbType: DatabaseType): DumpService {\n+ if (!dbType) dbType = DatabaseType.MYSQL\n+ switch (dbType) {\n+ case DatabaseType.MYSQL:\n+ return new MysqlDumpService()\n+ }\n+ return new DumpService()\n+ }\n+\npublic static getImportService(dbType: DatabaseType) {\nif (!dbType) dbType = DatabaseType.MYSQL\nswitch (dbType) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support dump with mysqldump
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.