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
|
---|---|---|---|---|---|---|---|---|---|
675,375 |
16.06.2017 13:26:07
| -7,200 |
a27b779cb8518b0629f333ba155fd1e222d93adc
|
Change testThaliMobile Can get data from all participants so if connection attempt will fail, we wont end the tests.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "var ThaliMobile = require('thali/NextGeneration/thaliMobile');\nvar ThaliMobileNativeWrapper = require('thali/NextGeneration/thaliMobileNativeWrapper');\nvar ThaliMobileNative = require('thali/NextGeneration/thaliMobileNative');\n+var thaliMobileNativeTestUtils = require('../lib/thaliMobileNativeTestUtils.js');\nvar thaliConfig = require('thali/NextGeneration/thaliConfig');\nvar tape = require('../lib/thaliTape');\nvar testUtils = require('../lib/testUtils.js');\n@@ -308,7 +309,6 @@ test('can get the network status', function (t) {\n});\n});\n-\ntest('peerAvailabilityChanged - peer added/removed to/from cache (native)',\nfunction (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n@@ -2255,6 +2255,7 @@ test('can get data from all participants',\n}\nremainingParticipants[participant.uuid] = participantState.notRunning;\n});\n+\nsetupDiscoveryAndFindPeers(t, router, function (peer, done) {\n// Try to get data only from non-TCP peers so that the test\n// works the same way on desktop on CI where Wifi is blocked\n@@ -2263,10 +2264,10 @@ test('can get data from all participants',\nreturn;\n}\n- ThaliMobile.getPeerHostInfo(peer.peerIdentifier, peer.connectionType)\n- .then(function (peerHostInfo) {\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\nreturn testUtils.get(\n- peerHostInfo.hostAddress, peerHostInfo.portNumber,\n+ '127.0.0.1', connection.listeningPort,\nuuidPath, pskIdentity, pskKey\n).catch(function () {\n// Ignore request failures. After peer listener recreating we are\n@@ -2274,6 +2275,10 @@ test('can get data from all participants',\nreturn null;\n});\n})\n+ .catch(function (err) {\n+ // Ignore connection failure, probably zombie advertiser\n+ return null;\n+ })\n.then(function (uuid) {\nif (uuid === null) {\nreturn;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Change testThaliMobile Can get data from all participants so if connection attempt will fail, we wont end the tests.
|
675,375 |
20.06.2017 09:26:34
| -7,200 |
84808304f8051f9750311a4830e4583f21619a95
|
Do not kill connections manually in teardown in testThaliManagerCoordinated.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js",
"new_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js",
"diff": "@@ -7,7 +7,6 @@ if (!tape.coordinated) {\nvar testUtils = require('../lib/testUtils.js');\nvar logger = require('../lib/testLogger.js')('testThaliManagerCoordinated');\n-var platform = require('thali/NextGeneration/utils/platform');\nvar crypto = require('crypto');\nvar Promise = require('bluebird');\n@@ -18,8 +17,6 @@ var thaliConfig = require('thali/NextGeneration/thaliConfig');\nvar ThaliManager = require('thali/NextGeneration/thaliManager');\nvar ThaliPeerPoolDefault =\nrequire('thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault');\n-var thaliMobileNativeWrapper =\n- require('thali/NextGeneration/thaliMobileNativeWrapper');\n// Public key for local device should be passed\n// to the tape 'setup' as 'tape.data'.\n@@ -35,41 +32,19 @@ PouchDB = testUtils.getLevelDownPouchDb();\nvar thaliManager;\n-var peerIdsToBeClosed = [];\n-\nvar test = tape({\nsetup: function (t) {\n- thaliMobileNativeWrapper.emitter.on('nonTCPPeerAvailabilityChangedEvent', nonTcpPeerAvailableChangedListener);\nt.data = publicKeyForLocalDevice.toJSON();\nt.end();\n},\nteardown: function (t) {\nPromise.resolve()\n- .then(function () {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n-\n- });\n- })\n.then(function () {\nif (thaliManager) {\nreturn thaliManager.stop();\n}\n})\n.then(function () {\n- if (!platform.isAndroid) {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n- Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call disconnect in teardown'\n- );\n- });\n- });\n- }\n- peerIdsToBeClosed = [];\n-\n- thaliMobileNativeWrapper.emitter.removeListener('nonTCPPeerAvailabilityChangedEvent',\n- nonTcpPeerAvailableChangedListener);\nt.end();\n});\n},\n@@ -80,10 +55,6 @@ var test = tape({\nteardownTimeout: 3 * 60 * 1000\n});\n-function nonTcpPeerAvailableChangedListener(peer) {\n- peerIdsToBeClosed.push(peer.peerIdentifier);\n-}\n-\nvar DEBUG = false;\nfunction debug() {\nif (!DEBUG) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Do not kill connections manually in teardown in testThaliManagerCoordinated.
|
675,371 |
20.06.2017 11:59:01
| -7,200 |
d7519e712b5476dd37d739636e21b4ce7bb03fa1
|
Added skip function to allow a test to be skipped over
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testTests.js",
"new_path": "test/www/jxcore/bv_tests/testTests.js",
"diff": "@@ -29,6 +29,29 @@ test('another', function (t) {\nt.end();\n});\n+test.skip('skip', function (t) {\n+ t.ok(false, 'Should not execute skipped test');\n+ t.end();\n+});\n+\n+test.skip('another skip', function () { return false; },\n+ function (t) {\n+ t.ok(false, 'Should not execute skipped test');\n+ t.end();\n+});\n+\n+test.skip('skip with skip function', function () { return true; },\n+ function (t) {\n+ t.ok(false, 'Should not execute skipped test');\n+ t.end();\n+});\n+\n+test('skip function', function () { return true; },\n+ function (t) {\n+ t.ok(false, 'Should not execute skipped test');\n+ t.end();\n+});\n+\nvar testObject = {\ntestSpyMethod: function() {\nlogger.debug('test spy method for global sinon sansbox');\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/SimpleTape.js",
"new_path": "test/www/jxcore/lib/SimpleTape.js",
"diff": "@@ -40,8 +40,10 @@ function SimpleThaliTape (options) {\n// test('name', ...) -> 'this.addTest('name, ...)'\n// test.only('name', ...) -> 'this.only('name, ...)'\n+ // test.skip('name', ...) -> 'this.skip('name, ...)'\nthis._handler = this.addTest.bind(this);\nthis._handler.only = this.only.bind(this);\n+ this._handler.skip = this.skip.bind(this);\nreturn this._handler;\n}\n@@ -69,6 +71,17 @@ SimpleThaliTape.prototype.only = function () {\nreturn this.addTest.apply(this, arguments);\n};\n+SimpleThaliTape.prototype.skip = function (name, canBeSkipped, fun) {\n+ if (!fun) {\n+ fun = canBeSkipped;\n+ }\n+ canBeSkipped = function () {\n+ return true;\n+ };\n+\n+ return this.addTest.apply(this, [name, canBeSkipped, fun]);\n+};\n+\n// 'canBeSkipped' is optional argument.\nSimpleThaliTape.prototype.addTest = function (name, canBeSkipped, fun) {\nassert(\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Added skip function to allow a test to be skipped over
|
675,371 |
20.06.2017 19:53:57
| -7,200 |
15b391b748cd46f88e50ee9d279dbb8c8602e2d7
|
Update after CR
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/SimpleTape.js",
"new_path": "test/www/jxcore/lib/SimpleTape.js",
"diff": "@@ -71,15 +71,8 @@ SimpleThaliTape.prototype.only = function () {\nreturn this.addTest.apply(this, arguments);\n};\n-SimpleThaliTape.prototype.skip = function (name, canBeSkipped, fun) {\n- if (!fun) {\n- fun = canBeSkipped;\n- }\n- canBeSkipped = function () {\n- return true;\n- };\n-\n- return this.addTest.apply(this, [name, canBeSkipped, fun]);\n+SimpleThaliTape.prototype.skip = function (name, fun) {\n+ return this.addTest.apply(this, [name, function () { return true; }, fun]);\n};\n// 'canBeSkipped' is optional argument.\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update after CR
|
675,371 |
20.06.2017 21:02:18
| -7,200 |
265139272e29f321c6e079e313a288085ee30811
|
Removed not needed tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testTests.js",
"new_path": "test/www/jxcore/bv_tests/testTests.js",
"diff": "@@ -40,18 +40,6 @@ test.skip('another skip', function () { return false; },\nt.end();\n});\n-test.skip('skip with skip function', function () { return true; },\n- function (t) {\n- t.ok(false, 'Should not execute skipped test');\n- t.end();\n-});\n-\n-test('skip function', function () { return true; },\n- function (t) {\n- t.ok(false, 'Should not execute skipped test');\n- t.end();\n-});\n-\nvar testObject = {\ntestSpyMethod: function() {\nlogger.debug('test spy method for global sinon sansbox');\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Removed not needed tests
|
675,375 |
23.06.2017 09:07:59
| -7,200 |
af4ea1b19c3cd4475f329e7e587710eb3a0cb1a7
|
Fix calling t.end before assertion in testThaliMobileNative
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -1208,6 +1208,8 @@ function (t) {\ntest('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\nvar callCount = 0;\n+ var promises = [];\n+\nMobile('discoveryAdvertisingStateUpdateNonTCP').registerToNative(\nfunction (state) {\ncallCount++;\n@@ -1217,34 +1219,54 @@ test('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\n'discoveryActive should be false');\nt.equal(state.advertisingActive, false,\n'advertisingActive should be true');\n+\n+ promises.push(new Promise(function (resolve, reject) {\nMobile('startUpdateAdvertisingAndListening').callNative(4242, function (err) {\n- t.notOk(err, 'Can call startUpdateAdvertisingAndListening without error');\n+ !err ? resolve() : reject('Can call startUpdateAdvertisingAndListening without error');\n});\n+ }));\nbreak;\ncase 2:\nt.equal(state.discoveryActive, true,\n'discoveryActive should be false');\nt.equal(state.advertisingActive, true,\n'advertisingActive should be true');\n+\n+ promises.push(new Promise(function (resolve, reject) {\nMobile('stopListeningForAdvertisements').callNative(function (err) {\n- t.notOk(err, 'Can call stopListeningForAdvertisements without error');\n+ if (!err) {\n+ return resolve();\n+ } else {\n+ return reject('Can call stopListeningForAdvertisements without error')\n+ }\n});\n+ }));\nbreak;\ncase 3:\nt.equal(state.discoveryActive, false,\n'discoveryActive should be false');\nt.equal(state.advertisingActive, true,\n'advertisingActive should be true');\n+\n+ promises.push(new Promise(function (resolve, reject) {\nMobile('stopAdvertisingAndListening').callNative(function (err) {\n- t.notOk(err, 'Can call stopAdvertisingAndListening without error');\n+ !err ? resolve() : reject('Can call stopAdvertisingAndListening without error');\n});\n+ }));\nbreak;\ncase 4:\nt.equal(state.discoveryActive, false,\n'discoveryActive should be false');\nt.equal(state.advertisingActive, false,\n'advertisingActive should be true');\n+\n+ Promise.all(promises)\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\nt.end();\n+ });\nbreak;\ndefault:\nbreak;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix calling t.end before assertion in testThaliMobileNative
|
675,375 |
23.06.2017 10:55:43
| -7,200 |
fecb9987d449f041f9c88bbf712be1d6b5986355
|
Change if statement to short one
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -1234,11 +1234,7 @@ test('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\npromises.push(new Promise(function (resolve, reject) {\nMobile('stopListeningForAdvertisements').callNative(function (err) {\n- if (!err) {\n- return resolve();\n- } else {\n- return reject('Can call stopListeningForAdvertisements without error')\n- }\n+ !err ? resolve() : reject('Can call stopListeningForAdvertisements without error');\n});\n}));\nbreak;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Change if statement to short one
|
675,375 |
26.06.2017 14:46:42
| -7,200 |
abbee73aefcb266b1c8f7404fe32b570b4e89bf3
|
CR Suggestions. Remove not needed variables.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testHttp.js",
"new_path": "test/www/jxcore/bv_tests/testHttp.js",
"diff": "@@ -21,26 +21,26 @@ var test = tape({\nt.end();\n},\nteardown: function (t) {\n+ Promise.resolve()\n+ .then(function () {\nif (!platform.isAndroid) {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n- Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call disconnect in teardown'\n- );\n- });\n- });\n+ return thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n}\n- peerIdsToBeClosed = [];\n-\n+ })\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\n(httpServer !== null ? httpServer.closeAllPromise() :\nPromise.resolve())\n.catch(function (err) {\nt.fail('httpServer had stop err ' + err);\n})\n.then(function () {\n+ peerIdsToBeClosed = [];\nt.end();\n});\n+ });\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -53,21 +53,22 @@ var test = tape({\nerr,\n'Should be able to call stopAdvertisingAndListening in teardown'\n);\n+ Promise.resolve()\n+ .then(function () {\nif (!platform.isAndroid) {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n- Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call disconnect in teardown'\n- );\n- });\n- });\n+ return thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n}\n+ })\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\npeerIdsToBeClosed = [];\nt.end();\n});\n});\n});\n+ });\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "@@ -36,18 +36,19 @@ var test = tape({\n.then(function () {\nt.equals(thaliMobileNativeWrapper._isStarted(), false,\n'must be stopped');\n+ Promise.resolve()\n+ .then(function () {\nif (!platform.isAndroid) {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n- Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call disconnect in teardown'\n- );\n- });\n- });\n+ return thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n}\n+ })\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\npeerIdsToBeClosed = [];\nt.end();\n+ });\n})\n.catch(function (err) {\nt.fail('teardown failed with ' + JSON.stringify(err));\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"diff": "@@ -50,21 +50,22 @@ var test = tape({\nerr,\n'Should be able to call stopAdvertisingAndListening in teardown'\n);\n+ Promise.resolve()\n+ .then(function () {\nif (!platform.isAndroid) {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n- Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call disconnect in teardown'\n- );\n- });\n- });\n+ return thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n}\n+ })\n+ .catch(function (err) {\n+ t.fail(err);\n+ })\n+ .then(function () {\npeerIdsToBeClosed = [];\nt.end();\n});\n});\n});\n+ });\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -5,12 +5,10 @@ var format = require('util').format;\nvar platform = require('thali/NextGeneration/utils/platform');\nvar logger = require('../lib/testLogger')('thaliMobileNativeTestUtils');\nvar randomString = require('randomstring');\n-var Promise = require('lie');\nvar makeIntoCloseAllServer =\nrequire('thali/NextGeneration/makeIntoCloseAllServer');\nvar Promise = require('bluebird');\nvar net = require('net');\n-var inherits = require('util').inherits;\nvar EventEmitter = require('events').EventEmitter;\nvar testUtils = require('../lib/testUtils.js');\n@@ -247,22 +245,13 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\nvar getRequestPromise = null;\nvar cancelGetPortTimeout = null;\nvar runningTest = false;\n+ var peer;\nvar availablePeers = [];\nvar timeoutId = setTimeout(function () {\nexitCall(null, new Error('Timer expired'));\n}, MAX_TIME_TO_WAIT_IN_MILLISECONDS);\n- function removeFromAvailablePeers(peer) {\n- var i;\n-\n- for (i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- }\n- }\n- }\n-\nfunction exitCall(success, failure) {\nif (exitCalled) {\nreturn;\n@@ -315,9 +304,10 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\n// In this case this method is only used when we run on iOS.\nfunction tryToConnect() {\n- availablePeers.forEach(function (peer) {\n+ availablePeers.forEach(function (record) {\nif (!runningTest) {\nrunningTest = true;\n+ peer = record.peer;\nconnectToPeer(peer)\n.then(function (connection) {\n@@ -335,8 +325,10 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\n// the end of available peers array, so we will try to connect\n// to other peers first.\n// See #1904.\n- removeFromAvailablePeers(peer);\n- availablePeers.push(peer);\n+ removeFromAvailablePeers(availablePeers, peer);\n+ availablePeers.push({\n+ peer: peer\n+ });\ntryToConnect();\n});\n@@ -346,11 +338,13 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\nfunction nonTCPAvailableHandler(peer) {\nif (!peer.peerAvailable) {\n- removeFromAvailablePeers(peer);\n+ removeFromAvailablePeers(availablePeers, peer);\nreturn;\n}\n- availablePeers.push(peer);\n+ availablePeers.push({\n+ peer: peer\n+ });\nif (!peerID) {\npeerID = peer.peerIdentifier;\n@@ -371,6 +365,21 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\nmodule.exports.getSamePeerWithRetry = getSamePeerWithRetry;\n+/**\n+ * Function used to remove specific record from array of available peers.\n+ * @param {Array} availablePeers List of available peers\n+ * @param {Object} peerToRemove Peer that has to be removed from available peers array.\n+ */\n+function removeFromAvailablePeers(availablePeers, peerToRemove) {\n+ var i;\n+\n+ for (i = availablePeers.length - 1; i >= 0; i--) {\n+ if (availablePeers[i].peer.peerIdentifier === peerToRemove.peerIdentifier) {\n+ availablePeers.splice(i, 1);\n+ }\n+ }\n+}\n+\n/**\n* This function is responsible for execution of test function requiring connection to the other peer.\n* It assures that the connection is not established with the zombie advertiser. In case of the connection error\n@@ -382,20 +391,12 @@ module.exports.getSamePeerWithRetry = getSamePeerWithRetry;\nfunction executeZombieProofTest (t, server, testFunction) {\nvar availablePeers = [];\nvar runningTest = false;\n-\n- function removeFromAvailablePeers(peer) {\n- var i;\n-\n- for (i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- }\n- }\n- }\n+ var peer;\nfunction tryToConnect() {\n- availablePeers.forEach(function (peer) {\n+ availablePeers.forEach(function (record) {\nif (!runningTest) {\n+ peer = record.peer;\nrunningTest = true;\nconnectToPeer(peer)\n@@ -405,8 +406,10 @@ function executeZombieProofTest (t, server, testFunction) {\n.catch(function (error) {\nrunningTest = false;\n- removeFromAvailablePeers(peer);\n- availablePeers.push(peer);\n+ removeFromAvailablePeers(availablePeers, peer);\n+ availablePeers.push({\n+ peer: peer\n+ });\ntryToConnect();\n});\n@@ -420,11 +423,13 @@ function executeZombieProofTest (t, server, testFunction) {\nvar peer = peerAsArray[0];\nif (!peer.peerAvailable) {\n- removeFromAvailablePeers(peer);\n+ removeFromAvailablePeers(availablePeers, peer);\nreturn;\n}\n- availablePeers.push(peer);\n+ availablePeers.push({\n+ peer: peer\n+ });\nlogger.debug('We got a peer ' + JSON.stringify(peer));\ntryToConnect();\n@@ -443,20 +448,10 @@ module.exports.executeZombieProofTest = executeZombieProofTest;\n* @param {function} testFunction\n*/\nfunction executeZombieProofTestCoordinated (t, server, testFunction) {\n- var availablePeers = [];\n-\n- function removeFromAvailablePeers(peer) {\n- var i;\n-\n- for (i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peer.peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- }\n- }\n- }\n+ var availablePeersAndTestingFlags = [];\nfunction tryToConnect() {\n- availablePeers.forEach(function (record) {\n+ availablePeersAndTestingFlags.forEach(function (record) {\nvar runningTest = record.runningTest;\nvar peer = record.peer;\n@@ -469,9 +464,9 @@ function executeZombieProofTestCoordinated (t, server, testFunction) {\n})\n.catch(function (error) {\nrecord.runningTest = false;\n- removeFromAvailablePeers(peer);\n+ removeFromAvailablePeers(availablePeersAndTestingFlags, peer);\n- availablePeers.push(record);\n+ availablePeersAndTestingFlags.push(record);\ntryToConnect();\n});\n}\n@@ -484,11 +479,11 @@ function executeZombieProofTestCoordinated (t, server, testFunction) {\nvar peer = peerAsArray[0];\nif (!peer.peerAvailable) {\n- removeFromAvailablePeers(peer);\n+ removeFromAvailablePeers(availablePeersAndTestingFlags, peer);\nreturn;\n}\n- availablePeers.push({\n+ availablePeersAndTestingFlags.push({\npeer: peer,\nrunningTest: false\n});\n@@ -549,3 +544,19 @@ function getConnectionToOnePeerAndTest(t, connectTest) {\n}\nmodule.exports.getConnectionToOnePeerAndTest = getConnectionToOnePeerAndTest;\n+\n+function killAllMultiConnectConnections(peerIdsToBeClosed) {\n+ var promises = [];\n+\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n+ promises.push(new Promise(function (resolve, reject) {\n+ Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n+ !err ? resolve() : reject('Should be able to call disconnect');\n+ });\n+ }));\n+ });\n+\n+ return Promise.all(promises);\n+}\n+\n+module.exports.killAllMultiConnectConnections = killAllMultiConnectConnections;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
CR Suggestions. Remove not needed variables.
|
675,375 |
03.07.2017 18:18:25
| -7,200 |
1889b54427988d898713e8f4b0f3d121d75604c7
|
WIP: Test still fails sometimes
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -413,7 +413,13 @@ test('Can shift data via parallel connections',\n});\ntest('Can shift data securely', function (t) {\n- var exchangeData = 'small amount of data';\n+ var dataSize = 16 * 1024;\n+ var exchangeData = randomString.generate(dataSize);\n+\n+ var uuids = t.participants.map(function (p) { return p.uuid; });\n+ assert(uuids.length === 2, 'This test requires exactly 2 devices');\n+ uuids.sort();\n+ var iAmFirst = (tape.uuid === uuids[0]);\nvar pskKey = new Buffer('psk-key');\nvar pskId = 'psk-id';\n@@ -461,9 +467,12 @@ test('Can shift data securely', function (t) {\nt.fail(error.message);\n});\n});\n+\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n+ var waitForServerEnd = waitForEvent(server, 'CLIENT_DONE');\n+\nfunction shiftData(sock) {\nsock.on('error', function (error) {\nconsole.log('Client socket error:', error.message, error.stack);\n@@ -473,11 +482,8 @@ test('Can shift data securely', function (t) {\nvar receivedData = '';\nsock.on('data', function (chunk) {\nreceivedData += chunk.toString();\n- if (receivedData === exchangeData) {\n- sock.destroy();\n- }\n});\n- sock.on('close', function () {\n+ sock.on('end', function () {\nt.equal(receivedData, exchangeData, 'got the same data back');\n});\n@@ -487,21 +493,36 @@ test('Can shift data securely', function (t) {\nsock.write(rawData, function () {\nlogger.debug('Client data flushed');\n});\n- return waitForEvent(sock, 'close');\n+ return waitForEvent(sock, 'end');\n}\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (connection, peer) {\n- peerIdsToBeClosed.push(peer.peerIdentifier);\n-\n+ function startShiftData(port) {\nreturn connect(tls, {\n- port: connection.listeningPort,\n+ port: port,\nciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\npskIdentity: pskId,\npskKey: pskKey\n})\n.then(function (socket) {\nreturn shiftData(socket);\n+ });\n+ }\n+\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (connection, peer) {\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n+\n+ Promise.resolve()\n+ .then(function () {\n+ if (iAmFirst) {\n+ return startShiftData(connection.listeningPort)\n+ .then(function () {\n+ return waitForServerEnd;\n+ });\n+ }\n+ return waitForServerEnd.then(function () {\n+ return startShiftData(connection.listeningPort);\n+ })\n})\n.catch(t.fail)\n.then(function () {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
WIP: Test still fails sometimes
|
675,375 |
03.07.2017 21:13:35
| -7,200 |
d72c3ce6a6d6da7d5d97097178a4e64becfd855d
|
WIP: Restore working code
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -413,13 +413,21 @@ test('Can shift data via parallel connections',\n});\ntest('Can shift data securely', function (t) {\n- var dataSize = 16 * 1024;\n- var exchangeData = randomString.generate(dataSize);\n+ var uuids = t.participants.map(function (p) {\n+ return p.uuid;\n+ });\n+\n+ if (uuids.length !== 2) {\n+ t.skip('This test requires exactly 2 devices');\n+ t.end();\n+ return;\n+ }\n- var uuids = t.participants.map(function (p) { return p.uuid; });\n- assert(uuids.length === 2, 'This test requires exactly 2 devices');\nuuids.sort();\n+\nvar iAmFirst = (tape.uuid === uuids[0]);\n+ var exchangeData = 'small amount of data';\n+ var isClientDone = false;\nvar pskKey = new Buffer('psk-key');\nvar pskId = 'psk-id';\n@@ -461,6 +469,7 @@ test('Can shift data via parallel connections',\nt.fail(new Error('Unexpected end event'));\nreturn;\n}\n+ isClientDone = true;\nserver.emit('CLIENT_DONE');\n});\nsocket.on('error', function (error) {\n@@ -471,31 +480,6 @@ test('Can shift data via parallel connections',\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- var waitForServerEnd = waitForEvent(server, 'CLIENT_DONE');\n-\n- function shiftData(sock) {\n- sock.on('error', function (error) {\n- console.log('Client socket error:', error.message, error.stack);\n- t.fail(error.message);\n- });\n-\n- var receivedData = '';\n- sock.on('data', function (chunk) {\n- receivedData += chunk.toString();\n- });\n- sock.on('end', function () {\n- t.equal(receivedData, exchangeData, 'got the same data back');\n- });\n-\n- var rawData = new Buffer(exchangeData);\n- logger.debug('Client sends data (%d bytes):',\n- rawData.length);\n- sock.write(rawData, function () {\n- logger.debug('Client data flushed');\n- });\n- return waitForEvent(sock, 'end');\n- }\n-\nfunction startShiftData(port) {\nreturn connect(tls, {\nport: port,\n@@ -504,7 +488,19 @@ test('Can shift data via parallel connections',\npskKey: pskKey\n})\n.then(function (socket) {\n- return shiftData(socket);\n+ return shiftData(t, socket, exchangeData);\n+ });\n+ }\n+\n+ function clientDonePromise() {\n+ return new Promise(function (resolve, reject) {\n+ if (isClientDone) {\n+ resolve();\n+ } else {\n+ server.on('CLIENT_DONE', function () {\n+ resolve();\n+ });\n+ }\n});\n}\n@@ -517,12 +513,13 @@ test('Can shift data via parallel connections',\nif (iAmFirst) {\nreturn startShiftData(connection.listeningPort)\n.then(function () {\n- return waitForServerEnd;\n+ return clientDonePromise();\n});\n}\n- return waitForServerEnd.then(function () {\n+ return clientDonePromise()\n+ .then(function () {\nreturn startShiftData(connection.listeningPort);\n- })\n+ });\n})\n.catch(t.fail)\n.then(function () {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
WIP: Restore working code
|
675,375 |
04.07.2017 11:23:54
| -7,200 |
2e86c55f79e16aabdfb7fd500076801d6b2a2e66
|
Get rid of unnecessary variables, functions and logic. Leave as it was before but cleaned up
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -296,12 +296,6 @@ function connect(module, options) {\n});\n}\n-function waitForEvent(emitter, event) {\n- return new Promise(function (resolve) {\n- emitter.once(event, resolve);\n- });\n-}\n-\nfunction shiftData(t, sock, exchangeData) {\nreturn new Promise(function (resolve, reject) {\nsock.on('error', function (error) {\n@@ -413,21 +407,7 @@ test('Can shift data via parallel connections',\n});\ntest('Can shift data securely', function (t) {\n- var uuids = t.participants.map(function (p) {\n- return p.uuid;\n- });\n-\n- if (uuids.length !== 2) {\n- t.skip('This test requires exactly 2 devices');\n- t.end();\n- return;\n- }\n-\n- uuids.sort();\n-\n- var iAmFirst = (tape.uuid === uuids[0]);\nvar exchangeData = 'small amount of data';\n- var isClientDone = false;\nvar pskKey = new Buffer('psk-key');\nvar pskId = 'psk-id';\n@@ -464,67 +444,29 @@ test('Can shift data securely', function (t) {\n}\n});\nsocket.on('end', function () {\n- // server ends connection, not client\nif (!ended) {\nt.fail(new Error('Unexpected end event'));\n- return;\n}\n- isClientDone = true;\n- server.emit('CLIENT_DONE');\n});\nsocket.on('error', function (error) {\nt.fail(error.message);\n});\n});\n-\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- function startShiftData(port) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (connection, peer) {\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n+\nreturn connect(tls, {\n- port: port,\n+ port: connection.listeningPort,\nciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\npskIdentity: pskId,\npskKey: pskKey\n})\n.then(function (socket) {\nreturn shiftData(t, socket, exchangeData);\n- });\n- }\n-\n- function clientDonePromise() {\n- return new Promise(function (resolve, reject) {\n- // It may happen that the server has already received all data\n- // but we didn't set listener yet. So we use additional variable\n- // that will tell us if server has already finished.\n- // If isClientDone is not set to true, we set up our listener\n- // and when server ends, it will emit 'CLIENT_DONE' event.\n- if (isClientDone) {\n- resolve();\n- } else {\n- server.on('CLIENT_DONE', function () {\n- resolve();\n- });\n- }\n- });\n- }\n-\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (connection, peer) {\n- peerIdsToBeClosed.push(peer.peerIdentifier);\n-\n- Promise.resolve()\n- .then(function () {\n- if (iAmFirst) {\n- return startShiftData(connection.listeningPort)\n- .then(function () {\n- return clientDonePromise();\n- });\n- }\n- return clientDonePromise()\n- .then(function () {\n- return startShiftData(connection.listeningPort);\n- });\n})\n.catch(t.fail)\n.then(function () {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Get rid of unnecessary variables, functions and logic. Leave as it was before but cleaned up
|
675,375 |
04.07.2017 11:26:33
| -7,200 |
dfabc2d4c5b6bf1a6b4a6e41badbac74097fb40f
|
Stop NotificationClient and NotificationServer in teardown section in order to allow other peers to retry to get data.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"diff": "@@ -82,6 +82,8 @@ var GlobalVariables = function () {\n};\n+var notificationServer, notificationClient;\n+\nvar test = tape({\nsetup: function (t) {\nglobals = new GlobalVariables();\n@@ -93,6 +95,9 @@ var test = tape({\nteardown: function (t) {\nthaliMobile.stop();\n// Clears timeout\n+ notificationClient.stop();\n+ notificationServer.stop();\n+\nvar summary =\n'Participants:' + globals.numberOfParticipants +\n' Peers Replied to us:' + countNonZeroItems(globals.peerRepliedToUs)+\n@@ -214,11 +219,11 @@ test('Client to server request coordinated', function (t) {\npeerPool.start();\n// Initialize the ThaliNotificationClient\n- var notificationClient =\n+ notificationClient =\nnew ThaliNotificationClient(peerPool, globals.ecdh);\n// Initializes ThaliNotificationServer\n- var notificationServer = new ThaliNotificationServer(\n+ notificationServer = new ThaliNotificationServer(\nglobals.expressRouter, globals.ecdh, 90000);\ngetPskIdToPublicKey = notificationServer.getPskIdToPublicKey();\n@@ -257,6 +262,7 @@ test('Client to server request coordinated', function (t) {\nvar publicKeyHash = NotificationBeacons.createPublicKeyHash(res.keyId);\nglobals.peerAdvertisesDataForUsEvents[publicKeyHash]++;\n+\ninitiateHttpsRequestToPeer(res, 1);\n});\n@@ -266,9 +272,6 @@ test('Client to server request coordinated', function (t) {\nif(checkSuccess() || ++intervalRounds > 24) {\n// Test has been completed successfully or we have hit the time limit\nclearInterval(globals.testInterval);\n- thaliMobile.stopListeningForAdvertisements().then(function () {\n- notificationClient.stop();\n- notificationServer.stop().then(function () {\nt.ok(allDictionaryItemsNonZero(globals.peerRepliedToUs),\n'Peer made successful https requests to all peers');\n@@ -281,14 +284,6 @@ test('Client to server request coordinated', function (t) {\nglobals.failedPskIdentityCount);\nt.end();\n- }).catch(function (failure) {\n- t.fail('Stopping the server failed:' + failure);\n- t.end();\n- });\n- }).catch(function (failure) {\n- t.fail('Failed to call stopListeningForAdvertisements:' + failure);\n- t.end();\n- });\n}\n}, 5000);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Stop NotificationClient and NotificationServer in teardown section in order to allow other peers to retry to get data.
|
675,375 |
04.07.2017 14:41:36
| -7,200 |
9b0114985311191a2eac3896d677168ae9b35128
|
WIP: Refactor tests in testThaliMobileNative as promises
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -263,7 +263,7 @@ test('Can connect to a remote peer', function (t) {\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\nfunction (connection, peer) {\n- // Called if we successfully connect to to a peer\n+ return new Promise(function (resolve, reject) {\nlogger.info(connection);\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -275,7 +275,8 @@ test('Can connect to a remote peer', function (t) {\n// A check if any of our old reverse connection or please connect code\n// is still hiding around.\nt.ok(connection.listeningPort !== 0, 'listening port should not be 0');\n- t.end();\n+ resolve();\n+ });\n});\n});\n@@ -359,6 +360,7 @@ test('Can shift data', function (t) {\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\nfunction (connection, peer) {\n+ return new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\n@@ -368,7 +370,8 @@ test('Can shift data', function (t) {\n})\n.catch(t.fail)\n.then(function () {\n- t.end();\n+ resolve();\n+ });\n});\n});\n});\n@@ -386,6 +389,7 @@ test('Can shift data via parallel connections',\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\nfunction (connection, peer) {\n+ return new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\nPromise.all([\n@@ -401,7 +405,8 @@ test('Can shift data via parallel connections',\n})\n.catch(t.fail)\n.then(function () {\n- t.end();\n+ resolve();\n+ });\n});\n});\n});\n@@ -457,10 +462,12 @@ test('Can shift data securely', function (t) {\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\nfunction (connection, peer) {\n+ return new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n+ var nativePort = connection.listeningPort;\n- return connect(tls, {\n- port: connection.listeningPort,\n+ connect(tls, {\n+ port: nativePort,\nciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\npskIdentity: pskId,\npskKey: pskKey\n@@ -470,77 +477,82 @@ test('Can shift data securely', function (t) {\n})\n.catch(t.fail)\n.then(function () {\n- t.end();\n+ resolve();\n+ });\n});\n});\n});\ntest('Can shift large amounts of data', function (t) {\nvar sockets = {};\n- var server = net.createServer(function (socket) {\n- socket.on('data', function (data) {\n- socket.write(data);\n- });\n- socket.on('end', socket.end);\n- socket.on('error', function (error) {\n- logger.warn('Error on echo server socket: ' + error);\n- t.fail();\n- });\n- sockets[socket.remotePort] = socket;\n- });\n- server = makeIntoCloseAllServer(server);\n- serverToBeClosed = server;\n-\n- var dataSize = 64 * 1024;\n- var toSend = randomString.generate(dataSize);\n+ // var server = net.createServer(function (socket) {\n+ // socket.on('data', function (data) {\n+ // socket.write(data);\n+ // });\n+ // socket.on('end', socket.end);\n+ // socket.on('error', function (error) {\n+ // logger.warn('Error on echo server socket: ' + error);\n+ // t.fail();\n+ // });\n+ // sockets[socket.remotePort] = socket;\n+ // });\n- function shiftData(sock) {\n-\n- sock.on('error', function (error) {\n- logger.warn('Error on client socket: ' + error);\n- t.fail();\n- });\n- var toRecv = '';\n-\n- var done = false;\n- sock.on('data', function (data) {\n- var remaining = dataSize - toRecv.length;\n-\n- if (remaining >= data.length) {\n- toRecv += data.toString();\n- data = data.slice(0, 0);\n- }\n- else {\n- toRecv += data.toString('utf8', 0, remaining);\n- data = data.slice(remaining);\n- }\n+ var dataSize = 64 * 1024;\n+ var exchangeData = randomString.generate(dataSize);\n- if (toRecv.length === dataSize) {\n- if (!done) {\n- done = true;\n- t.ok(toSend === toRecv, 'received should match sent forward');\n- t.end();\n- }\n- if (data.length) {\n- sock.write(data);\n- }\n- }\n- });\n+ var server = createServer(t, exchangeData.length);\n+ server = makeIntoCloseAllServer(server);\n+ serverToBeClosed = server;\n- sock.write(toSend);\n- }\n+ // function shiftData(sock) {\n+ // sock.on('error', function (error) {\n+ // logger.warn('Error on client socket: ' + error);\n+ // t.fail();\n+ // });\n+ //\n+ // var toRecv = '';\n+ //\n+ // var done = false;\n+ // sock.on('data', function (data) {\n+ // var remaining = dataSize - toRecv.length;\n+ //\n+ // if (remaining >= data.length) {\n+ // toRecv += data.toString();\n+ // data = data.slice(0, 0);\n+ // }\n+ // else {\n+ // toRecv += data.toString('utf8', 0, remaining);\n+ // data = data.slice(remaining);\n+ // }\n+ //\n+ // if (toRecv.length === dataSize) {\n+ // if (!done) {\n+ // done = true;\n+ // t.ok(toSend === toRecv, 'received should match sent forward');\n+ // t.end();\n+ // }\n+ // if (data.length) {\n+ // sock.write(data);\n+ // }\n+ // }\n+ // });\n+ //\n+ // sock.write(toSend);\n+ // }\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\nfunction (connection, peer) {\n- var client = null;\npeerIdsToBeClosed.push(peer.peerIdentifier);\n+ var nativePort = connection.listeningPort;\n- // We're happy here if we make a connection to anyone\n- logger.info('Connection info: ' + JSON.stringify(connection));\n- client = net.connect(connection.listeningPort, function () {\n- logger.info('Connected to the ' + connection.listeningPort);\n- shiftData(client);\n+ connect(net, {port: nativePort})\n+ .then(function (socket) {\n+ return shiftData(t, socket, exchangeData);\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ resolve();\n});\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -392,8 +392,21 @@ function executeZombieProofTest (t, server, testFunction) {\nvar availablePeers = [];\nvar runningTest = false;\nvar peer;\n+ var testTimeout;\n+ var tryToConnectRetries = 0;\nfunction tryToConnect() {\n+ testTimeout = setTimeout(function () {\n+ tryToConnectRetries++;\n+\n+ if (tryToConnectRetries > 5) {\n+ t.fail('Too many test retries!')\n+ } else {\n+ runningTest = false;\n+ tryToConnect();\n+ }\n+ }, 30000);\n+\navailablePeers.forEach(function (record) {\nif (!runningTest) {\npeer = record.peer;\n@@ -401,7 +414,11 @@ function executeZombieProofTest (t, server, testFunction) {\nconnectToPeer(peer)\n.then(function (connection) {\n- testFunction(connection, peer);\n+ testFunction(connection, peer)\n+ .then(function () {\n+ clearTimeout(testTimeout);\n+ t.end();\n+ });\n})\n.catch(function (error) {\nrunningTest = false;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
WIP: Refactor tests in testThaliMobileNative as promises
|
675,375 |
05.07.2017 13:00:47
| -7,200 |
2950e5ec1e7a365be5f6ff2a9caa44a52abd32a0
|
Fix Can shift large amount of data. Add logging when restarting test due to timeout
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -484,20 +484,6 @@ test('Can shift data securely', function (t) {\n});\ntest('Can shift large amounts of data', function (t) {\n- var sockets = {};\n- // var server = net.createServer(function (socket) {\n- // socket.on('data', function (data) {\n- // socket.write(data);\n- // });\n- // socket.on('end', socket.end);\n- // socket.on('error', function (error) {\n- // logger.warn('Error on echo server socket: ' + error);\n- // t.fail();\n- // });\n- // sockets[socket.remotePort] = socket;\n- // });\n-\n-\nvar dataSize = 64 * 1024;\nvar exchangeData = randomString.generate(dataSize);\n@@ -505,44 +491,9 @@ test('Can shift large amounts of data', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- // function shiftData(sock) {\n- // sock.on('error', function (error) {\n- // logger.warn('Error on client socket: ' + error);\n- // t.fail();\n- // });\n- //\n- // var toRecv = '';\n- //\n- // var done = false;\n- // sock.on('data', function (data) {\n- // var remaining = dataSize - toRecv.length;\n- //\n- // if (remaining >= data.length) {\n- // toRecv += data.toString();\n- // data = data.slice(0, 0);\n- // }\n- // else {\n- // toRecv += data.toString('utf8', 0, remaining);\n- // data = data.slice(remaining);\n- // }\n- //\n- // if (toRecv.length === dataSize) {\n- // if (!done) {\n- // done = true;\n- // t.ok(toSend === toRecv, 'received should match sent forward');\n- // t.end();\n- // }\n- // if (data.length) {\n- // sock.write(data);\n- // }\n- // }\n- // });\n- //\n- // sock.write(toSend);\n- // }\n-\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\nfunction (connection, peer) {\n+ return new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\n@@ -556,6 +507,7 @@ test('Can shift large amounts of data', function (t) {\n});\n});\n});\n+});\nfunction findSmallestParticipant(participants) {\nvar smallest = null;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -397,6 +397,7 @@ function executeZombieProofTest (t, server, testFunction) {\nfunction tryToConnect() {\ntestTimeout = setTimeout(function () {\n+ logger.debug('Test timeout reached. Restarting test.');\ntryToConnectRetries++;\nif (tryToConnectRetries > 5) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix Can shift large amount of data. Add logging when restarting test due to timeout
|
675,375 |
05.07.2017 15:41:44
| -7,200 |
49fde15d15dfea7d0525def81c14ae087147b64c
|
Fix timer in thaliMobileNativeTestUtils
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -392,10 +392,14 @@ function executeZombieProofTest (t, server, testFunction) {\nvar availablePeers = [];\nvar runningTest = false;\nvar peer;\n- var testTimeout;\n+ var testTimeout = null;\nvar tryToConnectRetries = 0;\nfunction tryToConnect() {\n+ if (testTimeout) {\n+ clearTimeout(testTimeout);\n+ }\n+\ntestTimeout = setTimeout(function () {\nlogger.debug('Test timeout reached. Restarting test.');\ntryToConnectRetries++;\n@@ -418,6 +422,8 @@ function executeZombieProofTest (t, server, testFunction) {\ntestFunction(connection, peer)\n.then(function () {\nclearTimeout(testTimeout);\n+ testTimeout = null;\n+\nt.end();\n});\n})\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix timer in thaliMobileNativeTestUtils
|
675,375 |
06.07.2017 15:08:47
| -7,200 |
40b2d2654bfffc8e8659c841e394cda36c63cc3e
|
WIP: Apply retry logic for testThaliNotification, temp fix in thaliMobileNativeTestUtils
|
[
{
"change_type": "MODIFY",
"old_path": "lib/ios/Cartfile",
"new_path": "lib/ios/Cartfile",
"diff": "-github \"thaliproject/thali-ios\" \"master-enrico-error-handling\"\n+github \"thaliproject/thali-ios\" \"master-enrico-error-handling-tmp\"\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"diff": "@@ -15,6 +15,8 @@ var ThaliPeerPoolDefault =\nvar NotificationBeacons =\nrequire('thali/NextGeneration/notification/thaliNotificationBeacons');\nvar thaliConfig = require('thali/NextGeneration/thaliConfig');\n+var thaliMobileNativeTestUtils = require('../lib/thaliMobileNativeTestUtils');\n+var Promise = require('lie');\nvar testUtils = require('../lib/testUtils');\nvar logger = require('../lib/testLogger')('testThaliNotification');\n@@ -107,13 +109,7 @@ var test = tape({\n}\n});\n-function initiateHttpsRequestToPeer(peerDetails, requestNumber){\n-\n- // 3 times is max that we try to reconnect\n- if (requestNumber++ > 3) {\n- return;\n- }\n-\n+function initiateHttpsRequestToPeer(peerDetails){\nvar options = {\nmethod: 'GET',\nhostname: peerDetails.hostAddress,\n@@ -126,8 +122,7 @@ function initiateHttpsRequestToPeer(peerDetails, requestNumber){\nciphers: thaliConfig.SUPPORTED_PSK_CIPHERS\n};\n- var requestSuccessful = false;\n-\n+ return new Promise(function (resolve, reject) {\nvar req = https.request(options, function (res) {\nvar data = [];\n@@ -143,7 +138,8 @@ function initiateHttpsRequestToPeer(peerDetails, requestNumber){\nvar publicKeyHash =\nNotificationBeacons.createPublicKeyHash(peerDetails.keyId);\nglobals.peerRepliedToUs[publicKeyHash]++;\n- requestSuccessful = true;\n+\n+ resolve();\n}\n}\n});\n@@ -153,13 +149,9 @@ function initiateHttpsRequestToPeer(peerDetails, requestNumber){\nlogger.warn(err.message);\n});\n- req.on('close', function (err) {\n- if(!requestSuccessful) {\n- initiateHttpsRequestToPeer(peerDetails, requestNumber);\n- }\n- });\n-\nreq.end();\n+ })\n+\n}\nif (!tape.coordinated) {\n@@ -253,6 +245,38 @@ test('Client to server request coordinated', function (t) {\nglobals.expressRouter.get(HELLO_PATH,\nhelloWorld);\n+ var testTimeouts = [];\n+\n+ function runTest(peer, publicKeyHash) {\n+ return new Promise(function (resolve, reject) {\n+ // Simulate recreating NotificationAction\n+ testTimeouts[publicKeyHash] = setTimeout(function () {\n+ logger.warn('Restarting multiConnect.');\n+\n+ // peerAdvertisesDataForUs doesn't have `peerIdentifier` property,\n+ // which is used by `thaliMobileNativeTestUtils.connectToPeer`\n+ // so we need to create it.\n+ peer.peerIdentifier = peer.peerId;\n+\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ logger.info('Established new connection with port ', connection.listeningPort);\n+\n+ res.portNumber = connection.listeningPort;\n+ runTest(peer, publicKeyHash)\n+ .then(function () {\n+ resolve();\n+ });\n+ });\n+ }, 30000);\n+\n+ initiateHttpsRequestToPeer(peer)\n+ .then(function () {\n+ resolve();\n+ });\n+ });\n+ }\n+\nnotificationClient.on(notificationClient.Events.PeerAdvertisesDataForUs,\nfunction (res) {\nvar msg = 'PeerAdvertisesDataForUs:' + res.connectionType +\n@@ -263,7 +287,10 @@ test('Client to server request coordinated', function (t) {\nvar publicKeyHash = NotificationBeacons.createPublicKeyHash(res.keyId);\nglobals.peerAdvertisesDataForUsEvents[publicKeyHash]++;\n- initiateHttpsRequestToPeer(res, 1);\n+ runTest(res, publicKeyHash)\n+ .then(function () {\n+ clearTimeout(testTimeouts[publicKeyHash]);\n+ });\n});\nvar intervalRounds = 0;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -392,10 +392,14 @@ function executeZombieProofTest (t, server, testFunction) {\nvar availablePeers = [];\nvar runningTest = false;\nvar peer;\n- var testTimeout;\n+ var testTimeout = null;\nvar tryToConnectRetries = 0;\nfunction tryToConnect() {\n+ if (testTimeout) {\n+ clearTimeout(testTimeout);\n+ }\n+\ntestTimeout = setTimeout(function () {\nlogger.debug('Test timeout reached. Restarting test.');\ntryToConnectRetries++;\n@@ -418,6 +422,8 @@ function executeZombieProofTest (t, server, testFunction) {\ntestFunction(connection, peer)\n.then(function () {\nclearTimeout(testTimeout);\n+ testTimeout = null;\n+\nt.end();\n});\n})\n@@ -509,12 +515,22 @@ function executeZombieProofTestCoordinated (t, server, testFunction) {\nlogger.debug('We got a peer ' + JSON.stringify(peer));\ntryToConnect();\n}\n+}\nstartAndListen(t, server, peerAvailabilityChangedHandler);\n}\nmodule.exports.executeZombieProofTestCoordinated = executeZombieProofTestCoordinated;\n+function checkIfPeerIsAlreadyPresent(peersArray, peer) {\n+ peersArray.forEach(function (record) {\n+ if (record.peer.peerIdentifier === peer.peerIdentifier) {\n+ return true;\n+ }\n+ });\n+\n+ return false;\n+}\nfunction getConnectionToOnePeerAndTest(t, connectTest) {\nvar echoServer = net.createServer(function (socket) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
WIP: Apply retry logic for testThaliNotification, temp fix in thaliMobileNativeTestUtils
|
675,375 |
07.07.2017 13:10:49
| -7,200 |
01d7c8fdfa50e2b045b115e2cbce02c7744bbeb9
|
WIP: Fix few issues when testing on 3 devices, add testHttp to config.js
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testHttp.js",
"new_path": "test/www/jxcore/bv_tests/testHttp.js",
"diff": "@@ -240,7 +240,7 @@ test('Multiple coordinated request ios native',\nreply = thirdReply;\nbreak;\ndefault:\n- t.end();\n+ t.fail('Server received wrong request url!');\n}\nres.end(reply);\n});\n@@ -250,7 +250,6 @@ test('Multiple coordinated request ios native',\nmakeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path' + localCounter)\n.then(function (response) {\n-\npeerIdsToBeClosed.push(peer.peerIdentifier);\nt.equal(response.toString(), expectedReplies[localCounter]);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/config.js",
"new_path": "test/www/jxcore/config.js",
"diff": "@@ -15,6 +15,7 @@ module.exports = {\n'testTests.js',\n'testUsn.js',\n'testNativeMethod.js',\n+ 'testHttp.js',\n'testThaliMobileNative.js',\n'testThaliMobileNativeAndroid.js',\n'testThaliMobileNativeiOS.js',\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -316,7 +316,7 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\n// When we establish multi connect connections, run test.\ncallTryAgain(connection.listeningPort);\n})\n- .catch(function (error) {\n+ .catch(function (err) {\nrunningTest = false;\n// There is a scenario when we might fail to connect to\n// available peer which is NOT a zombie, in that case when\n@@ -326,9 +326,14 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\n// to other peers first.\n// See #1904.\nremoveFromAvailablePeers(availablePeers, peer);\n+\n+ // Don't try to connect if we previously failed with this peer\n+ // with `Peer is unavailable`.\n+ if (err.message !== 'Peer is unavailable') {\navailablePeers.push({\npeer: peer\n});\n+ }\ntryToConnect();\n});\n@@ -394,12 +399,17 @@ function executeZombieProofTest (t, server, testFunction) {\nvar peer;\nvar testTimeout = null;\nvar tryToConnectRetries = 0;\n+ var areWeDone = false;\nfunction tryToConnect() {\nif (testTimeout) {\nclearTimeout(testTimeout);\n}\n+ if (areWeDone) {\n+ return;\n+ }\n+\ntestTimeout = setTimeout(function () {\nlogger.debug('Test timeout reached. Restarting test.');\ntryToConnectRetries++;\n@@ -424,16 +434,28 @@ function executeZombieProofTest (t, server, testFunction) {\nclearTimeout(testTimeout);\ntestTimeout = null;\n+ // In case we would fail with timeout with some other peer\n+ // we are good if we finished with one. So, we set a flag\n+ // and when this function will be called again but we will\n+ // be already done with any of peers, return.\n+ if (!areWeDone) {\n+ areWeDone = true;\nt.end();\n+ }\n});\n})\n- .catch(function (error) {\n+ .catch(function (err) {\nrunningTest = false;\nremoveFromAvailablePeers(availablePeers, peer);\n+\n+ // Don't try to connect if we previously failed with this peer\n+ // with `Peer is unavailable`.\n+ if (err.message !== 'Peer is unavailable') {\navailablePeers.push({\npeer: peer\n});\n+ }\ntryToConnect();\n});\n@@ -464,6 +486,18 @@ function executeZombieProofTest (t, server, testFunction) {\nmodule.exports.executeZombieProofTest = executeZombieProofTest;\n+function checkIfPeerIsAlreadyPresent(peersArray, peer) {\n+ var isPeerPresentInArray = false;\n+\n+ peersArray.forEach(function (record) {\n+ if (record.peer.peerIdentifier === peer.peerIdentifier) {\n+ isPeerPresentInArray = true;\n+ }\n+ });\n+\n+ return isPeerPresentInArray;\n+}\n+\n/**\n* Same as above, but every peer is treated individually, so we could exchange data\n* with every available peer, not only one.\n@@ -486,11 +520,16 @@ function executeZombieProofTestCoordinated (t, server, testFunction) {\n.then(function (connection) {\ntestFunction(connection, peer);\n})\n- .catch(function (error) {\n+ .catch(function (err) {\nrecord.runningTest = false;\n- removeFromAvailablePeers(availablePeersAndTestingFlags, peer);\n+ removeFromAvailablePeers(availablePeersAndTestingFlags, peer);\n+ // Don't try to connect if we previously failed with this peer\n+ // with `Peer is unavailable`.\n+ if (err.message !== 'Peer is unavailable') {\navailablePeersAndTestingFlags.push(record);\n+ }\n+\ntryToConnect();\n});\n}\n@@ -507,31 +546,23 @@ function executeZombieProofTestCoordinated (t, server, testFunction) {\nreturn;\n}\n+ // Don't add same peers but with different generations.\n+ if (!checkIfPeerIsAlreadyPresent(availablePeersAndTestingFlags, peer)) {\navailablePeersAndTestingFlags.push({\npeer: peer,\nrunningTest: false\n});\n+ }\nlogger.debug('We got a peer ' + JSON.stringify(peer));\ntryToConnect();\n}\n-}\nstartAndListen(t, server, peerAvailabilityChangedHandler);\n}\nmodule.exports.executeZombieProofTestCoordinated = executeZombieProofTestCoordinated;\n-function checkIfPeerIsAlreadyPresent(peersArray, peer) {\n- peersArray.forEach(function (record) {\n- if (record.peer.peerIdentifier === peer.peerIdentifier) {\n- return true;\n- }\n- });\n-\n- return false;\n-}\n-\nfunction getConnectionToOnePeerAndTest(t, connectTest) {\nvar echoServer = net.createServer(function (socket) {\nsocket.pipe(socket);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
WIP: Fix few issues when testing on 3 devices, add testHttp to config.js
|
675,375 |
07.07.2017 13:24:10
| -7,200 |
a53d8d9a998906dbd3b239d918c81a078370fd79
|
Change priority of testHttp.js in config.js
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/config.js",
"new_path": "test/www/jxcore/config.js",
"diff": "@@ -15,7 +15,6 @@ module.exports = {\n'testTests.js',\n'testUsn.js',\n'testNativeMethod.js',\n- 'testHttp.js',\n'testThaliMobileNative.js',\n'testThaliMobileNativeAndroid.js',\n'testThaliMobileNativeiOS.js',\n@@ -23,6 +22,7 @@ module.exports = {\n'testCreateNativeListener.js',\n'testCreatePeerListener.js',\n'testThaliTcpServersManager.js',\n+ 'testHttp.js',\n'testThaliMobileNativeWrapper.js',\n'testThaliWifiInfrastructure.js',\n'testThaliMobile.js',\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Change priority of testHttp.js in config.js
|
675,375 |
10.07.2017 09:07:53
| -7,200 |
a8db48dd69e4e099518d0b28239f4684d839c0d2
|
Fix for resolving replication peer action even when we try to replicate with non existing remote db
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js",
"new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js",
"diff": "@@ -362,6 +362,7 @@ test('Coordinated replication action test - should throw error when wrong remote\npeerPool, devicePublicPrivateKey\n);\nvar peerActions = [];\n+ var areWeDone = false;\nlocalPouchDB = new TestPouchDB(LOCAL_DB_NAME);\n@@ -394,11 +395,16 @@ test('Coordinated replication action test - should throw error when wrong remote\n// This should be rejected since we provided non existing remote db\nthaliReplicationPeerAction.start(httpAgentPool, wrongRemoteDbName)\n.then(function() {\n+ // It is possible that we will resolve even when the proper error occurred.\n+ // This is when we call _complete on already killed action.\n+ if (!areWeDone) {\nvar error = 'we should not be able to replicate with db that doesn\\'t exist';\nt.fail(error);\nreject(new Error(error));\n+ }\n})\n.catch(function (error) {\n+ areWeDone = true;\nt.equals(error.reason, ERROR_NO_DB_FILE, 'error should be \\'no_db_file\\'');\nresolve(true);\n});\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix for resolving replication peer action even when we try to replicate with non existing remote db
|
675,375 |
10.07.2017 10:39:19
| -7,200 |
e42d8e50ae252565bf3663436bdcab06170684da
|
Fix thaliTestNotification retry logic, add peer to availablePeers array again only if error was
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"diff": "@@ -262,7 +262,7 @@ test('Client to server request coordinated', function (t) {\n.then(function (connection) {\nlogger.info('Established new connection with port ', connection.listeningPort);\n- res.portNumber = connection.listeningPort;\n+ peer.portNumber = connection.listeningPort;\nrunTest(peer, publicKeyHash)\n.then(function () {\nresolve();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -329,7 +329,7 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\n// Don't try to connect if we previously failed with this peer\n// with `Peer is unavailable`.\n- if (err.message !== 'Peer is unavailable') {\n+ if (err.message === 'Connection could not be established') {\navailablePeers.push({\npeer: peer\n});\n@@ -451,7 +451,7 @@ function executeZombieProofTest (t, server, testFunction) {\n// Don't try to connect if we previously failed with this peer\n// with `Peer is unavailable`.\n- if (err.message !== 'Peer is unavailable') {\n+ if (err.message === 'Connection could not be established') {\navailablePeers.push({\npeer: peer\n});\n@@ -526,7 +526,7 @@ function executeZombieProofTestCoordinated (t, server, testFunction) {\nremoveFromAvailablePeers(availablePeersAndTestingFlags, peer);\n// Don't try to connect if we previously failed with this peer\n// with `Peer is unavailable`.\n- if (err.message !== 'Peer is unavailable') {\n+ if (err.message === 'Connection could not be established') {\navailablePeersAndTestingFlags.push(record);\n}\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix thaliTestNotification retry logic, add peer to availablePeers array again only if error was
|
675,375 |
10.07.2017 13:32:23
| -7,200 |
a2b6fb8291e05e0068871b65c1477d5ce136767e
|
Call stop on notificationClient and notificationServer only when they are truthy. This won't be called when we will run not coordinated tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotification.js",
"diff": "@@ -97,8 +97,10 @@ var test = tape({\nteardown: function (t) {\nthaliMobile.stop();\n// Clears timeout\n+ if (notificationClient && notificationServer) {\nnotificationClient.stop();\nnotificationServer.stop();\n+ }\nvar summary =\n'Participants:' + globals.numberOfParticipants +\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Call stop on notificationClient and notificationServer only when they are truthy. This won't be called when we will run not coordinated tests
|
675,375 |
13.07.2017 13:24:45
| -7,200 |
31384d0b279123fc0d1aa8e4180ea30784ff58c7
|
Move thaliMobileNativeWrapper._registerToNative() to teardown, skip iOS tests that do not work now because of add check in testForDataCorruption
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testHttp.js",
"new_path": "test/www/jxcore/bv_tests/testHttp.js",
"diff": "@@ -18,6 +18,7 @@ var peerIdsToBeClosed = [];\nvar test = tape({\nsetup: function (t) {\nhttpServer = makeIntoCloseAllServer(http.createServer(), true);\n+ ThaliMobileNativeWrapper._registerToNative();\nt.end();\n},\nteardown: function (t) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1781,8 +1781,8 @@ function(t) {\ntest('We properly fire peer unavailable and then available when ' +\n'connection fails on iOS',\nfunction () {\n- return !(platform.isIOS &&\n- global.NETWORK_TYPE === ThaliMobile.networkTypes.NATIVE);\n+ // Skip for now, see #1924\n+ return true;\n},\nfunction(t) {\n@@ -2517,10 +2517,13 @@ test('test for data corruption',\n}\nvar serversManager = ThaliMobileNativeWrapper._getServersManager();\n+\n+ if (serversManager !== null) {\nserversManager.terminateOutgoingConnection(\npeer.peerIdentifier,\npeer.portNumber\n);\n+ }\n// We have to give Android enough time to notice the killed\n// connection and recycle everything\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -32,7 +32,6 @@ var peerIdsToBeClosed = [];\nvar test = tape({\nsetup: function (t) {\n- thaliMobileNativeWrapper._registerToNative();\nserverToBeClosed = {\ncloseAll: function (callback) {\ncallback();\n@@ -64,6 +63,7 @@ var test = tape({\n})\n.then(function () {\npeerIdsToBeClosed = [];\n+ thaliMobileNativeWrapper._registerToNative();\nt.end();\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "@@ -26,9 +26,6 @@ var peerIdsToBeClosed = [];\nvar test = tape({\nsetup: function (t) {\n- // Make sure right handlers are registered in case\n- // some other test has overwritten them.\n- thaliMobileNativeWrapper._registerToNative();\nt.end();\n},\nteardown: function (t) {\n@@ -47,6 +44,7 @@ var test = tape({\n})\n.then(function () {\npeerIdsToBeClosed = [];\n+ thaliMobileNativeWrapper._registerToNative();\nt.end();\n});\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"diff": "@@ -29,7 +29,6 @@ var serverToBeClosed = null;\nvar test = tape({\nsetup: function (t) {\n- thaliMobileNativeWrapper._registerToNative();\nserverToBeClosed = {\ncloseAll: function (callback) {\ncallback();\n@@ -61,6 +60,7 @@ var test = tape({\n})\n.then(function () {\npeerIdsToBeClosed = [];\n+ thaliMobileNativeWrapper._registerToNative();\nt.end();\n});\n});\n@@ -113,6 +113,10 @@ test('cannot call multiConnect with illegal peerID', function (t) {\n});\ntest('multiConnect properly fails on legal but non-existent peerID',\n+ function () {\n+ // Skip for now, see #1924\n+ return true;\n+ },\nfunction (t) {\nvar connectReturned = false;\nvar originalSyncValue = randomString.generate();\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Move thaliMobileNativeWrapper._registerToNative() to teardown, skip iOS tests that do not work now because of #1924, add check in testForDataCorruption
|
675,375 |
17.07.2017 12:51:01
| -7,200 |
9197780ac774a509f8d2f465eccc73949385713d
|
Fix for fix testHttp to proper run multiple requests with every peer
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testHttp.js",
"new_path": "test/www/jxcore/bv_tests/testHttp.js",
"diff": "@@ -167,25 +167,26 @@ test('Single coordinated request ios native',\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n},\nfunction (t) {\n- var total = t.participants.length - 1;\n- var counter = 0;\n+ var numberOfParticipants = t.participants.length - 1;\nhttpServer.on('request', function (req, res) {\nvar reply = req.method + ' ' + req.url;\nres.end(reply);\n});\n- thaliMobileNativeTestUtils.executeZombieProofTestCoordinated(t, httpServer, function (connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, numberOfParticipants, function (connection, peer) {\n+ return new Promise(function (resolve, reject) {\nmakeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path')\n.then(function (response) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nt.equal(response.toString(), 'GET /path');\n- ++counter === total ? t.end() : t.pass();\n+ resolve();\n})\n.catch(t.fail)\n});\n});\n+ });\ntest('Multiple local http requests', function (t) {\nhttpServer.on('request', function (req, res) {\n@@ -223,11 +224,9 @@ test('Multiple coordinated request ios native',\nvar firstReply = 'firstReply';\nvar secondReply = 'secondReply';\nvar thirdReply = 'thirdReply';\n- var expectedReplies = [ firstReply, secondReply, thirdReply ];\nvar reply;\n- var total = t.participants.length - 1;\n- var counter = 0;\n+ var numberOfParticipants = t.participants.length - 1;\nhttpServer.on('request', function (req, res) {\nswitch (req.url) {\n@@ -246,15 +245,19 @@ test('Multiple coordinated request ios native',\nres.end(reply);\n});\n- thaliMobileNativeTestUtils.executeZombieProofTestCoordinated(t, httpServer, function (connection, peer) {\n- var localCounter = counter;\n-\n- makeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path' + localCounter)\n- .then(function (response) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, numberOfParticipants,\n+ function (connection, peer) {\n+ return Promise.all([\n+ makeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path0'),\n+ makeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path1'),\n+ makeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path2')\n+ ])\n+ .then(function (responses) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n- t.equal(response.toString(), expectedReplies[localCounter]);\n- ++counter === total ? t.end() : t.pass();\n+ t.equal(responses[0].toString(), firstReply);\n+ t.equal(responses[1].toString(), secondReply);\n+ t.equal(responses[2].toString(), thirdReply);\n})\n.catch(t.fail);\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -261,7 +261,7 @@ test('Can connect to a remote peer', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server, null,\nfunction (connection, peer) {\nreturn new Promise(function (resolve, reject) {\nlogger.info(connection);\n@@ -358,7 +358,7 @@ test('Can shift data', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server, null,\nfunction (connection, peer) {\nreturn new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -387,7 +387,7 @@ test('Can shift data via parallel connections',\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server, null,\nfunction (connection, peer) {\nreturn new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -460,7 +460,7 @@ test('Can shift data securely', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server, null,\nfunction (connection, peer) {\nreturn new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -491,7 +491,7 @@ test('Can shift large amounts of data', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server, null,\nfunction (connection, peer) {\nreturn new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"diff": "@@ -210,7 +210,7 @@ test('Get same port when trying to connect multiple times on iOS',\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server, null,\nfunction (currentConnection, currentTestPeer) {\nreturn new Promise(function (resolve, reject) {\npeerIdsToBeClosed.push(currentTestPeer.peerIdentifier);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -391,15 +391,17 @@ function removeFromAvailablePeers(availablePeers, peerToRemove) {\n* it checks if there are other peers available beside the one already tried.\n* @param {object} t test object.\n* @param {net.Server} server Server object\n+ * @param {number} numberOfCoordinatedParticipants amount of test participants that we will try to connect with\n* @param {function} testFunction\n*/\n-function executeZombieProofTest (t, server, testFunction) {\n+function executeZombieProofTest(t, server, numberOfCoordinatedParticipants, testFunction) {\nvar availablePeers = [];\nvar runningTest = false;\nvar peer;\nvar testTimeout = null;\nvar tryToConnectRetries = 0;\nvar areWeDone = false;\n+ var donePeers = 0;\nfunction tryToConnect() {\nif (testTimeout) {\n@@ -431,16 +433,28 @@ function executeZombieProofTest (t, server, testFunction) {\n.then(function (connection) {\ntestFunction(connection, peer)\n.then(function () {\n+ runningTest = false;\n+\nclearTimeout(testTimeout);\ntestTimeout = null;\n+ // When we finish with that peer, remove it from array so when\n+ // we call tryToConnect again, we won't try to connect with\n+ // that peer again.\n+ removeFromAvailablePeers(availablePeers, peer);\n+\n// In case we would fail with timeout with some other peer\n// we are good if we finished with one. So, we set a flag\n// and when this function will be called again but we will\n// be already done with any of peers, return.\n- if (!areWeDone) {\n+ // In case we run in coordinated mode, we want to connect\n+ // with every peer, so we call tryToConnect again until we will\n+ // successfully make request with every one.\n+ if (!numberOfCoordinatedParticipants && !areWeDone) {\nareWeDone = true;\nt.end();\n+ } else {\n+ ++donePeers === numberOfCoordinatedParticipants ? t.end() : tryToConnect();\n}\n});\n})\n@@ -448,6 +462,7 @@ function executeZombieProofTest (t, server, testFunction) {\nrunningTest = false;\nremoveFromAvailablePeers(availablePeers, peer);\n+\n// Don't try to connect if we previously failed with this peer\n// with error other than `Connection could not be established`.\nif (err.message === 'Connection could not be established') {\n@@ -455,9 +470,10 @@ function executeZombieProofTest (t, server, testFunction) {\npeer: peer\n});\n}\n-\ntryToConnect();\n});\n+ } else {\n+ logger.debug('Already running test!');\n}\n});\n}\n@@ -477,90 +493,14 @@ function executeZombieProofTest (t, server, testFunction) {\n});\nlogger.debug('We got a peer ' + JSON.stringify(peer));\n- tryToConnect();\n- }\n-\n- startAndListen(t, server, peerAvailabilityChangedHandler);\n-}\n-\n-module.exports.executeZombieProofTest = executeZombieProofTest;\n-\n-function checkIfPeerIsAlreadyPresent(peersArray, peer) {\n- var isPeerPresentInArray = false;\n-\n- peersArray.forEach(function (record) {\n- if (record.peer.peerIdentifier === peer.peerIdentifier) {\n- isPeerPresentInArray = true;\n- }\n- });\n-\n- return isPeerPresentInArray;\n-}\n-\n-/**\n- * Same as above, but every peer is treated individually, so we could exchange data\n- * with every available peer, not only one.\n- * @param {object} t test object.\n- * @param {net.Server} server Server object\n- * @param {function} testFunction\n- */\n-function executeZombieProofTestCoordinated (t, server, testFunction) {\n- var availablePeersAndTestingFlags = [];\n-\n- function tryToConnect() {\n- availablePeersAndTestingFlags.forEach(function (record) {\n- var runningTest = record.runningTest;\n- var peer = record.peer;\n-\n- if (!runningTest) {\n- record.runningTest = true;\n- connectToPeer(peer)\n- .then(function (connection) {\n- testFunction(connection, peer);\n- })\n- .catch(function (err) {\n- record.runningTest = false;\n- removeFromAvailablePeers(availablePeersAndTestingFlags, peer);\n-\n- // Don't try to connect if we previously failed with this peer\n- // with error other than `Connection could not be established`.\n- if (err.message === 'Connection could not be established') {\n- availablePeersAndTestingFlags.push(record);\n- }\n-\n- tryToConnect();\n- });\n- }\n- });\n- }\n-\n- // The peer we got here is in fact an one element array, so we\n- // have to treat it like array.\n- function peerAvailabilityChangedHandler(peerAsArray) {\n- var peer = peerAsArray[0];\n-\n- if (!peer.peerAvailable) {\n- removeFromAvailablePeers(availablePeersAndTestingFlags, peer);\n- return;\n- }\n-\n- // Don't add same peers but with different generations.\n- if (!checkIfPeerIsAlreadyPresent(availablePeersAndTestingFlags, peer)) {\n- availablePeersAndTestingFlags.push({\n- peer: peer,\n- runningTest: false\n- });\n- }\n-\n- logger.debug('We got a peer ' + JSON.stringify(peer));\ntryToConnect();\n}\nstartAndListen(t, server, peerAvailabilityChangedHandler);\n}\n-module.exports.executeZombieProofTestCoordinated = executeZombieProofTestCoordinated;\n+module.exports.executeZombieProofTest = executeZombieProofTest;\nfunction getConnectionToOnePeerAndTest(t, connectTest) {\nvar echoServer = net.createServer(function (socket) {\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Fix for #1941, fix testHttp to proper run multiple requests with every peer
|
675,375 |
17.07.2017 13:04:35
| -7,200 |
dd9567c79c7255de350eb89db2200838613d3c09
|
Remove recreatePeer on iOS devices in thaliMobileNativeWrapper, fix tests
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1779,8 +1779,8 @@ function(t) {\ntest('We properly fire peer unavailable and then available when ' +\n'connection fails on iOS',\nfunction () {\n- return !(platform.isIOS &&\n- global.NETWORK_TYPE === ThaliMobile.networkTypes.NATIVE);\n+ // We no longer do it, see discussion in #1924\n+ return true;\n},\nfunction(t) {\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"diff": "@@ -106,7 +106,7 @@ test('multiConnect properly fails on legal but non-existent peerID',\nt.ok(connectReturned, 'Should only get called after multiConnect ' +\n'returned');\nt.equal(originalSyncValue, syncValue, 'SyncValue matches');\n- t.equal(error, 'Connection could not be established',\n+ t.equal(error, 'Peer is unavailable',\n'Got right error');\nt.notOk(listeningPort, 'listeningPort is null');\nt.end();\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/wifiBasedNativeMock.js",
"new_path": "test/www/jxcore/lib/wifiBasedNativeMock.js",
"diff": "@@ -653,9 +653,15 @@ MobileCallInstance.prototype._connect =\nvar peerToConnect = peerAvailabilities[peerIdentifier];\nif (!peerToConnect) {\n+ if (platform.isAndroid) {\nsetImmediate(function () {\ncallback('Connection could not be established');\n});\n+ } else {\n+ setImmediate(function () {\n+ callback('Peer is unavailable');\n+ });\n+ }\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js",
"diff": "@@ -701,10 +701,6 @@ module.exports._multiConnect = function (peerIdentifier) {\nif (error) {\nreject(new Error(error));\n- if (error === 'Connection could not be established') {\n- recreatePeer(peerIdentifier);\n- }\n-\n}\nresolve(portNumber);\n@@ -1118,29 +1114,6 @@ function getPeerPort(peer) {\nPromise.resolve(null);\n}\n-function recreatePeer(peerIdentifier) {\n- var peerUnavailable = {\n- peerIdentifier: peerIdentifier,\n- peerAvailable: false,\n- portNumber: null,\n- recreated: true\n- };\n-\n- handlePeerAvailabilityChanged(peerUnavailable);\n-\n- var generation = peerGenerations[peerIdentifier];\n-\n- var peerAvailable = {\n- peerIdentifier: peerIdentifier,\n- peerAvailable: true,\n- generation: generation,\n- portNumber: null,\n- recreated: true\n- };\n-\n- handlePeerAvailabilityChanged(peerAvailable);\n-}\n-\n/**\n* This is used whenever discovery or advertising starts or stops. Since it's\n* possible for these to be stopped (in particular) due to events outside of\n@@ -1312,9 +1285,6 @@ module.exports._registerToNative = function () {\nconnectionType: connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK\n};\nmodule.exports.emitter.emit('failedNativeConnection', event);\n- if (failedConnection.error) {\n- recreatePeer(failedConnection.peerIdentifier);\n- }\n}\n);\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Remove recreatePeer on iOS devices in thaliMobileNativeWrapper, fix tests
|
675,375 |
19.07.2017 09:45:34
| -7,200 |
3b7bbcf969ff345829cf2ea7e4a3f9acaa9134c5
|
Disable tests relying on recreating peer logic
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobile.js",
"diff": "@@ -1140,9 +1140,8 @@ test('multiconnect failure - new peer is ignored (MPCF)',\ntest('multiconnect failure - cached peer fires peerAvailabilityChanged (MPCF)',\nfunction () {\n- return platform._isRealMobile ||\n- global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n- platform.isAndroid;\n+ // We no longer do it, see discussion in #1924\n+ return true;\n},\nfunction (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "+\n'use strict';\nvar ThaliMobile = require('thali/NextGeneration/thaliMobile');\n@@ -546,7 +547,8 @@ test('We fire failedNativeConnection event when we get failedConnection from ' +\ntest('We fire nonTCPPeerAvailabilityChangedEvent event when we get ' +\n'failedConnection from multiConnectConnection',\nfunction() {\n- return platform._isRealMobile;\n+ // We no longer do it, see discussion in #1924\n+ return true;\n},\nfunction (t) {\nthaliMobileNativeWrapper.start(express.Router())\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Disable tests relying on recreating peer logic
|
675,375 |
19.07.2017 09:47:07
| -7,200 |
a8e6b92cd12baf29ad5f2dd5bfe246d4c9d9aaa1
|
Call stop listening and advertising in testHttp teardown, move this logic to separate file
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testHttp.js",
"new_path": "test/www/jxcore/bv_tests/testHttp.js",
"diff": "@@ -18,11 +18,10 @@ var peerIdsToBeClosed = [];\nvar test = tape({\nsetup: function (t) {\nhttpServer = makeIntoCloseAllServer(http.createServer(), true);\n- ThaliMobileNativeWrapper._registerToNative();\nt.end();\n},\nteardown: function (t) {\n- Promise.resolve()\n+ thaliMobileNativeTestUtils.stopListeningAndAdvertising()\n.then(function () {\nif (!platform.isAndroid) {\nreturn thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n@@ -39,6 +38,7 @@ var test = tape({\n})\n.then(function () {\npeerIdsToBeClosed = [];\n+ ThaliMobileNativeWrapper._registerToNative();\nt.end();\n});\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js",
"diff": "@@ -42,17 +42,7 @@ var test = tape({\nteardown: function (t) {\nthaliMobileNativeTestUtils.multiConnectEmitter.removeAllListeners();\nserverToBeClosed.closeAll(function () {\n- Mobile('stopListeningForAdvertisements').callNative(function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call stopListeningForAdvertisements in teardown'\n- );\n- Mobile('stopAdvertisingAndListening').callNative(function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call stopAdvertisingAndListening in teardown'\n- );\n- Promise.resolve()\n+ thaliMobileNativeTestUtils.stopListeningAndAdvertising()\n.then(function () {\nif (!platform.isAndroid) {\nreturn thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n@@ -67,8 +57,6 @@ var test = tape({\nt.end();\n});\n});\n- });\n- });\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js",
"diff": "@@ -33,7 +33,7 @@ var test = tape({\n.then(function () {\nt.equals(thaliMobileNativeWrapper._isStarted(), false,\n'must be stopped');\n- Promise.resolve()\n+ thaliMobileNativeTestUtils.stopListeningAndAdvertising()\n.then(function () {\nif (!platform.isAndroid) {\nreturn thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js",
"diff": "@@ -39,17 +39,7 @@ var test = tape({\nteardown: function (t) {\nthaliMobileNativeTestUtils.multiConnectEmitter.removeAllListeners();\nserverToBeClosed.closeAll(function () {\n- Mobile('stopListeningForAdvertisements').callNative(function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call stopListeningForAdvertisements in teardown'\n- );\n- Mobile('stopAdvertisingAndListening').callNative(function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call stopAdvertisingAndListening in teardown'\n- );\n- Promise.resolve()\n+ thaliMobileNativeTestUtils.stopListeningAndAdvertising()\n.then(function () {\nif (!platform.isAndroid) {\nreturn thaliMobileNativeTestUtils.killAllMultiConnectConnections(peerIdsToBeClosed);\n@@ -64,8 +54,6 @@ var test = tape({\nt.end();\n});\n});\n- });\n- });\n}\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js",
"diff": "@@ -564,3 +564,17 @@ function killAllMultiConnectConnections(peerIdsToBeClosed) {\n}\nmodule.exports.killAllMultiConnectConnections = killAllMultiConnectConnections;\n+\n+function stopListeningAndAdvertising() {\n+ return new Promise(function (resolve, reject) {\n+ Mobile('stopListeningForAdvertisements').callNative(function (err) {\n+ if (err) reject('Should be able to call stopListeningForAdvertisements');\n+\n+ Mobile('stopAdvertisingAndListening').callNative(function (err) {\n+ !err ? resolve() : reject('Should be able to call stopAdvertisingAndListening');\n+ });\n+ });\n+ });\n+}\n+\n+module.exports.stopListeningAndAdvertising = stopListeningAndAdvertising;\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Call stop listening and advertising in testHttp teardown, move this logic to separate file
|
675,375 |
19.07.2017 13:20:08
| -7,200 |
be2f3e7bcd913c6debde14d22e5d11900010fcc6
|
Make sure we stop every instance of NotificationClient in order to avoid having multiple listeners for peerAvailabilityChanged event.
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js",
"new_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js",
"diff": "@@ -343,6 +343,7 @@ test('Notification action killed with a superseded',\nnotificationClient.Events.PeerAdvertisesDataForUs,\nnotificationHandler\n);\n+ notificationClient.stop();\nt.end();\n});\n});\n@@ -520,6 +521,7 @@ test('Resolves an action locally using ThaliPeerPoolDefault', tape.sinonTest(fun\nres.peerId,\nglobals.TCPEvent.peerIdentifier,\n'peerIds must match');\n+ notificationClient.stop();\nt.end();\n}\n);\n@@ -751,6 +753,7 @@ test('notificationClient does not retry action with BAD_PEER resolution',\n'peer state should be RESOLVED');\n})\n.then(function () {\n+ notificationClient.stop();\nt.end();\n});\n};\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Make sure we stop every instance of NotificationClient in order to avoid having multiple listeners for peerAvailabilityChanged event.
|
675,371 |
25.07.2017 15:30:30
| -7,200 |
22939a4094c2d32efa3523c7aec4374897f12086
|
Updated versions of 3rd party libraries
|
[
{
"change_type": "MODIFY",
"old_path": "thali/install/validateBuildEnvironment.js",
"new_path": "thali/install/validateBuildEnvironment.js",
"diff": "@@ -13,13 +13,13 @@ const assert = require('assert');\nconst versions =\n{\n- xcode: '8.2.1',\n+ xcode: '8.3.3',\nxcodeCommandLineTools: ' ',\n- macOS: '10.12.3',\n- node: '6.9.1',\n- npm: '3.10.8',\n- brew: '1.1.',\n- ruby: '2.3.0p0',\n+ macOS: '10.12.6',\n+ node: '6.11.1',\n+ npm: '3.10.10',\n+ brew: '1.2.4',\n+ ruby: '2.4.1p111',\nwget: '1.18',\njxcore: '0.3.1.12',\nandroidHome: ' ',\n@@ -28,13 +28,13 @@ const versions =\n// We don't have an easy way to identify the version of the support libraries\n// we have but if they were installed recently enough then they will have\n// what we need.\n- androidSupportLibraries: '41.0.0',\n+ androidSupportLibraries: '47.0.0',\npython: '2.7.10',\n- cordova: '6.4.0',\n- java: '1.8.0_102',\n- git: '2.10.0',\n- swiftlint: '0.17.0',\n- carthage: '0.20.0',\n+ cordova: '6.5.0',\n+ java: '1.8.0_141',\n+ git: '2.13.1',\n+ swiftlint: '0.20.1',\n+ carthage: '0.24.0',\nsinopiaNode: ' ',\nsinopiaJxCore: ' '\n};\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Updated versions of 3rd party libraries
|
675,371 |
24.08.2017 15:26:17
| -7,200 |
8f8a0449cc92e4d454c0ed7146783a92a16ce70c
|
Update jxcore-cordova to 0.1.14 version, update readme.md
|
[
{
"change_type": "MODIFY",
"old_path": "readme.md",
"new_path": "readme.md",
"diff": "@@ -298,7 +298,7 @@ set PATH=%PATH%;%ANDROID_HOME%\\tools;%ANDROID_HOME%\\platform-tools\n```\n-`<installation location>` can vary on different platforms but it's something that containes `android` in path and with folders inside like `etc`, `platforms`,`samples`,`tools` and so on.\n+`<installation location>` can vary on different platforms but it's something that contains `android` in path and with folders inside like `etc`, `platforms`,`samples`,`tools` and so on.\nReal life Mac OS `~/.bash_profile` example:\n```\n@@ -311,29 +311,29 @@ Current API target level is `android-21`\n### iOS\n-Download [Xcode 6](https://developer.apple.com/xcode/), or later.\n+Download [Xcode 8](https://developer.apple.com/xcode/), or later.\n## Getting Started\n### Install latest JXCore\n-The installation guide for JXCore 3.1.10 on Mac OS and Windows can be found [here](https://github.com/thaliproject/jxbuild/blob/master/distribute.md).\n+The installation guide for JXCore 3.1.14 on Mac OS and Windows can be found [here](https://github.com/thaliproject/jxbuild/blob/master/distribute.md).\n-The latest version of JXCore 3.1.10 only for Mac OS can be downloaded from [here](https://jxcore.blob.core.windows.net/jxcore-release/jxcore/03110/release/jx_osx64v8.zip)\n+The latest version of JXCore 3.1.14 only for Mac OS can be downloaded from [here](https://jxcore.blob.core.windows.net/jxcore-release/jxcore/03114/release/jx_osx64v8.zip)\nTo check the version of the current JXCore installation run:\n```\n$ jx -jxv\n-v 0.3.1.10\n+v 0.3.1.14\n```\n### Install Cordova\n-(Check the [Android Platform Guide](https://cordova.apache.org/docs/en/4.0.0/guide_platforms_android_index.md.html#Android%20Platform%20Guide)\n-and [iOS Platform Guide](https://cordova.apache.org/docs/en/4.0.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide) for detailed instructions.)\n+(Check the [Android Platform Guide](https://cordova.apache.org/docs/en/6.x/guide/platforms/android/index.html)\n+and [iOS Platform Guide](https://cordova.apache.org/docs/en/6.x/guide/platforms/ios/index.html) for detailed instructions.)\n```\n-$ npm install -g cordova@6.4.0\n+$ npm install -g cordova@6.5.0\n```\n### Create a Cordova project\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/install/validateBuildEnvironment.js",
"new_path": "thali/install/validateBuildEnvironment.js",
"diff": "@@ -21,7 +21,7 @@ const versions =\nbrew: '1.2.',\nruby: '2.4.1p111',\nwget: '1.18',\n- jxcore: '0.3.1.12',\n+ jxcore: '0.3.1.14',\nandroidHome: ' ',\nandroidBuildTools: thaliConfig.thaliInstall.androidConfig.buildToolsVersion,\nandroidPlatform: thaliConfig.thaliInstall.androidConfig.compileSdkVersion,\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/package.json",
"new_path": "thali/package.json",
"diff": "\"compileSdkVersion\": \"android-25\"\n},\n\"btconnectorlib2\": \"0.3.9\",\n- \"jxcore-cordova\": \"0.1.12\",\n- \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.12/release/io.jxcore.node.jx\"\n+ \"jxcore-cordova\": \"0.1.14\",\n+ \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.14/release/io.jxcore.node.jx\"\n},\n\"scripts\": {\n\"prepublish\": \"node install/prePublishThaliCordovaPlugin.js\",\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Update jxcore-cordova to 0.1.14 version, update readme.md
|
675,375 |
19.09.2017 13:52:56
| -7,200 |
1cee6486fd4753fd2b7ac3abbdef1571e6271d94
|
Add parameter when starting Replication action to provide custom No activity timeout value
|
[
{
"change_type": "MODIFY",
"old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js",
"new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js",
"diff": "@@ -442,6 +442,111 @@ test('Do something and make sure we time out',\n}\n);\n+test('Replication timer should use custom timeout value when its provided when calling start',\n+ function (t) {\n+ function onServerSetUp (serverPort, randomDBName) {\n+ var thaliReplicationPeerAction = null;\n+ var notificationForUs = {\n+ keyId: new Buffer('abcdefg'),\n+ portNumber: serverPort,\n+ hostAddress: '127.0.0.1',\n+ pskIdentifyField: pskId,\n+ psk: pskKey,\n+ suggestedTCPTimeout: 10000,\n+ connectionType: thaliMobileNativeWrapper.connectionTypes.TCP_NATIVE\n+ };\n+ // Using a different directory really shouldn't make any difference\n+ // to this particular test but I'm being paranoid\n+ var DifferentDirectoryPouch = testUtils.getLevelDownPouchDb();\n+ // Change default value to 2, so we will be sure that timer is using our value\n+ var originalTimeout = ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS;\n+ ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = 2;\n+ var customTimeout = 6;\n+ var replicationActionEnd = false;\n+\n+ thaliReplicationPeerAction =\n+ new ThaliReplicationPeerAction(notificationForUs,\n+ DifferentDirectoryPouch, randomDBName,\n+ devicePublicKey);\n+\n+ setTimeout(function () {\n+ if (!replicationActionEnd) {\n+ t.fail('Replication timer should use custom timeout value');\n+ }\n+ }, 4);\n+\n+ thaliReplicationPeerAction.start(httpAgentPool, randomDBName, customTimeout)\n+ .then(function () {\n+ t.fail('We should have failed with time out.');\n+ })\n+ .catch(function (err) {\n+ replicationActionEnd = true;\n+ t.equal(thaliReplicationPeerAction.getActionState(),\n+ PeerAction.actionState.KILLED,\n+ 'action should be killed');\n+ t.equal(err.message, 'No activity time out', 'Error should be timed ' +\n+ 'out');\n+\n+ ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = originalTimeout;\n+ t.end();\n+ });\n+ }\n+ testCloseAllServer = testUtils.setUpServer(onServerSetUp);\n+ }\n+);\n+\n+test('Replication timer should use default timeout value when its not provided when calling start',\n+ function (t) {\n+ function onServerSetUp (serverPort, randomDBName) {\n+ var thaliReplicationPeerAction = null;\n+ var notificationForUs = {\n+ keyId: new Buffer('abcdefg'),\n+ portNumber: serverPort,\n+ hostAddress: '127.0.0.1',\n+ pskIdentifyField: pskId,\n+ psk: pskKey,\n+ suggestedTCPTimeout: 10000,\n+ connectionType: thaliMobileNativeWrapper.connectionTypes.TCP_NATIVE\n+ };\n+ // Using a different directory really shouldn't make any difference\n+ // to this particular test but I'm being paranoid\n+ var DifferentDirectoryPouch = testUtils.getLevelDownPouchDb();\n+ // Change default value to 2, so we will be sure that timer is using our value\n+ var originalTimeout = ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS;\n+ ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = 4;\n+ var replicationActionEnd = false;\n+\n+ thaliReplicationPeerAction =\n+ new ThaliReplicationPeerAction(notificationForUs,\n+ DifferentDirectoryPouch, randomDBName,\n+ devicePublicKey);\n+\n+ setTimeout(function () {\n+ if (!replicationActionEnd) {\n+ t.fail('Replication timer should use custom timeout value');\n+ }\n+ }, ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS - 2);\n+\n+ thaliReplicationPeerAction.start(httpAgentPool)\n+ .then(function () {\n+ t.fail('We should have failed with time out.');\n+ })\n+ .catch(function (err) {\n+ replicationActionEnd = true;\n+ t.equal(thaliReplicationPeerAction.getActionState(),\n+ PeerAction.actionState.KILLED,\n+ 'action should be killed');\n+ t.equal(err.message, 'No activity time out', 'Error should be timed ' +\n+ 'out');\n+\n+ ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = originalTimeout;\n+ t.end();\n+ });\n+ }\n+ testCloseAllServer = testUtils.setUpServer(onServerSetUp);\n+ }\n+);\n+\ntest('Start replicating and then catch error when server goes', function (t) {\nvar requestCount = 0;\nfunction killServer(app) {\n"
},
{
"change_type": "MODIFY",
"old_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js",
"new_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js",
"diff": "@@ -118,15 +118,18 @@ ThaliReplicationPeerAction.prototype.clone = function () {\n* actually doing useful work. This timer however is connected directly to the\n* changes feed and so can see if 'useful' work is happening and time out if it\n* is not.\n+ * @param {Number} maxIdlePeriodSeconds Number of seconds of no activity that we\n+ * will wait before killing the action. Be default we wait 3s, but because of #1961,\n+ * we provide optional parameter that can be used by policy manager.\n* @private\n*/\n-ThaliReplicationPeerAction.prototype._replicationTimer = function () {\n+ThaliReplicationPeerAction.prototype._replicationTimer = function (maxIdlePeriodSeconds) {\nvar self = this;\nif (self._refreshTimerManager) {\nself._refreshTimerManager.stop();\n}\nself._refreshTimerManager = new RefreshTimerManager(\n- ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS * 1000,\n+ !!maxIdlePeriodSeconds ? maxIdlePeriodSeconds * 1000 : ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS * 1000,\nfunction() {\nself._complete([new Error('No activity time out')]);\n});\n@@ -193,13 +196,16 @@ ThaliReplicationPeerAction.prototype._replicationTimer = function () {\n* @param {string} [remoteDbName] Optional parameter that specifies name of remote\n* DB that we will try to replicate with. This parameter is used to create a proper\n* url to remote database. If it is not provided, for example by\n+ * @param {Number} maxIdlePeriodSeconds Number of seconds of no activity that we\n+ * will wait before killing the action. Be default we wait 3s, but because of #1961,\n+ * we provide optional parameter that can be used by policy manager.\n* {@link module:thaliPeerPoolInterface~ThaliPeerPoolInterface} custom implementation,\n* we assume that the remote DB name is the same as our local one. The reason why it is\n* not provided in constructor is that at the time of creating instance of this object,\n* we simply don't know such information.\n* @returns {Promise<?Error>}\n*/\n-ThaliReplicationPeerAction.prototype.start = function (httpAgentPool, remoteDbName) {\n+ThaliReplicationPeerAction.prototype.start = function (httpAgentPool, remoteDbName, maxIdlePeriodSeconds) {\nvar self = this;\nthis._completed = false;\n@@ -223,7 +229,7 @@ ThaliReplicationPeerAction.prototype.start = function (httpAgentPool, remoteDbNa\nself._replicationPromise = new Promise(function (resolve, reject) {\nself._resolve = resolve;\nself._reject = reject;\n- self._replicationTimer();\n+ self._replicationTimer(maxIdlePeriodSeconds);\nself._cancelReplication = remoteDB.replicate.to(self._localDbName, {\nlive: true\n})\n"
}
] |
JavaScript
|
MIT License
|
thaliproject/thali_cordovaplugin
|
Add parameter when starting Replication action to provide custom No activity timeout value
|
141,906 |
21.11.2017 21:50:48
| -28,800 |
af33209be0592db1d27f26caa777c529bb15f48c
|
Active connection, status bar and new query
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"command\": \"mysql.runQuery\",\n\"title\": \"Run MySQL Query\"\n},\n+ {\n+ \"command\": \"mysql.newQuery\",\n+ \"title\": \"New Query\"\n+ },\n{\n\"command\": \"mysql.selectTop1000\",\n\"title\": \"Select Top 1000\"\n\"group\": \"navigation@1\"\n}],\n\"view/item/context\": [{\n+ \"command\": \"mysql.newQuery\",\n+ \"when\": \"view == mysql && viewItem == database\"\n+ },\n+ {\n\"command\": \"mysql.selectTop1000\",\n\"when\": \"view == mysql && viewItem == table\"\n- }]\n+ }\n+ ]\n}\n},\n\"scripts\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/global.ts",
"new_path": "src/common/global.ts",
"diff": "@@ -3,5 +3,29 @@ import * as vscode from \"vscode\";\nimport { IConnection } from \"../model/connection\";\nexport class Global {\n- public static activeConnection: IConnection;\n+ static get activeConnection(): IConnection {\n+ return Global._activeConnection;\n+ }\n+\n+ static set activeConnection(newActiveConnection: IConnection) {\n+ this._activeConnection = newActiveConnection;\n+ Global.updateStatusBarItems(newActiveConnection);\n+ }\n+\n+ public static updateStatusBarItems(activeConnection: IConnection) {\n+ if (Global.mysqlStatusBarItem) {\n+ Global.mysqlStatusBarItem.text = Global.getStatusBarItemText(activeConnection);\n+ } else {\n+ Global.mysqlStatusBarItem = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);\n+ Global.mysqlStatusBarItem.text = Global.getStatusBarItemText(activeConnection);\n+ Global.mysqlStatusBarItem.show();\n+ }\n+ }\n+\n+ private static _activeConnection: IConnection;\n+ private static mysqlStatusBarItem: vscode.StatusBarItem;\n+\n+ private static getStatusBarItemText(activeConnection: IConnection): string {\n+ return `$(server) ${activeConnection.host}` + (activeConnection.database ? ` $(database) ${activeConnection.database}` : \"\");\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -18,7 +18,14 @@ export class Utility {\n}\npublic static runQuery() {\n- // TODO\n+ if (!vscode.window.activeTextEditor) {\n+ vscode.window.showWarningMessage(\"SQL file not selected\");\n+ return;\n+ }\n+ if (!Global.activeConnection) {\n+ vscode.window.showWarningMessage(\"Database not selected\");\n+ return;\n+ }\nconst sql = vscode.window.activeTextEditor.document.getText();\nconst connection = mysql.createConnection(Global.activeConnection);\nUtility.queryPromise<any[]>(connection, sql)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "\"use strict\";\nimport * as vscode from \"vscode\";\nimport { Utility } from \"./common/utility\";\n+import { DatabaseNode } from \"./model/databaseNode\";\nimport { TableNode } from \"./model/tableNode\";\nimport { MySQLTreeDataProvider } from \"./mysqlTreeDataProvider\";\n@@ -16,6 +17,10 @@ export function activate(context: vscode.ExtensionContext) {\nUtility.runQuery();\n}));\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.newQuery\", (databaseNode: DatabaseNode) => {\n+ databaseNode.newQuery();\n+ }));\n+\ncontext.subscriptions.push(vscode.commands.registerCommand(\"mysql.selectTop1000\", (tableNode: TableNode) => {\ntableNode.selectTop1000();\n}));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connection.ts",
"new_path": "src/model/connection.ts",
"diff": "@@ -2,11 +2,6 @@ export interface IConnection {\nreadonly host: string;\nreadonly user: string;\nreadonly password: string;\n+ readonly port: number;\nreadonly database?: string;\n}\n-\n-interface IConnection2 {\n- readonly host: string;\n- readonly user: string;\n- readonly password: string;\n-}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "@@ -7,7 +7,7 @@ import { InfoNode } from \"./infoNode\";\nimport { INode } from \"./INode\";\nexport class ConnectionNode implements INode {\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string) {\n+ constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: number) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -23,11 +23,12 @@ export class ConnectionNode implements INode {\nhost: this.host,\nuser: this.user,\npassword: this.password,\n+ port: this.port,\n});\nreturn Utility.queryPromise<any[]>(connection, \"SHOW DATABASES\")\n.then((databases) => {\nreturn databases.map<DatabaseNode>((database) => {\n- return new DatabaseNode(this.host, this.user, this.password, database.Database);\n+ return new DatabaseNode(this.host, this.user, this.password, this.port, database.Database);\n});\n})\n.catch((err) => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/databaseNode.ts",
"diff": "import * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n+import { Global } from \"../common/global\";\nimport { Utility } from \"../common/utility\";\nimport { InfoNode } from \"./infoNode\";\nimport { INode } from \"./INode\";\nimport { TableNode } from \"./tableNode\";\nexport class DatabaseNode implements INode {\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly database: string) {\n+ constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: number, private readonly database: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -23,16 +24,30 @@ export class DatabaseNode implements INode {\nhost: this.host,\nuser: this.user,\npassword: this.password,\n+ port: this.port,\ndatabase: this.database,\n});\n- return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT 50`)\n+ return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT 100`)\n.then((tables) => {\nreturn tables.map<TableNode>((table) => {\n- return new TableNode(this.host, this.user, this.password, this.database, table.TABLE_NAME);\n+ return new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME);\n});\n})\n.catch((err) => {\nreturn [new InfoNode(err)];\n});\n}\n+\n+ public async newQuery() {\n+ const textDocument = await vscode.workspace.openTextDocument({ content: \"\", language: \"sql\" });\n+ vscode.window.showTextDocument(textDocument);\n+\n+ Global.activeConnection = {\n+ host: this.host,\n+ user: this.user,\n+ password: this.password,\n+ port: this.port,\n+ database: this.database,\n+ };\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/tableNode.ts",
"new_path": "src/model/tableNode.ts",
"diff": "@@ -7,7 +7,8 @@ import { Utility } from \"../common/utility\";\nimport { INode } from \"./INode\";\nexport class TableNode implements INode {\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly database: string, private readonly table: string) {\n+ constructor(private readonly host: string, private readonly user: string, private readonly password: string,\n+ private readonly port: number, private readonly database: string, private readonly table: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -27,19 +28,15 @@ export class TableNode implements INode {\nconst textDocument = await vscode.workspace.openTextDocument({ content: sql, language: \"sql\" });\nvscode.window.showTextDocument(textDocument);\n- const connection = mysql.createConnection({\n- host: this.host,\n- user: this.user,\n- password: this.password,\n- database: this.database,\n- });\n- // TODO\nGlobal.activeConnection = {\nhost: this.host,\nuser: this.user,\npassword: this.password,\n+ port: this.port,\ndatabase: this.database,\n};\n+\n+ const connection = mysql.createConnection(Global.activeConnection);\nUtility.queryPromise<any[]>(connection, sql)\n.then((result) => {\nOutputChannel.appendLine(JSON.stringify(result, null, 2));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/mysqlTreeDataProvider.ts",
"new_path": "src/mysqlTreeDataProvider.ts",
"diff": "@@ -30,9 +30,10 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\nconnections = [];\n}\nconnections.push({\n- host: \"abc\",\n+ host: \"hendry-mysql.mysql.database.azure.com\",\nuser: \"mysqluser@hendry-mysql\",\npassword: \"\",\n+ port: 3306,\n});\nawait this.context.globalState.update(Constants.GlobalStateMySQLConectionsKey, connections);\nthis.refresh();\n@@ -45,7 +46,7 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\nprivate getConnectionNodes(): ConnectionNode[] {\nconst connections = this.context.globalState.get<IConnection[]>(Constants.GlobalStateMySQLConectionsKey);\nreturn connections.map<ConnectionNode>((connection) => {\n- return new ConnectionNode(connection.host, connection.user, connection.password);\n+ return new ConnectionNode(connection.host, connection.user, connection.password, connection.port);\n});\n}\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Active connection, status bar and new query
|
141,906 |
22.11.2017 14:05:13
| -28,800 |
bc1649e1d2d67ce58c1cec5b8e3377d4811c983b
|
keytar, add/delete connection, refresh node
|
[
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "\"lockfileVersion\": 1,\n\"requires\": true,\n\"dependencies\": {\n+ \"@types/keytar\": {\n+ \"version\": \"4.0.1\",\n+ \"resolved\": \"https://registry.npmjs.org/@types/keytar/-/keytar-4.0.1.tgz\",\n+ \"integrity\": \"sha512-loKBID6UL4QjhD2scuvv6oAPlQ/WAY7aYTDyKlKo7fIgriLS8EZExqT567cHL5CY6si51MRoX1+r3mitD3eYrA==\",\n+ \"dev\": true\n+ },\n\"@types/mocha\": {\n\"version\": \"2.2.44\",\n\"resolved\": \"https://registry.npmjs.org/@types/mocha/-/mocha-2.2.44.tgz\",\n\"uuid\": {\n\"version\": \"3.1.0\",\n\"resolved\": \"https://registry.npmjs.org/uuid/-/uuid-3.1.0.tgz\",\n- \"integrity\": \"sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==\",\n- \"dev\": true\n+ \"integrity\": \"sha512-DIWtzUkw04M4k3bf1IcpS2tngXEL26YUD2M0tMDUpnUrz2hgzUBlD55a4FjdLGPvfHxS6uluGWvaVEqgBcVa+g==\"\n},\n\"vali-date\": {\n\"version\": \"1.0.0\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"main\": \"./out/extension\",\n\"contributes\": {\n\"views\": {\n- \"explorer\": [{\n+ \"explorer\": [\n+ {\n\"id\": \"mysql\",\n\"name\": \"MySQL\"\n- }]\n+ }\n+ ]\n},\n- \"commands\": [{\n+ \"commands\": [\n+ {\n+ \"command\": \"mysql.refresh\",\n+ \"title\": \"Refresh\"\n+ },\n+ {\n\"command\": \"mysql.add\",\n\"title\": \"Add\"\n},\n+ {\n+ \"command\": \"mysql.deleteConnection\",\n+ \"title\": \"Delete Connection\"\n+ },\n{\n\"command\": \"mysql.runQuery\",\n\"title\": \"Run MySQL Query\"\n}\n],\n\"menus\": {\n- \"editor/context\": [{\n+ \"editor/context\": [\n+ {\n\"command\": \"mysql.runQuery\",\n\"when\": \"editorLangId == sql\",\n\"group\": \"navigation\"\n- }],\n- \"view/title\": [{\n+ }\n+ ],\n+ \"view/title\": [\n+ {\n\"command\": \"mysql.add\",\n\"when\": \"view == mysql\",\n\"group\": \"navigation@1\"\n- }],\n- \"view/item/context\": [{\n+ }\n+ ],\n+ \"view/item/context\": [\n+ {\n+ \"command\": \"mysql.refresh\",\n+ \"when\": \"view == mysql && viewItem == connection\",\n+ \"group\": \"mysql@0\"\n+ },\n+ {\n+ \"command\": \"mysql.deleteConnection\",\n+ \"when\": \"view == mysql && viewItem == connection\",\n+ \"group\": \"mysql@1\"\n+ },\n+ {\n+ \"command\": \"mysql.refresh\",\n+ \"when\": \"view == mysql && viewItem == database\",\n+ \"group\": \"mysql@0\"\n+ },\n+ {\n\"command\": \"mysql.newQuery\",\n- \"when\": \"view == mysql && viewItem == database\"\n+ \"when\": \"view == mysql && viewItem == database\",\n+ \"group\": \"mysql@1\"\n},\n{\n\"command\": \"mysql.selectTop1000\",\n- \"when\": \"view == mysql && viewItem == table\"\n+ \"when\": \"view == mysql && viewItem == table\",\n+ \"group\": \"mysql@0\"\n}\n]\n}\n\"test\": \"npm run compile && node ./node_modules/vscode/bin/test\"\n},\n\"devDependencies\": {\n+ \"@types/keytar\": \"^4.0.1\",\n\"@types/mocha\": \"^2.2.42\",\n\"@types/node\": \"^7.0.43\",\n\"tslint\": \"^5.8.0\",\n\"vscode\": \"^1.1.6\"\n},\n\"dependencies\": {\n- \"mysql\": \"^2.15.0\"\n+ \"mysql\": \"^2.15.0\",\n+ \"uuid\": \"^3.1.0\"\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "\"user strict\";\nexport class Constants {\n+ public static ExtensionId = \"formulahendry.vscode-mysql\";\npublic static GlobalStateMySQLConectionsKey = \"mysql.connections\";\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/global.ts",
"new_path": "src/common/global.ts",
"diff": "\"use strict\";\n+import * as keytarType from \"keytar\";\nimport * as vscode from \"vscode\";\nimport { IConnection } from \"../model/connection\";\nexport class Global {\n+ public static keytar: typeof keytarType = require(`${vscode.env.appRoot}/node_modules/keytar`);\n+\nstatic get activeConnection(): IConnection {\nreturn Global._activeConnection;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "\"use strict\";\nimport * as vscode from \"vscode\";\nimport { Utility } from \"./common/utility\";\n+import { ConnectionNode } from \"./model/connectionNode\";\nimport { DatabaseNode } from \"./model/databaseNode\";\n+import { INode } from \"./model/INode\";\nimport { TableNode } from \"./model/tableNode\";\nimport { MySQLTreeDataProvider } from \"./mysqlTreeDataProvider\";\n@@ -9,10 +11,18 @@ export function activate(context: vscode.ExtensionContext) {\nconst mysqlTreeDataProvider = new MySQLTreeDataProvider(context);\ncontext.subscriptions.push(vscode.window.registerTreeDataProvider(\"mysql\", mysqlTreeDataProvider));\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.refresh\", (node: INode) => {\n+ mysqlTreeDataProvider.refresh(node);\n+ }));\n+\ncontext.subscriptions.push(vscode.commands.registerCommand(\"mysql.add\", () => {\nmysqlTreeDataProvider.addConnection();\n}));\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.deleteConnection\", (connectionNode: ConnectionNode) => {\n+ connectionNode.deleteConnection(context, mysqlTreeDataProvider);\n+ }));\n+\ncontext.subscriptions.push(vscode.commands.registerCommand(\"mysql.runQuery\", () => {\nUtility.runQuery();\n}));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connection.ts",
"new_path": "src/model/connection.ts",
"diff": "export interface IConnection {\nreadonly host: string;\nreadonly user: string;\n- readonly password: string;\n- readonly port: number;\n+ readonly password?: string;\n+ readonly port: string;\nreadonly database?: string;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "import * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n+import { Constants } from \"../common/constants\";\n+import { Global } from \"../common/global\";\nimport { Utility } from \"../common/utility\";\n+import { MySQLTreeDataProvider } from \"../mysqlTreeDataProvider\";\n+import { IConnection } from \"./connection\";\nimport { DatabaseNode } from \"./databaseNode\";\nimport { InfoNode } from \"./infoNode\";\nimport { INode } from \"./INode\";\nexport class ConnectionNode implements INode {\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: number) {\n+ constructor(private readonly id: string, private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -35,4 +39,14 @@ export class ConnectionNode implements INode {\nreturn [new InfoNode(err)];\n});\n}\n+\n+ public async deleteConnection(context: vscode.ExtensionContext, mysqlTreeDataProvider: MySQLTreeDataProvider) {\n+ const connections = context.globalState.get<{ [key: string]: IConnection }>(Constants.GlobalStateMySQLConectionsKey);\n+ delete connections[this.id];\n+ await context.globalState.update(Constants.GlobalStateMySQLConectionsKey, connections);\n+\n+ await Global.keytar.deletePassword(Constants.ExtensionId, this.id);\n+\n+ mysqlTreeDataProvider.refresh();\n+ }\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/databaseNode.ts",
"diff": "@@ -8,7 +8,7 @@ import { INode } from \"./INode\";\nimport { TableNode } from \"./tableNode\";\nexport class DatabaseNode implements INode {\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: number, private readonly database: string) {\n+ constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: string, private readonly database: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/tableNode.ts",
"new_path": "src/model/tableNode.ts",
"diff": "@@ -8,7 +8,7 @@ import { INode } from \"./INode\";\nexport class TableNode implements INode {\nconstructor(private readonly host: string, private readonly user: string, private readonly password: string,\n- private readonly port: number, private readonly database: string, private readonly table: string) {\n+ private readonly port: string, private readonly database: string, private readonly table: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/mysqlTreeDataProvider.ts",
"new_path": "src/mysqlTreeDataProvider.ts",
"diff": "import * as path from \"path\";\n+import * as uuidv1 from \"uuid/v1\";\nimport * as vscode from \"vscode\";\nimport { Constants } from \"./common/constants\";\n+import { Global } from \"./common/global\";\nimport { IConnection } from \"./model/connection\";\nimport { ConnectionNode } from \"./model/connectionNode\";\nimport { INode } from \"./model/INode\";\n@@ -25,28 +27,59 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\n}\npublic async addConnection() {\n- let connections = this.context.globalState.get<IConnection[]>(Constants.GlobalStateMySQLConectionsKey);\n+ const host = await vscode.window.showInputBox({ prompt: \"The hostname of the database\", placeHolder: \"host\", ignoreFocusOut: true });\n+ if (!host) {\n+ return;\n+ }\n+\n+ const user = await vscode.window.showInputBox({ prompt: \"The MySQL user to authenticate as\", placeHolder: \"user\", ignoreFocusOut: true });\n+ if (!user) {\n+ return;\n+ }\n+\n+ const password = await vscode.window.showInputBox({ prompt: \"The password of the MySQL user\", placeHolder: \"password\", ignoreFocusOut: true, password: true });\n+ if (password === undefined) {\n+ return;\n+ }\n+\n+ const port = await vscode.window.showInputBox({ prompt: \"The port number to connect to\", placeHolder: \"port\", ignoreFocusOut: true, value: \"3306\" });\n+ if (!port) {\n+ return;\n+ }\n+\n+ let connections = this.context.globalState.get<{ [key: string]: IConnection }>(Constants.GlobalStateMySQLConectionsKey);\n+\nif (!connections) {\n- connections = [];\n- }\n- connections.push({\n- host: \"hendry-mysql.mysql.database.azure.com\",\n- user: \"mysqluser@hendry-mysql\",\n- password: \"\",\n- port: 3306,\n- });\n+ connections = {};\n+ }\n+\n+ const id = uuidv1();\n+ connections[id] = {\n+ host,\n+ user,\n+ port,\n+ };\n+\n+ if (password) {\n+ await Global.keytar.setPassword(Constants.ExtensionId, id, password);\n+ }\nawait this.context.globalState.update(Constants.GlobalStateMySQLConectionsKey, connections);\nthis.refresh();\n}\n- private refresh(element?: INode): void {\n+ public refresh(element?: INode): void {\nthis._onDidChangeTreeData.fire(element);\n}\n- private getConnectionNodes(): ConnectionNode[] {\n- const connections = this.context.globalState.get<IConnection[]>(Constants.GlobalStateMySQLConectionsKey);\n- return connections.map<ConnectionNode>((connection) => {\n- return new ConnectionNode(connection.host, connection.user, connection.password, connection.port);\n- });\n+ private async getConnectionNodes(): Promise<ConnectionNode[]> {\n+ const connections = this.context.globalState.get<{ [key: string]: IConnection }>(Constants.GlobalStateMySQLConectionsKey);\n+ const ConnectionNodes = [];\n+ if (connections) {\n+ for (const id of Object.keys(connections)) {\n+ const password = await Global.keytar.getPassword(Constants.ExtensionId, id);\n+ ConnectionNodes.push(new ConnectionNode(id, connections[id].host, connections[id].user, password, connections[id].port));\n+ }\n+ }\n+ return ConnectionNodes;\n}\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
keytar, add/delete connection, refresh node
|
141,906 |
24.11.2017 20:26:27
| -28,800 |
1f9493f1326e3938e1ec9201cbce00fdad2609f8
|
Better output format: display output as table
|
[
{
"change_type": "MODIFY",
"old_path": "package-lock.json",
"new_path": "package-lock.json",
"diff": "\"integrity\": \"sha1-iYUI2iIm84DfkEcoRWhJwVAaSw0=\",\n\"dev\": true\n},\n+ \"asciitable\": {\n+ \"version\": \"0.0.7\",\n+ \"resolved\": \"https://registry.npmjs.org/asciitable/-/asciitable-0.0.7.tgz\",\n+ \"integrity\": \"sha1-e8zERZjmHhkqgAtyXAYSobF3pW4=\"\n+ },\n\"asn1\": {\n\"version\": \"0.2.3\",\n\"resolved\": \"https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz\",\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"dependencies\": {\n\"applicationinsights\": \"^1.0.0\",\n+ \"asciitable\": \"0.0.7\",\n\"mysql\": \"^2.15.0\",\n\"uuid\": \"^3.1.0\"\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "\"use strict\";\n+import * as asciitable from \"asciitable\";\nimport * as mysql from \"mysql\";\nimport * as vscode from \"vscode\";\nimport { IConnection } from \"../model/connection\";\n@@ -41,7 +42,11 @@ export class Utility {\nOutputChannel.appendLine(\"[Start] Executing MySQL query...\");\nUtility.queryPromise<any>(connection, sql)\n.then((result) => {\n- OutputChannel.appendLine(JSON.stringify(result).replace(/},/g, \"},\\r\\n\"));\n+ if (Array.isArray(result)) {\n+ OutputChannel.appendLine(asciitable(result));\n+ } else {\n+ OutputChannel.appendLine(JSON.stringify(result));\n+ }\nAppInsightsClient.sendEvent(\"runQuery.end\", { Result: \"Success\" });\n})\n.catch((err) => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Better output format: display output as table
|
141,906 |
24.11.2017 20:48:00
| -28,800 |
54d07c1630567b0e26db360899813c848591fda5
|
Add option to set maximum table count, and increase the dafault count
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -30,6 +30,10 @@ MySQL management tool\n\n+## Settings\n+\n+* `vscode-mysql.maxTableCount`: The maximum table count shown in the tree view. (Default is **500**)\n+\n## Telemetry data\nBy default, anonymous telemetry data collection is turned on to understand user behavior to improve this extension. To disable it, update the settings.json as below:\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"type\": \"boolean\",\n\"default\": true,\n\"description\": \"Whether to enable anonymous usage collection.\"\n+ },\n+ \"vscode-mysql.maxTableCount\": {\n+ \"type\": \"integer\",\n+ \"default\": 500,\n+ \"description\": \"The maximum table count shown in the tree view\"\n}\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -8,6 +8,8 @@ import { Global } from \"./global\";\nimport { OutputChannel } from \"./outputChannel\";\nexport class Utility {\n+ public static readonly maxTableCount = Utility.getConfiguration().get<number>(\"maxTableCount\");\n+\npublic static getConfiguration(): vscode.WorkspaceConfiguration {\nreturn vscode.workspace.getConfiguration(\"vscode-mysql\");\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/databaseNode.ts",
"diff": "@@ -29,7 +29,7 @@ export class DatabaseNode implements INode {\nport: this.port,\ndatabase: this.database,\n});\n- return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT 100`)\n+ return Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${Utility.maxTableCount}`)\n.then((tables) => {\nreturn tables.map<TableNode>((table) => {\nreturn new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME);\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Add option to set maximum table count, and increase the dafault count
|
141,906 |
26.11.2017 20:12:59
| -28,800 |
31523aabba1982f92e93d4f84b715975dcc06ece
|
Activate extension when running MySQL query
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "+## 0.0.3 (2017-11-26)\n+* Activate extension when running MySQL query\n+\n## 0.0.2 (2017-11-24)\n* Better output format: display output as table\n* [#2](https://github.com/formulahendry/vscode-mysql/issues/2): Add option to set maximum table count, and increase the dafault count\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"0.0.2\",\n+ \"version\": \"0.0.3\",\n\"publisher\": \"formulahendry\",\n\"icon\": \"logo.png\",\n\"engines\": {\n},\n\"activationEvents\": [\n\"onView:mysql\",\n- \"onCommand:mysql.addConnection\"\n+ \"onCommand:mysql.addConnection\",\n+ \"onCommand:mysql.runQuery\"\n],\n\"main\": \"./out/extension\",\n\"contributes\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -26,16 +26,21 @@ export class Utility {\n});\n}\n- public static runQuery(sql?: string, connectionOptions?: IConnection) {\n+ public static async runQuery(sql?: string, connectionOptions?: IConnection) {\nAppInsightsClient.sendEvent(\"runQuery.start\");\nif (!sql && !vscode.window.activeTextEditor) {\nvscode.window.showWarningMessage(\"No SQL file selected\");\n+ AppInsightsClient.sendEvent(\"runQuery.noFile\");\nreturn;\n}\nif (!connectionOptions && !Global.activeConnection) {\n+ const hasActiveConnection = await Utility.hasActiveConnection();\n+ if (!hasActiveConnection) {\nvscode.window.showWarningMessage(\"No MySQL Server or Database selected\");\n+ AppInsightsClient.sendEvent(\"runQuery.noMySQL\");\nreturn;\n}\n+ }\nsql = sql ? sql : vscode.window.activeTextEditor.document.getText();\nconnectionOptions = connectionOptions ? connectionOptions : Global.activeConnection;\n@@ -64,4 +69,19 @@ export class Utility {\nconst textDocument = await vscode.workspace.openTextDocument({ content: sql, language: \"sql\" });\nreturn vscode.window.showTextDocument(textDocument);\n}\n+\n+ private static async hasActiveConnection(): Promise<boolean> {\n+ let count = 5;\n+ while (!Global.activeConnection && count > 0) {\n+ await Utility.sleep(100);\n+ count--;\n+ }\n+ return !!Global.activeConnection;\n+ }\n+\n+ private static sleep(ms) {\n+ return new Promise((resolve) => {\n+ setTimeout(resolve, ms);\n+ });\n+ }\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Activate extension when running MySQL query
|
141,906 |
30.11.2017 21:30:37
| -28,800 |
f2c2f33d45d668d11ce500b1519f2d305b9bd61e
|
Support multiple statement queries
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "+## 0.1.0 (2017-11-30)\n+* Support multiple statement queries\n+\n## 0.0.3 (2017-11-26)\n* Activate extension when running MySQL query\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"0.0.3\",\n+ \"version\": \"0.1.0\",\n\"publisher\": \"formulahendry\",\n\"icon\": \"logo.png\",\n\"engines\": {\n\"vscode\": \"^1.18.0\"\n},\n\"categories\": [\n- \"Languages\"\n+ \"Languages\",\n+ \"Azure\"\n],\n\"keywords\": [\n\"SQL\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -44,23 +44,32 @@ export class Utility {\nsql = sql ? sql : vscode.window.activeTextEditor.document.getText();\nconnectionOptions = connectionOptions ? connectionOptions : Global.activeConnection;\n+ connectionOptions.multipleStatements = true;\nconst connection = mysql.createConnection(connectionOptions);\nOutputChannel.appendLine(\"[Start] Executing MySQL query...\");\n- Utility.queryPromise<any>(connection, sql)\n- .then((result) => {\n- if (Array.isArray(result)) {\n- OutputChannel.appendLine(asciitable(result));\n+ connection.query(sql, (err, rows) => {\n+ if (Array.isArray(rows)) {\n+ if (rows.some(((row) => Array.isArray(row)))) {\n+ rows.forEach((row) => {\n+ if (Array.isArray(row)) {\n+ OutputChannel.appendLine(asciitable(row));\n} else {\n- OutputChannel.appendLine(JSON.stringify(result));\n+ OutputChannel.appendLine(JSON.stringify(row));\n}\n- AppInsightsClient.sendEvent(\"runQuery.end\", { Result: \"Success\" });\n- })\n- .catch((err) => {\n+ });\n+ } else {\n+ OutputChannel.appendLine(asciitable(rows));\n+ }\n+ } else {\n+ OutputChannel.appendLine(JSON.stringify(rows));\n+ }\n+ if (err) {\nOutputChannel.appendLine(err);\nAppInsightsClient.sendEvent(\"runQuery.end\", { Result: \"Fail\", ErrorMessage: err });\n- })\n- .then(() => {\n+ } else {\n+ AppInsightsClient.sendEvent(\"runQuery.end\", { Result: \"Success\" });\n+ }\nOutputChannel.appendLine(\"[Done] Finished MySQL query.\");\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connection.ts",
"new_path": "src/model/connection.ts",
"diff": "@@ -4,4 +4,5 @@ export interface IConnection {\nreadonly password?: string;\nreadonly port: string;\nreadonly database?: string;\n+ multipleStatements?: boolean;\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support multiple statement queries
|
141,916 |
04.12.2017 14:30:35
| -3,600 |
97d5456209f3236c16ba9d54c816a363fbdc8e3c
|
Support SSL connection
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "\"use strict\";\nimport * as asciitable from \"asciitable\";\n+import * as fs from \"fs\";\nimport * as mysql from \"mysql\";\nimport * as vscode from \"vscode\";\nimport { IConnection } from \"../model/connection\";\n@@ -45,7 +46,7 @@ export class Utility {\nsql = sql ? sql : vscode.window.activeTextEditor.document.getText();\nconnectionOptions = connectionOptions ? connectionOptions : Global.activeConnection;\nconnectionOptions.multipleStatements = true;\n- const connection = mysql.createConnection(connectionOptions);\n+ const connection = Utility.createConnection(connectionOptions);\nOutputChannel.appendLine(\"[Start] Executing MySQL query...\");\nconnection.query(sql, (err, rows) => {\n@@ -79,6 +80,29 @@ export class Utility {\nreturn vscode.window.showTextDocument(textDocument);\n}\n+ public static createConnection(connectionOptions: IConnection): any {\n+ let connection;\n+ if (connectionOptions.certPath && fs.existsSync(connectionOptions.certPath)) {\n+ connection = mysql.createConnection({\n+ host: connectionOptions.host,\n+ user: connectionOptions.user,\n+ password: connectionOptions.password,\n+ port: connectionOptions.port,\n+ ssl : {\n+ ca : fs.readFileSync(connectionOptions.certPath),\n+ },\n+ });\n+ } else {\n+ connection = mysql.createConnection({\n+ host: connectionOptions.host,\n+ user: connectionOptions.user,\n+ password: connectionOptions.password,\n+ port: connectionOptions.port,\n+ });\n+ }\n+ return connection;\n+ }\n+\nprivate static async hasActiveConnection(): Promise<boolean> {\nlet count = 5;\nwhile (!Global.activeConnection && count > 0) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connection.ts",
"new_path": "src/model/connection.ts",
"diff": "@@ -5,4 +5,5 @@ export interface IConnection {\nreadonly port: string;\nreadonly database?: string;\nmultipleStatements?: boolean;\n+ readonly certPath: string;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "+import * as fs from \"fs\";\nimport * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n@@ -12,7 +13,9 @@ import { InfoNode } from \"./infoNode\";\nimport { INode } from \"./INode\";\nexport class ConnectionNode implements INode {\n- constructor(private readonly id: string, private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: string) {\n+ constructor(private readonly id: string, private readonly host: string, private readonly user: string,\n+ private readonly password: string, private readonly port: string,\n+ private readonly certPath: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -25,16 +28,18 @@ export class ConnectionNode implements INode {\n}\npublic async getChildren(): Promise<INode[]> {\n- const connection = mysql.createConnection({\n+ const connection = Utility.createConnection({\nhost: this.host,\nuser: this.user,\npassword: this.password,\nport: this.port,\n+ certPath: this.certPath,\n});\n+\nreturn Utility.queryPromise<any[]>(connection, \"SHOW DATABASES\")\n.then((databases) => {\nreturn databases.map<DatabaseNode>((database) => {\n- return new DatabaseNode(this.host, this.user, this.password, this.port, database.Database);\n+ return new DatabaseNode(this.host, this.user, this.password, this.port, database.Database, this.certPath);\n});\n})\n.catch((err) => {\n@@ -51,6 +56,7 @@ export class ConnectionNode implements INode {\nuser: this.user,\npassword: this.password,\nport: this.port,\n+ certPath: this.certPath,\n};\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/databaseNode.ts",
"diff": "+import * as fs from \"fs\";\nimport * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n@@ -9,7 +10,9 @@ import { INode } from \"./INode\";\nimport { TableNode } from \"./tableNode\";\nexport class DatabaseNode implements INode {\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string, private readonly port: string, private readonly database: string) {\n+ constructor(private readonly host: string, private readonly user: string,\n+ private readonly password: string, private readonly port: string, private readonly database: string,\n+ private readonly certPath: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -22,17 +25,19 @@ export class DatabaseNode implements INode {\n}\npublic async getChildren(): Promise<INode[]> {\n- const connection = mysql.createConnection({\n+ const connection = Utility.createConnection({\nhost: this.host,\nuser: this.user,\npassword: this.password,\nport: this.port,\ndatabase: this.database,\n+ certPath: this.certPath,\n});\n+\nreturn Utility.queryPromise<any[]>(connection, `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${Utility.maxTableCount}`)\n.then((tables) => {\nreturn tables.map<TableNode>((table) => {\n- return new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME);\n+ return new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME, this.certPath);\n});\n})\n.catch((err) => {\n@@ -50,6 +55,7 @@ export class DatabaseNode implements INode {\npassword: this.password,\nport: this.port,\ndatabase: this.database,\n+ certPath: this.certPath,\n};\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/tableNode.ts",
"new_path": "src/model/tableNode.ts",
"diff": "@@ -11,7 +11,8 @@ import { INode } from \"./INode\";\nexport class TableNode implements INode {\nconstructor(private readonly host: string, private readonly user: string, private readonly password: string,\n- private readonly port: string, private readonly database: string, private readonly table: string) {\n+ private readonly port: string, private readonly database: string, private readonly table: string,\n+ private readonly certPath: string) {\n}\npublic getTreeItem(): vscode.TreeItem {\n@@ -24,13 +25,15 @@ export class TableNode implements INode {\n}\npublic async getChildren(): Promise<INode[]> {\n- const connection = mysql.createConnection({\n+ const connection = Utility.createConnection({\nhost: this.host,\nuser: this.user,\npassword: this.password,\nport: this.port,\ndatabase: this.database,\n+ certPath: this.certPath,\n});\n+\nreturn Utility.queryPromise<any[]>(connection, `SELECT * FROM information_schema.columns WHERE table_schema = '${this.database}' AND table_name = '${this.table}';`)\n.then((columns) => {\nreturn columns.map<ColumnNode>((column) => {\n@@ -53,6 +56,7 @@ export class TableNode implements INode {\npassword: this.password,\nport: this.port,\ndatabase: this.database,\n+ certPath: this.certPath,\n};\nGlobal.activeConnection = connection;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/mysqlTreeDataProvider.ts",
"new_path": "src/mysqlTreeDataProvider.ts",
"diff": "@@ -49,6 +49,11 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\nreturn;\n}\n+ const certPath = await vscode.window.showInputBox({ prompt: \"[Optional] SSL certificate path. Leave empty to ignore\", placeHolder: \"certificate file path\", ignoreFocusOut: true });\n+ if (certPath === undefined) {\n+ return;\n+ }\n+\nlet connections = this.context.globalState.get<{ [key: string]: IConnection }>(Constants.GlobalStateMySQLConectionsKey);\nif (!connections) {\n@@ -60,6 +65,7 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\nhost,\nuser,\nport,\n+ certPath,\n};\nif (password) {\n@@ -80,13 +86,14 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\nif (connections) {\nfor (const id of Object.keys(connections)) {\nconst password = await Global.keytar.getPassword(Constants.ExtensionId, id);\n- ConnectionNodes.push(new ConnectionNode(id, connections[id].host, connections[id].user, password, connections[id].port));\n+ ConnectionNodes.push(new ConnectionNode(id, connections[id].host, connections[id].user, password, connections[id].port, connections[id].certPath));\nif (!Global.activeConnection) {\nGlobal.activeConnection = {\nhost: connections[id].host,\nuser: connections[id].user,\npassword,\nport: connections[id].port,\n+ certPath: connections[id].certPath,\n};\n}\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Support SSL connection (#7)
|
141,906 |
04.12.2017 22:46:45
| -28,800 |
a0b94ffe2aaa2e685d069fa636a99b3c4250c337
|
Close the connection after query
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -20,10 +20,11 @@ export class Utility {\nconnection.query(sql, (err, rows) => {\nif (err) {\nreject(\"Error: \" + err.message);\n- return;\n- }\n+ } else {\nresolve(rows);\n+ }\n});\n+ connection.end();\n});\n}\n@@ -73,6 +74,7 @@ export class Utility {\n}\nOutputChannel.appendLine(\"[Done] Finished MySQL query.\");\n});\n+ connection.end();\n}\npublic static async createSQLTextDocument(sql: string = \"\") {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Close the connection after query
|
141,906 |
05.12.2017 20:36:52
| -28,800 |
bfca5523e0ad2199c037ca4ed69299970b9d4fe1
|
Keep original properties when creating connection
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -83,26 +83,13 @@ export class Utility {\n}\npublic static createConnection(connectionOptions: IConnection): any {\n- let connection;\n+ const newConnectionOptions: any = Object.assign({}, connectionOptions);\nif (connectionOptions.certPath && fs.existsSync(connectionOptions.certPath)) {\n- connection = mysql.createConnection({\n- host: connectionOptions.host,\n- user: connectionOptions.user,\n- password: connectionOptions.password,\n- port: connectionOptions.port,\n- ssl : {\n+ newConnectionOptions.ssl = {\nca: fs.readFileSync(connectionOptions.certPath),\n- },\n- });\n- } else {\n- connection = mysql.createConnection({\n- host: connectionOptions.host,\n- user: connectionOptions.user,\n- password: connectionOptions.password,\n- port: connectionOptions.port,\n- });\n+ };\n}\n- return connection;\n+ return mysql.createConnection(newConnectionOptions);\n}\nprivate static async hasActiveConnection(): Promise<boolean> {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Keep original properties when creating connection
|
141,906 |
31.12.2017 15:40:06
| -28,800 |
14d29c3fe1098d07158298897f904b9259fa338f
|
Resolve Add key bindings for 'Run MySQL Query'
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "+## 0.2.2 (2017-12-31)\n+* [#10](https://github.com/formulahendry/vscode-mysql/issues/10): Add key bindings for 'Run MySQL Query'\n+\n## 0.2.1 (2017-12-05)\n* Keep original properties when creating connection\n* Close the connection after query\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -21,7 +21,8 @@ MySQL management tool\n* To run MySQL query, open a SQL file first then:\n* right click on the SQL file, then click `Run MySQL Query` in editor context menu\n- * or press `F1` and then select/type `Run MySQL Query`,\n+ * or use shortcut `Ctrl+Alt+E`\n+ * or press `F1` and then select/type `Run MySQL Query`\n\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"0.2.1\",\n+ \"version\": \"0.2.2\",\n\"publisher\": \"formulahendry\",\n\"icon\": \"logo.png\",\n\"engines\": {\n\"category\": \"MySQL\"\n}\n],\n+ \"keybindings\": [\n+ {\n+ \"command\": \"mysql.runQuery\",\n+ \"key\": \"ctrl+alt+e\",\n+ \"when\": \"editorLangId == sql\"\n+ }\n+ ],\n\"menus\": {\n\"editor/context\": [{\n\"command\": \"mysql.runQuery\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/outputChannel.ts",
"new_path": "src/common/outputChannel.ts",
"diff": "@@ -3,7 +3,7 @@ import * as vscode from \"vscode\";\nexport class OutputChannel {\npublic static appendLine(value: string) {\n- OutputChannel.outputChannel.show();\n+ OutputChannel.outputChannel.show(true);\nOutputChannel.outputChannel.appendLine(value);\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Resolve #10: Add key bindings for 'Run MySQL Query'
|
141,915 |
23.02.2018 16:19:16
| -7,200 |
3cc23181f46bb555c2cca28df6fe714261ba8044
|
Fixes Adopt the usage of ASAR in VSCode
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/global.ts",
"new_path": "src/common/global.ts",
"diff": "@@ -4,7 +4,7 @@ import * as vscode from \"vscode\";\nimport { IConnection } from \"../model/connection\";\nexport class Global {\n- public static keytar: typeof keytarType = require(`${vscode.env.appRoot}/node_modules/keytar`);\n+ public static keytar: typeof keytarType = getCoreNodeModule(`keytar`);\nstatic get activeConnection(): IConnection {\nreturn Global._activeConnection;\n@@ -32,3 +32,18 @@ export class Global {\nreturn `$(server) ${activeConnection.host}` + (activeConnection.database ? ` $(database) ${activeConnection.database}` : \"\");\n}\n}\n+\n+/**\n+ * Returns a node module installed with VSCode, or null if it fails.\n+ */\n+function getCoreNodeModule(moduleName: string) {\n+ try {\n+ return require(`${vscode.env.appRoot}/node_modules.asar/${moduleName}`);\n+ } catch (err) { }\n+\n+ try {\n+ return require(`${vscode.env.appRoot}/node_modules/${moduleName}`);\n+ } catch (err) { }\n+\n+ return null;\n+}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Fixes #22: Adopt the usage of ASAR in VSCode (#25)
|
141,898 |
23.02.2018 08:23:10
| 21,600 |
58a72da09f3aa594380acdafb18df7b726a292f4
|
Adding support for executing a selection
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "@@ -44,7 +44,16 @@ export class Utility {\n}\n}\n- sql = sql ? sql : vscode.window.activeTextEditor.document.getText();\n+ if (!sql) {\n+ const activeTextEditor = vscode.window.activeTextEditor;\n+ const selection = activeTextEditor.selection;\n+ if (selection.isEmpty) {\n+ sql = activeTextEditor.document.getText();\n+ } else {\n+ sql = activeTextEditor.document.getText(selection);\n+ }\n+ }\n+\nconnectionOptions = connectionOptions ? connectionOptions : Global.activeConnection;\nconnectionOptions.multipleStatements = true;\nconst connection = Utility.createConnection(connectionOptions);\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Adding support for executing a selection (#21)
|
141,907 |
13.06.2018 14:18:50
| 10,800 |
05340afdeb38f071d82cc2eb16ae2ce06f849e18
|
#implement copy menu for names/insert/update
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"command\": \"mysql.selectTop1000\",\n\"title\": \"Select Top 1000\",\n\"category\": \"MySQL\"\n+ },\n+ {\n+ \"command\": \"mysql.copy.names\",\n+ \"title\": \"Copy Names\",\n+ \"category\": \"MySQL\"\n+ },\n+ {\n+ \"command\": \"mysql.copy.insert\",\n+ \"title\": \"Copy for Insert\",\n+ \"category\": \"MySQL\"\n+ },\n+ {\n+ \"command\": \"mysql.copy.update\",\n+ \"title\": \"Copy for Update\",\n+ \"category\": \"MySQL\"\n}\n],\n\"keybindings\": [\n\"when\": \"view == mysql && viewItem == table\",\n\"group\": \"mysql@0\"\n},\n+ {\n+ \"command\": \"mysql.copy.names\",\n+ \"when\": \"view == mysql && viewItem == table\",\n+ \"group\": \"mysql@0\"\n+ },\n+ {\n+ \"command\": \"mysql.copy.insert\",\n+ \"when\": \"view == mysql && viewItem == table\",\n+ \"group\": \"mysql@0\"\n+ },\n+ {\n+ \"command\": \"mysql.copy.update\",\n+ \"when\": \"view == mysql && viewItem == table\",\n+ \"group\": \"mysql@0\"\n+ },\n{\n\"command\": \"mysql.refresh\",\n\"when\": \"view == mysql && viewItem == table\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -42,6 +42,18 @@ export function activate(context: vscode.ExtensionContext) {\ncontext.subscriptions.push(vscode.commands.registerCommand(\"mysql.selectTop1000\", (tableNode: TableNode) => {\ntableNode.selectTop1000();\n}));\n+\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.copy.names\", (tableNode: TableNode) => {\n+ tableNode.copyNames();\n+ }));\n+\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.copy.insert\", (tableNode: TableNode) => {\n+ tableNode.copyInsert();\n+ }));\n+\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.copy.update\", (tableNode: TableNode) => {\n+ tableNode.copyUpdate();\n+ }));\n}\nexport function deactivate() {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/tableNode.ts",
"new_path": "src/model/tableNode.ts",
"diff": "@@ -62,4 +62,45 @@ export class TableNode implements INode {\nUtility.runQuery(sql, connection);\n}\n+ public copyNames() {\n+ this\n+ .getChildren()\n+ .then((children: INode[]) => {\n+ const childrenNames = children.map((child: any) => child.column.COLUMN_NAME);\n+\n+ OutputChannel.appendLine(`${this.database}.${this.table}`);\n+ OutputChannel.appendLine(` ${childrenNames.toString().replace(/,/g, \"\\n \")}`);\n+ OutputChannel.appendLine(``);\n+\n+ });\n+ }\n+ public copyInsert() {\n+ this\n+ .getChildren()\n+ .then((children: INode[]) => {\n+ const childrenNames = children.map((child: any) => child.column.COLUMN_NAME);\n+\n+ OutputChannel.appendLine(`insert into ${this.database}.${this.table}(${childrenNames.toString().replace(/,/g, \", \")})`);\n+ OutputChannel.appendLine(`values`);\n+ OutputChannel.appendLine(`(:${childrenNames.toString().replace(/,/g, \", :\")})`);\n+ OutputChannel.appendLine(`;`);\n+ OutputChannel.appendLine(``);\n+ });\n+ }\n+ public copyUpdate() {\n+ this\n+ .getChildren()\n+ .then((children: INode[]) => {\n+ const keysNames = children.filter((child: any) => child.column.COLUMN_KEY).map((child: any) => child.column.COLUMN_NAME);\n+ const childrenNames = children.filter((child: any) => !child.column.COLUMN_KEY).map((child: any) => child.column.COLUMN_NAME);\n+\n+ const sets = childrenNames.map((name: string) => `${name} = :${name}`);\n+ const where = keysNames.map((name: string) => `${name} = :${name}`);\n+\n+ OutputChannel.appendLine(`update ${this.database}.${this.table} \\nset ${sets.toString().replace(/,/g, \"\\n , \")}`);\n+ OutputChannel.appendLine(` where ${where.toString().replace(/,/g, \"\\n and \")}`);\n+ OutputChannel.appendLine(``);\n+ });\n+ }\n+\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
#implement copy menu for names/insert/update
|
141,908 |
24.03.2019 14:37:49
| -28,800 |
4dae2d2b7637019df7afed5b233213caa012548d
|
add change table/column name support
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-manager\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"1.3.0\",\n- \"publisher\": \"formulahendry\",\n+ \"version\": \"1.3.1\",\n+ \"publisher\": \"cweijan\",\n\"icon\": \"logo.png\",\n\"engines\": {\n\"vscode\": \"^1.30.0\"\n\"RDBMS\"\n],\n\"bugs\": {\n- \"url\": \"https://github.com/formulahendry/vscode-mysql/issues\",\n- \"email\": \"formulahendry@gmail.com\"\n+ \"url\": \"https://github.com/cweijan/vscode-mysql/issues\",\n+ \"email\": \"cweijan@163.com\"\n},\n- \"homepage\": \"https://github.com/formulahendry/vscode-mysql/blob/master/README.md\",\n+ \"homepage\": \"https://github.com/cweijan/vscode-mysql/blob/master/README.md\",\n\"repository\": {\n\"type\": \"git\",\n- \"url\": \"https://github.com/formulahendry/vscode-mysql.git\"\n+ \"url\": \"https://github.com/cweijan/vscode-mysql.git\"\n},\n\"activationEvents\": [\n\"onView:mysql\",\n{\n\"command\": \"mysql.refresh\",\n\"title\": \"Refresh\",\n- \"category\": \"MySQL\"\n+ \"category\": \"MySQL\",\n+ \"icon\": {\n+ \"light\": \"resources/light/refresh.svg\",\n+ \"dark\": \"resources/dark/refresh.svg\"\n+ }\n},\n{\n\"command\": \"mysql.addConnection\",\n\"command\": \"mysql.copy.update\",\n\"title\": \"Update SQL Template\",\n\"category\": \"MySQL\"\n+ },\n+ {\n+ \"command\": \"mysql.changeTableName\",\n+ \"title\": \"change table name\",\n+ \"category\": \"MySQL\",\n+ \"icon\": {\n+ \"light\": \"resources/light/edit.svg\",\n+ \"dark\": \"resources/dark/edit.svg\"\n+ }\n+ },\n+ {\n+ \"command\": \"mysql.changeColumnName\",\n+ \"title\": \"change column name\",\n+ \"category\": \"MySQL\",\n+ \"icon\": {\n+ \"light\": \"resources/light/edit.svg\",\n+ \"dark\": \"resources/dark/edit.svg\"\n+ }\n}\n],\n\"keybindings\": [\n\"command\": \"mysql.addConnection\",\n\"when\": \"view == mysql\",\n\"group\": \"navigation@1\"\n+ },\n+ {\n+ \"command\": \"mysql.refresh\",\n+ \"when\": \"view == mysql\",\n+ \"group\": \"navigation@0\"\n}\n],\n\"view/item/context\": [\n\"when\": \"view == mysql && viewItem == table\",\n\"group\": \"mysql@0\"\n},\n+ {\n+ \"command\": \"mysql.changeTableName\",\n+ \"when\": \"view == mysql && viewItem == table\",\n+ \"group\": \"inline\"\n+ },\n{\n\"command\": \"mysql.copy.insert\",\n\"when\": \"view == mysql && viewItem == table\",\n\"command\": \"mysql.refresh\",\n\"when\": \"view == mysql && viewItem == table\",\n\"group\": \"mysql@4\"\n+ },\n+ {\n+ \"command\": \"mysql.changeColumnName\",\n+ \"when\": \"view == mysql && viewItem == column\",\n+ \"group\": \"inline\"\n}\n]\n},\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/dark/edit.svg",
"diff": "+<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n+<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n+ viewBox=\"0 0 504.48 504.48\" style=\"enable-background:new 0 0 504.48 504.48;\" xml:space=\"preserve\">\n+<path style=\"fill:#2394BC;\" d=\"M492.534,145.772L172.337,461.636c0,0-163.84,48.837-171.323,41.354s37.415-175.261,37.415-175.261\n+ L358.626,11.864c15.36-15.754,40.172-15.754,55.532,0l78.375,78.769C507.894,105.599,507.894,130.412,492.534,145.772z\"/>\n+<path style=\"fill:#44A4C6;\" d=\"M66.392,367.113L418.097,15.409l-3.938-3.938c-15.36-15.36-40.172-15.36-55.532,0.394L38.823,328.123\n+ c0,0-0.788,3.151-2.363,8.665L66.392,367.113L66.392,367.113z\"/>\n+<path style=\"fill:#1F85A9;\" d=\"M501.592,132.775c5.514-14.178,2.757-31.114-8.665-42.535l-7.877-7.877L133.346,434.067l30.72,30.326\n+ c4.332-1.182,7.089-1.969,8.271-2.363C172.337,462.03,501.592,132.775,501.592,132.775z\"/>\n+<path style=\"fill:#FFCABA;\" d=\"M0.62,501.809l2.363,2.363c18.511,2.757,160.689-39.385,169.354-42.142l0.394-0.394\n+ c0,0-9.058-42.535-16.935-50.018c-7.877-7.877-42.142-9.058-50.018-16.542c-7.877-7.877-8.665-42.142-16.935-50.018\n+ c-7.877-7.877-48.049-16.148-50.018-16.542C38.823,328.123-2.531,482.116,0.62,501.809L0.62,501.809z\"/>\n+<path style=\"fill:#FFDCD2;\" d=\"M0.226,499.839c2.757-4.726,16.542-29.145,88.222-154.781c-7.877-7.877-48.049-16.148-50.018-16.542\n+ C38.823,328.123-0.168,473.846,0.226,499.839z\"/>\n+<path style=\"fill:#E5B5A7;\" d=\"M0.226,500.233v1.182l2.363,2.363c18.511,2.757,160.689-39.385,169.354-42.142l0.394-0.394\n+ c0,0-8.665-42.142-16.542-50.018C25.432,486.055,3.771,498.264,0.226,500.233z\"/>\n+<path style=\"fill:#2394BC;\" d=\"M27.402,473.058c-5.12-5.12-13.391-9.058-21.662-9.846c-4.332,22.055-7.089,38.203-4.726,40.566\n+ c1.969,1.969,16.935-0.394,36.628-4.726C37.642,489.206,33.309,478.966,27.402,473.058z\"/>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+</svg>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/light/edit.svg",
"diff": "+<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n+<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n+ viewBox=\"0 0 504.48 504.48\" style=\"enable-background:new 0 0 504.48 504.48;\" xml:space=\"preserve\">\n+<path style=\"fill:#2394BC;\" d=\"M492.534,145.772L172.337,461.636c0,0-163.84,48.837-171.323,41.354s37.415-175.261,37.415-175.261\n+ L358.626,11.864c15.36-15.754,40.172-15.754,55.532,0l78.375,78.769C507.894,105.599,507.894,130.412,492.534,145.772z\"/>\n+<path style=\"fill:#44A4C6;\" d=\"M66.392,367.113L418.097,15.409l-3.938-3.938c-15.36-15.36-40.172-15.36-55.532,0.394L38.823,328.123\n+ c0,0-0.788,3.151-2.363,8.665L66.392,367.113L66.392,367.113z\"/>\n+<path style=\"fill:#1F85A9;\" d=\"M501.592,132.775c5.514-14.178,2.757-31.114-8.665-42.535l-7.877-7.877L133.346,434.067l30.72,30.326\n+ c4.332-1.182,7.089-1.969,8.271-2.363C172.337,462.03,501.592,132.775,501.592,132.775z\"/>\n+<path style=\"fill:#FFCABA;\" d=\"M0.62,501.809l2.363,2.363c18.511,2.757,160.689-39.385,169.354-42.142l0.394-0.394\n+ c0,0-9.058-42.535-16.935-50.018c-7.877-7.877-42.142-9.058-50.018-16.542c-7.877-7.877-8.665-42.142-16.935-50.018\n+ c-7.877-7.877-48.049-16.148-50.018-16.542C38.823,328.123-2.531,482.116,0.62,501.809L0.62,501.809z\"/>\n+<path style=\"fill:#FFDCD2;\" d=\"M0.226,499.839c2.757-4.726,16.542-29.145,88.222-154.781c-7.877-7.877-48.049-16.148-50.018-16.542\n+ C38.823,328.123-0.168,473.846,0.226,499.839z\"/>\n+<path style=\"fill:#E5B5A7;\" d=\"M0.226,500.233v1.182l2.363,2.363c18.511,2.757,160.689-39.385,169.354-42.142l0.394-0.394\n+ c0,0-8.665-42.142-16.542-50.018C25.432,486.055,3.771,498.264,0.226,500.233z\"/>\n+<path style=\"fill:#2394BC;\" d=\"M27.402,473.058c-5.12-5.12-13.391-9.058-21.662-9.846c-4.332,22.055-7.089,38.203-4.726,40.566\n+ c1.969,1.969,16.935-0.394,36.628-4.726C37.642,489.206,33.309,478.966,27.402,473.058z\"/>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+</svg>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/DatabaseCache.ts",
"new_path": "src/common/DatabaseCache.ts",
"diff": "@@ -10,9 +10,11 @@ export class DatabaseCache {\nprivate static context: ExtensionContext;\nstatic databaseNodes: DatabaseNode[] = [];\n+ private static datbaseMap={};\n+ private static tableMap={};\nprivate static databaseNodeMapTableNode = {};\nprivate static tableNodeMapColumnNode = {};\n- private static collpaseState;\n+ private static collpaseState: { key?: TreeItemCollapsibleState };\nstatic evictAllCache(): any {\nif (this.context == null) throw new Error(\"DatabaseCache is not init!\")\n@@ -38,6 +40,22 @@ export class DatabaseCache {\nreturn tableNodeList;\n}\n+\n+ static getParentTreeItem(iNode: INode, type: string): INode {\n+\n+ let databaseNode: DatabaseNode=<DatabaseNode>iNode;\n+ if (type == ModelType.TABLE && (databaseNode = this.datbaseMap[`${databaseNode.host}_${databaseNode.port}_${databaseNode.user}_${databaseNode.database}`])) {\n+ return databaseNode\n+ }\n+\n+ let tableNode: TableNode=<TableNode>iNode;\n+ if (type == ModelType.COLUMN && (tableNode = this.tableMap[`${tableNode.host}_${tableNode.port}_${tableNode.user}_${tableNode.database}_${tableNode.table}`])) {\n+ return tableNode\n+ }\n+\n+ return null;\n+ }\n+\nstatic getElementState(element?: INode) {\nif (element.type == ModelType.COLUMN || element.type == ModelType.INFO) {\n@@ -74,13 +92,25 @@ export class DatabaseCache {\n}\n+ static async initDatabaseNodes(databaseNodes: DatabaseNode[]) {\n+ if (!databaseNodes) {\n+ databaseNodes = []\n+ }\n+ this.databaseNodes = databaseNodes\n+ await this.databaseNodes.forEach(databaseNode => {\n+ this.datbaseMap[`${databaseNode.host}_${databaseNode.port}_${databaseNode.user}_${databaseNode.database}`]\n+ })\n+ }\n+\nstatic obtainStoreCache() {\nif (this.context == null) throw new Error(\"DatabaseCache is not init!\")\nlet cached = false\nif (this.context.globalState.get(CacheKey.DatabaseCacheKey)) {\nconst databaseProxyList: DatabaseProxy[] = this.context.globalState.get(CacheKey.DatabaseCacheKey)\ndatabaseProxyList.forEach(d => {\n- this.databaseNodes.push(new DatabaseNode(d.host, d.user, d.password, d.port, d.database, d.certPath))\n+ const databasenode = new DatabaseNode(d.host, d.user, d.password, d.port, d.database, d.certPath)\n+ this.databaseNodes.push(databasenode)\n+ this.datbaseMap[`${d.host}_${d.port}_${d.user}_${d.database}`] = databasenode\n})\n}\nif (this.context.globalState.get(CacheKey.DatabaseTableCacheKey)) {\n@@ -90,7 +120,9 @@ export class DatabaseCache {\nthis.databaseNodeMapTableNode[dn] = []\n}\nt[dn].forEach(tableProxy => {\n- this.databaseNodeMapTableNode[dn].push(new TableNode(tableProxy.host, tableProxy.user, tableProxy.password, tableProxy.port, tableProxy.database, tableProxy.table, tableProxy.certPath))\n+ const tableNode=new TableNode(tableProxy.host, tableProxy.user, tableProxy.password, tableProxy.port, tableProxy.database, tableProxy.table, tableProxy.certPath)\n+ this.databaseNodeMapTableNode[dn].push(tableNode)\n+ this.tableMap[`${tableProxy.host}_${tableProxy.port}_${tableProxy.user}_${tableProxy.database}_${tableProxy.table}`]=tableNode\n})\n})\n@@ -102,7 +134,7 @@ export class DatabaseCache {\nthis.tableNodeMapColumnNode[tn] = []\n}\nc[tn].forEach(columnProxy => {\n- this.tableNodeMapColumnNode[tn].push(new ColumnNode(columnProxy.host, columnProxy.user, columnProxy.password, columnProxy.port, columnProxy.database, columnProxy.column))\n+ this.tableNodeMapColumnNode[tn].push(new ColumnNode(columnProxy.host, columnProxy.user, columnProxy.password, columnProxy.port, columnProxy.database,columnProxy.table,columnProxy.certPath, columnProxy.column))\n})\n})\n@@ -123,7 +155,6 @@ export class DatabaseCache {\n}\nstatic storeCurrentCache() {\n- OutputChannel.appendLine(\"store\")\nif (this.context == null) throw new Error(\"DatabaseCache is not init!\")\nthis.context.globalState.update(CacheKey.DatabaseCacheKey, this.databaseNodes)\nthis.context.globalState.update(CacheKey.DatabaseTableCacheKey, this.databaseNodeMapTableNode)\n@@ -150,6 +181,9 @@ export class DatabaseCache {\nstatic setTableListOfDatabase(databaseName: string, tableNodeList: TableNode[]) {\nthis.databaseNodeMapTableNode[databaseName] = tableNodeList\n+ tableNodeList.forEach(tableNode=>{\n+ this.tableMap[`${tableNode.host}_${tableNode.port}_${tableNode.user}_${tableNode.database}_${tableNode.table}`]=tableNode\n+ })\n}\nstatic setColumnListOfTable(tableName: string, columnList: ColumnNode[]) {\n@@ -173,5 +207,6 @@ class TableProxy {\nclass ColumnProxy {\nhost: string; user: string; password: string;\n- port: string; database: string; column: any\n+ port: string; database: string; table: string;\n+ certPath: string;column: any\n}\n\\ No newline at end of file\n"
},
{
"change_type": "DELETE",
"old_path": "src/common/SqlUtility.ts",
"new_path": null,
"diff": "-export class SqlUility{\n-\n-}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/appInsightsClient.ts",
"new_path": "src/common/appInsightsClient.ts",
"diff": "\"use strict\";\nimport appInsights = require(\"applicationinsights\");\n-import * as vscode from \"vscode\";\nimport { Utility } from \"./utility\";\nexport class AppInsightsClient {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/global.ts",
"new_path": "src/common/global.ts",
"diff": "import * as keytarType from \"keytar\";\nimport * as vscode from \"vscode\";\nimport { IConnection } from \"../model/connection\";\n+import { MySQLTreeDataProvider } from \"../provider/mysqlTreeDataProvider\";\nexport class Global {\npublic static keytar: typeof keytarType = getCoreNodeModule(`keytar`);\n+ public static sqlTreeProvider:MySQLTreeDataProvider;\nstatic get activeConnection(): IConnection {\nreturn Global._activeConnection;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/utility.ts",
"new_path": "src/common/utility.ts",
"diff": "\"use strict\";\n-import * as asciitable from \"asciitable\";\nimport * as fs from \"fs\";\nimport * as mysql from \"mysql\";\nimport * as vscode from \"vscode\";\n@@ -7,9 +6,6 @@ import { IConnection } from \"../model/connection\";\nimport { AppInsightsClient } from \"./appInsightsClient\";\nimport { Global } from \"./global\";\nimport { OutputChannel } from \"./outputChannel\";\n-import { SourceInfo } from \"_debugger\";\n-import { cursorTo } from \"readline\";\n-import { SSL_OP_NO_QUERY_MTU } from \"constants\";\nexport class Utility {\npublic static readonly maxTableCount = Utility.getConfiguration().get<number>(\"maxTableCount\");\n@@ -20,8 +16,10 @@ export class Utility {\npublic static queryPromise<T>(connection, sql: string): Promise<T> {\nreturn new Promise((resolve, reject) => {\n+ OutputChannel.appendLine(`Execute SQL:${sql}`)\nconnection.query(sql, (err, rows) => {\nif (err) {\n+ OutputChannel.appendLine(err)\nreject(\"Error: \" + err.message);\n} else {\nresolve(rows);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -10,7 +10,8 @@ import { MySQLTreeDataProvider } from \"./provider/mysqlTreeDataProvider\";\nimport { SqlResultDocumentContentProvider } from \"./provider/sqlResultDocumentContentProvider\";\nimport { CompletionProvider } from \"./provider/CompletionProvider\";\nimport { DatabaseCache } from \"./common/DatabaseCache\";\n-import { OutputChannel } from \"./common/outputChannel\";\n+import { Global } from \"./common/global\";\n+import { ColumnNode } from \"./model/columnNode\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -23,6 +24,7 @@ export function activate(context: vscode.ExtensionContext) {\nconst treeview= vscode.window.createTreeView(\"mysql\",{\ntreeDataProvider:mysqlTreeDataProvider\n})\n+ Global.sqlTreeProvider=mysqlTreeDataProvider\ntreeview.onDidCollapseElement(event=>{\nDatabaseCache.storeElementState(event.element,vscode.TreeItemCollapsibleState.Collapsed)\n})\n@@ -35,11 +37,9 @@ export function activate(context: vscode.ExtensionContext) {\ncontext.subscriptions.push(vscode.workspace.registerTextDocumentContentProvider(\"sqlresult\", new SqlResultDocumentContentProvider(context)));\ncontext.subscriptions.push(vscode.commands.registerCommand(\"mysql.refresh\", (node: INode) => {\n- OutputChannel.appendLine(JSON.stringify(node))\n- OutputChannel.appendLine((<vscode.TreeItem>node).collapsibleState)\n- // DatabaseCache.evictAllCache()\n- // mysqlTreeDataProvider.init()\n- // mysqlTreeDataProvider.refresh()\n+ DatabaseCache.evictAllCache()\n+ mysqlTreeDataProvider.init()\n+ mysqlTreeDataProvider.refresh()\n}));\n@@ -47,6 +47,14 @@ export function activate(context: vscode.ExtensionContext) {\nmysqlTreeDataProvider.addConnection();\n}));\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.changeTableName\", (tableNode: TableNode) => {\n+ tableNode.changeTableName()\n+ }));\n+\n+ context.subscriptions.push(vscode.commands.registerCommand(\"mysql.changeColumnName\", (columnNode: ColumnNode) => {\n+ columnNode.changeColumnName()\n+ }));\n+\ncontext.subscriptions.push(vscode.commands.registerCommand(\"mysql.deleteConnection\", (connectionNode: ConnectionNode) => {\nconnectionNode.deleteConnection(context, mysqlTreeDataProvider);\n}));\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/columnNode.ts",
"new_path": "src/model/columnNode.ts",
"diff": "-import * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n-import { AppInsightsClient } from \"../common/appInsightsClient\";\n-import { Global } from \"../common/global\";\n-import { OutputChannel } from \"../common/outputChannel\";\n-import { Utility } from \"../common/utility\";\n-import { InfoNode } from \"./infoNode\";\nimport { INode } from \"./INode\";\nimport { ModelType } from \"../common/constants\";\n+import { Utility } from \"../common/utility\";\n+import { DatabaseCache } from \"../common/DatabaseCache\";\n+import { OutputChannel } from \"../common/outputChannel\";\n+import { Global } from \"../common/global\";\nclass ColumnTreeItem extends vscode.TreeItem {\ncolumnName: string;\n@@ -16,10 +14,12 @@ class ColumnTreeItem extends vscode.TreeItem {\n}\nexport class ColumnNode implements INode {\n+\nidentify: string;\ntype: string = ModelType.COLUMN;\nconstructor(private readonly host: string, private readonly user: string, private readonly password: string,\n- private readonly port: string, private readonly database: string, private readonly column: any) {\n+ private readonly port: string, private readonly database: string,private readonly table:string,\n+ private readonly certPath: string, private readonly column: any) {\n}\npublic getTreeItem(): ColumnTreeItem {\n@@ -37,4 +37,29 @@ export class ColumnNode implements INode {\npublic async getChildren(): Promise<INode[]> {\nreturn [];\n}\n+\n+ changeColumnName(): any {\n+ const connection = Utility.createConnection({\n+ host: this.host,\n+ user: this.user,\n+ password: this.password,\n+ port: this.port,\n+ database: this.database,\n+ certPath: this.certPath,\n+ });\n+\n+ const columnName=this.column.COLUMN_NAME\n+ vscode.window.showInputBox({ value: columnName, placeHolder: 'newColumnName', prompt: `You will changed ${this.table}.${columnName} to new column name!` }).then(newColumnName => {\n+ if (!newColumnName) return\n+ const sql = `alter table ${this.database}.${this.table} change column ${columnName} ${newColumnName} ${this.column.COLUMN_TYPE}`\n+ Utility.queryPromise(connection, sql).then((rows) => {\n+ DatabaseCache.getParentTreeItem(this, ModelType.COLUMN).getChildren(true).then(()=>{\n+ Global.sqlTreeProvider.refresh()\n+ DatabaseCache.storeCurrentCache()\n+ })\n+ })\n+\n+ })\n+ }\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "-import * as fs from \"fs\";\n-import * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\nimport { AppInsightsClient } from \"../common/appInsightsClient\";\n@@ -51,7 +49,7 @@ export class ConnectionNode implements INode {\ndatabaseNodes = databases.map<DatabaseNode>((database) => {\nreturn new DatabaseNode(this.host, this.user, this.password, this.port, database.Database, this.certPath);\n})\n- DatabaseCache.databaseNodes = databaseNodes\n+ DatabaseCache.initDatabaseNodes(databaseNodes)\nreturn databaseNodes;\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/databaseNode.ts",
"diff": "-import * as fs from \"fs\";\n-import * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\nimport { AppInsightsClient } from \"../common/appInsightsClient\";\n@@ -14,8 +12,8 @@ import { ModelType } from \"../common/constants\";\nexport class DatabaseNode implements INode {\nidentify: string;\ntype: string = ModelType.DATABASE;\n- constructor(private readonly host: string, private readonly user: string,\n- private readonly password: string, private readonly port: string,private readonly database: string,\n+ constructor(readonly host: string, readonly user: string,\n+ private readonly password: string, readonly port: string, readonly database: string,\nprivate readonly certPath: string) {\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/tableNode.ts",
"new_path": "src/model/tableNode.ts",
"diff": "-import * as mysql from \"mysql\";\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\nimport { AppInsightsClient } from \"../common/appInsightsClient\";\n@@ -12,11 +11,12 @@ import { DatabaseCache } from \"../common/DatabaseCache\";\nimport { ModelType } from \"../common/constants\";\nexport class TableNode implements INode {\n+\nidentify: string;\ntype: string = ModelType.TABLE;\n- constructor(private readonly host: string, private readonly user: string, private readonly password: string,\n- private readonly port: string, private readonly database: string, readonly table: string,\n+ constructor(readonly host: string, readonly user: string, private readonly password: string,\n+ readonly port: string, readonly database: string, readonly table: string,\nprivate readonly certPath: string) {\n}\n@@ -52,7 +52,7 @@ export class TableNode implements INode {\nreturn columnNodes;\n}\ncolumnNodes = columns.map<ColumnNode>((column) => {\n- return new ColumnNode(this.host, this.user, this.password, this.port, this.database, column);\n+ return new ColumnNode(this.host, this.user, this.password, this.port, this.database,this.table,this.certPath, column);\n})\nDatabaseCache.setColumnListOfTable(this.table, columnNodes)\n@@ -63,6 +63,31 @@ export class TableNode implements INode {\n});\n}\n+ public changeTableName() {\n+\n+ const connection = Utility.createConnection({\n+ host: this.host,\n+ user: this.user,\n+ password: this.password,\n+ port: this.port,\n+ database: this.database,\n+ certPath: this.certPath,\n+ });\n+\n+ vscode.window.showInputBox({ value: this.table, placeHolder: 'newTableName', prompt: `You will changed ${this.database}.${this.table} to new table name!` }).then(newTableName => {\n+ if (!newTableName) return\n+ const sql = `alter table ${this.database}.${this.table} rename ${newTableName}`\n+ Utility.queryPromise(connection, sql).then((rows) => {\n+ DatabaseCache.getParentTreeItem(this, ModelType.TABLE).getChildren(true).then(()=>{\n+ Global.sqlTreeProvider.refresh()\n+ DatabaseCache.storeCurrentCache()\n+ })\n+ })\n+\n+ })\n+\n+ }\n+\npublic async selectSqlTemplate(run: Boolean) {\nAppInsightsClient.sendEvent(\"selectSqlTemplate\");\nconst sql = `SELECT * FROM ${this.database}.${this.table} LIMIT 1000;`;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
add change table/column name support
|
141,908 |
30.04.2019 10:26:12
| -28,800 |
23cb52377e1aae0ad6bfd4c96c6076a1d0dca0a2
|
tree item context menu add dividing line
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n\"command\": \"mysql.newQuery\",\n\"when\": \"view == mysql && viewItem == connection\",\n- \"group\": \"mysql@1\"\n+ \"group\": \"1_mysql@1\"\n},\n{\n\"command\": \"mysql.refresh\",\n\"when\": \"view == mysql && viewItem == connection\",\n- \"group\": \"mysql@1\"\n+ \"group\": \"2_mysql@1\"\n},\n{\n\"command\": \"mysql.deleteConnection\",\n{\n\"command\": \"mysql.newQuery\",\n\"when\": \"view == mysql && viewItem == database\",\n- \"group\": \"mysql@0\"\n+ \"group\": \"2_mysql@0\"\n},\n{\n\"command\": \"mysql.refresh\",\n\"when\": \"view == mysql && viewItem == database\",\n- \"group\": \"mysql\"\n+ \"group\": \"3_mysql\"\n},\n{\n\"command\": \"mysql.deleteDatabase\",\n\"when\": \"view == mysql && viewItem == database\",\n- \"group\": \"mysql@5\"\n+ \"group\": \"4_mysql@5\"\n},\n{\n\"command\": \"mysql.template.sql\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@0\"\n+ \"group\": \"1_mysql@0\"\n},\n{\n\"command\": \"mysql.changeTableName\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"inline\"\n+ \"group\": \"1_inline\"\n},\n{\n\"command\": \"mysql.copy.insert\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@1\"\n+ \"group\": \"1_mysql@1\"\n},\n{\n\"command\": \"mysql.template.delete\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@3\"\n+ \"group\": \"1_mysql@3\"\n},\n{\n\"command\": \"mysql.copy.update\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@2\"\n+ \"group\": \"1_mysql@2\"\n},\n{\n\"command\": \"mysql.table.drop\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@4\"\n+ \"group\": \"2_mysql@4\"\n},\n{\n\"command\": \"mysql.table.truncate\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@4\"\n+ \"group\": \"2_mysql@4\"\n},\n{\n\"command\": \"mysql.data.export\",\n{\n\"command\": \"mysql.refresh\",\n\"when\": \"view == mysql && viewItem == table\",\n- \"group\": \"mysql@4\"\n+ \"group\": \"3_mysql@4\"\n},\n{\n\"command\": \"mysql.changeColumnName\",\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
tree item context menu add dividing line
|
141,908 |
22.02.2020 20:23:22
| -28,800 |
6de9ca9a9cf1834fa4b2febb29a76d5b5ece4ec7
|
reveal pannel when update
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -61,7 +61,7 @@ export class QueryUnit {\n// }\n// });\n} else {\n- SqlViewManager.showQueryResult({ sql, data});\n+ SqlViewManager.showQueryResult({ sql, data, splitResultView: true });\n}\n} else {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
reveal pannel when update
|
141,908 |
22.02.2020 20:29:55
| -28,800 |
ae2b0e08c92f4122873332cc3e2d5e52e98f67c1
|
show run button only when edit sql language
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-manager\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"1.5.2\",\n+ \"version\": \"1.5.3\",\n\"publisher\": \"cweijan\",\n\"icon\": \"logo.png\",\n\"engines\": {\n\"editor/title\": [\n{\n\"command\": \"mysql.runQuery\",\n+ \"when\": \"editorLangId == sql\",\n\"group\": \"navigation\"\n}\n],\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
show run button only when edit sql language
|
141,908 |
07.03.2020 19:05:04
| -28,800 |
0322cf780e352670744b33e6353e6e894a469a23
|
fix change database fail
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/ConnectionManager.ts",
"new_path": "src/database/ConnectionManager.ts",
"diff": "@@ -7,7 +7,7 @@ import { Global } from \"../common/Global\";\nexport class ConnectionManager {\n- private static connectionMap = {}\n+ private static connectionCache = {}\nprivate static lastConnectionOption: IConnection;\nprivate static lastActiveConnection: any;\n@@ -21,11 +21,11 @@ export class ConnectionManager {\nreturn undefined;\n}\n- if (this.lastActiveConnection && ((new Date().getTime() - this.lastActiveConnection.expireTime) < Constants.EXPIRE_TIME)) {\n+ if (this.lastActiveConnection && this.lastActiveConnection.state == 'authenticated') {\nreturn this.lastActiveConnection\n}\n- return this.createConnection(Object.assign({ multipleStatements: true }, this.lastConnectionOption))\n+ return this.getConnection(Object.assign({ multipleStatements: true }, this.lastConnectionOption))\n}\n@@ -35,35 +35,35 @@ export class ConnectionManager {\nconst key = `${connectionOptions.host}_${connectionOptions.port}_${connectionOptions.user}_${connectionOptions.password}_${connectionOptions.database}`\n- let usePoll = false\n- if (this.connectionMap[key] &&\n- ((new Date().getTime() - this.connectionMap[key].expireTime) > Constants.EXPIRE_TIME)) {\n- this.connectionMap[key].conneciton.end()\n- this.connectionMap[key] = undefined\n- } else if (!this.connectionMap[key]) {\n- // Console.log(\"create new \" + key);\n- this.connectionMap[key] = {\n- conneciton: this.createConnection(connectionOptions),\n- expireTime: new Date()\n+ let useCache = false\n+\n+ if (!this.connectionCache[key] ||\n+ (this.connectionCache[key] && this.connectionCache[key].conneciton.state != 'authenticated')) {\n+\n+ this.connectionCache[key] = {\n+ connectionOptions: connectionOptions,\n+ conneciton: this.createConnection(connectionOptions)\n};\n} else {\n- usePoll = true;\n+ useCache = true;\n}\n-\nreturn new Promise((resolve, reject) => {\n- if (usePoll) {\n- this.lastActiveConnection = this.connectionMap[key].conneciton\n- resolve(this.connectionMap[key].conneciton)\n+ if (useCache) {\n+ this.lastConnectionOption = this.connectionCache[key].connectionOptions\n+ this.lastActiveConnection = this.connectionCache[key].conneciton\n+ Global.updateStatusBarItems(this.lastConnectionOption);\n+ resolve(this.connectionCache[key].conneciton)\nreturn;\n}\n- this.connectionMap[key].conneciton.connect((err: Error) => {\n+ this.connectionCache[key].conneciton.connect((err: Error) => {\nif (!err) {\n- Global.updateStatusBarItems(connectionOptions);\n- this.lastActiveConnection = this.connectionMap[key].conneciton\n+ this.lastConnectionOption = connectionOptions\n+ this.lastActiveConnection = this.connectionCache[key].conneciton\n+ Global.updateStatusBarItems(this.lastConnectionOption);\nresolve(this.lastActiveConnection);\n} else {\n- this.connectionMap[key]=undefined\n+ this.connectionCache[key] = undefined\nConsole.log(`${err.stack}\\n${err.message}`)\nreject(err.message);\n}\n@@ -74,7 +74,7 @@ export class ConnectionManager {\npublic static createConnection(connectionOptions: IConnection): any {\n- const newConnectionOptions: any = Object.assign({ useConnectionPooling: true }, connectionOptions);\n+ const newConnectionOptions: any = Object.assign({ useConnectionPooling: true, connectTimeout: Constants.EXPIRE_TIME }, connectionOptions);\nif (connectionOptions.certPath && fs.existsSync(connectionOptions.certPath)) {\nnewConnectionOptions.ssl = {\nca: fs.readFileSync(connectionOptions.certPath),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connection.ts",
"new_path": "src/model/connection.ts",
"diff": "@@ -6,4 +6,5 @@ export interface IConnection {\nreadonly database?: string;\nmultipleStatements?: boolean;\nreadonly certPath: string;\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "@@ -55,7 +55,7 @@ export class ConnectionNode implements INode, IConnection {\npublic async newQuery() {\nQueryUnit.createSQLTextDocument();\n-\n+ ConnectionManager.getConnection(this)\n}\npublic createDatabase(sqlTreeProvider: MySQLTreeDataProvider) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/databaseNode.ts",
"diff": "@@ -54,6 +54,7 @@ export class DatabaseNode implements INode, IConnection {\n});\n}\n+\npublic backupData(exportPath: string) {\nConsole.log(`Doing backup ${this.host}_${this.database}...`)\n@@ -103,6 +104,7 @@ export class DatabaseNode implements INode, IConnection {\npublic async newQuery() {\nQueryUnit.createSQLTextDocument();\n+ ConnectionManager.getConnection(this)\n}\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
fix change database fail
|
141,908 |
07.03.2020 20:15:11
| -28,800 |
e0729cd302e56157e6288cc8fe39a6128c71fb1e
|
remove duplicate complection item
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionManager.ts",
"new_path": "src/provider/CompletionManager.ts",
"diff": "@@ -66,8 +66,12 @@ export class CompletionManager {\ntableNodes = DatabaseCache.getTableNodeList()\n}\n- return tableNodes.map<vscode.CompletionItem>(tableNode => {\n- let completionItem = new vscode.CompletionItem(tableNode.getTreeItem().label)\n+ var tempList=[...new Set(tableNodes.map(tableNode=>{\n+ return tableNode.getTreeItem().label;\n+ }))]\n+\n+ return tempList.map<vscode.CompletionItem>(tableName => {\n+ let completionItem = new vscode.CompletionItem(tableName)\ncompletionItem.kind = vscode.CompletionItemKind.Function\nreturn completionItem\n})\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
remove duplicate complection item
|
141,908 |
07.03.2020 20:47:43
| -28,800 |
29af47335da23a53bf6f3c302bd278cfb4605f95
|
sql assistant enhance
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionManager.ts",
"new_path": "src/provider/CompletionManager.ts",
"diff": "@@ -6,18 +6,19 @@ import { TableNode } from \"../model/TableNode\";\nexport class CompletionManager {\n- private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\"]\n+ private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\",\"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\",\"CREATE\",\"DROP\",\"FUNCTION\",\"PROCEDURE\",\"TRIGGER\"]\nprivate keywordComplectionItems: vscode.CompletionItem[] = []\ngetComplectionItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {\nlet completionItems = []\n- const prePostion = new vscode.Position(position.line, position.character - 1);\n+ const prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\nconst preChart = document.getText(new vscode.Range(prePostion, position))\nif (preChart != \".\" && preChart != \" \") {\ncompletionItems = completionItems.concat(this.keywordComplectionItems)\n}\n+ if ((position.character == 0) ) return completionItems\nlet wordRange = document.getWordRangeAtPosition(prePostion)\nconst inputWord = document.getText(wordRange)\n@@ -50,7 +51,7 @@ export class CompletionManager {\nlet databaseNodes = DatabaseCache.getDatabaseNodeList()\nreturn databaseNodes.map<vscode.CompletionItem>(databaseNode => {\nlet completionItem = new vscode.CompletionItem(databaseNode.getTreeItem().label)\n- completionItem.kind = vscode.CompletionItemKind.Function\n+ completionItem.kind = vscode.CompletionItemKind.Struct\nreturn completionItem\n})\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
sql assistant enhance
|
141,908 |
08.03.2020 00:25:30
| -28,800 |
2e5ab9891186409b84430f96cdfa553d47df767f
|
view node icon fix
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -20,6 +20,7 @@ export class ModelType{\npublic static COLUMN=\"column\"\npublic static INFO=\"info\";\npublic static TABLE_GROUP=\"tableGroup\";\n+ public static VIEW=\"view\";\npublic static VIEW_GROUP=\"viewGroup\";\npublic static TRIGGER_GROUP=\"triggerGroup\";\npublic static PROCEDURE_GROUP=\"procedureGroup\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/viewGroup.ts",
"new_path": "src/model/table/viewGroup.ts",
"diff": "@@ -8,6 +8,7 @@ import { ConnectionManager } from \"../../database/ConnectionManager\";\nimport { TableNode } from \"./tableNode\";\nimport { IConnection } from \"../Connection\";\nimport { Constants, ModelType } from \"../../common/Constants\";\n+import { ViewNode } from \"./viewNode\";\nexport class ViewGroup implements INode, IConnection {\ntype: string; identify: string;\n@@ -36,7 +37,7 @@ export class ViewGroup implements INode, IConnection {\nreturn QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT TABLE_NAME FROM information_schema.VIEWS WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${QueryUnit.maxTableCount}`)\n.then((tables) => {\ntableNodes = tables.map<TableNode>((table) => {\n- return new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME, this.certPath)\n+ return new ViewNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME, this.certPath)\n})\nDatabaseCache.setTableListOfDatabase(this.identify, tableNodes)\nif (tableNodes.length == 0) {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/model/table/viewNode.ts",
"diff": "+import * as path from \"path\";\n+import * as vscode from \"vscode\";\n+import { TableNode } from \"./tableNode\";\n+import { DatabaseCache } from \"../../database/DatabaseCache\";\n+import { ModelType, Constants } from \"../../common/Constants\";\n+\n+export class ViewNode extends TableNode{\n+ public getTreeItem(): vscode.TreeItem {\n+\n+ this.identify = `${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`\n+ return {\n+ label: this.table,\n+ collapsibleState: DatabaseCache.getElementState(this),\n+ contextValue: ModelType.VIEW,\n+ iconPath: path.join(Constants.RES_PATH, \"view.svg\"),\n+ command: {\n+ command: \"mysql.template.sql\",\n+ title: \"Run Select Statement\",\n+ arguments: [this, true]\n+ }\n+ };\n+\n+ }\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
view node icon fix
|
141,908 |
08.03.2020 00:44:15
| -28,800 |
a1a64a453e6826f3d9a72fafaac7dc30f90b338b
|
browser in same panel
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -80,4 +80,20 @@ export class QueryUnit {\nreturn vscode.window.showTextDocument(textDocument);\n}\n+\n+ private static sqlDocument: vscode.TextEditor;\n+ public static async showSQLTextDocument(sql: string = \"\") {\n+\n+ if (this.sqlDocument && !this.sqlDocument.document.isClosed ) {\n+ this.sqlDocument.edit((editBuilder) => {\n+ let lastLine = this.sqlDocument.document.lineCount-1;\n+ editBuilder.replace(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(lastLine, this.sqlDocument.document.lineAt(lastLine).text.length)), sql);\n+ })\n+ } else {\n+ const textDocument = await vscode.workspace.openTextDocument({ content: sql, language: \"sql\" });\n+ this.sqlDocument = await vscode.window.showTextDocument(textDocument)\n+ }\n+ return this.sqlDocument;\n+ }\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/function.ts",
"new_path": "src/model/other/function.ts",
"diff": "@@ -39,7 +39,7 @@ export class FunctionNode implements INode, IConnection {\nQueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SHOW CREATE FUNCTION ${this.database}.${this.name}`)\n.then((procedDtail) => {\nprocedDtail = procedDtail[0]\n- QueryUnit.createSQLTextDocument(`DELIMITER $$\\n\\nDROP FUNCTION IF EXISTS ${procedDtail['Function']}$$ \\n\\n${procedDtail['Create Function']}$$\\n\\nDELIMITER ;`);\n+ QueryUnit.showSQLTextDocument(`DELIMITER $$\\n\\nDROP FUNCTION IF EXISTS ${procedDtail['Function']}$$ \\n\\n${procedDtail['Create Function']}$$\\n\\nDELIMITER ;`);\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/procedure.ts",
"new_path": "src/model/other/procedure.ts",
"diff": "@@ -39,7 +39,7 @@ export class ProcedureNode implements INode, IConnection {\nQueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SHOW CREATE PROCEDURE ${this.database}.${this.name}`)\n.then((procedDtail) => {\nprocedDtail = procedDtail[0]\n- QueryUnit.createSQLTextDocument(`DELIMITER $$\\n\\nDROP PROCEDURE IF EXISTS ${procedDtail['Procedure']}$$ \\n\\n${procedDtail['Create Procedure']}$$\\n\\nDELIMITER ;`);\n+ QueryUnit.showSQLTextDocument(`DELIMITER $$\\n\\nDROP PROCEDURE IF EXISTS ${procedDtail['Procedure']}$$ \\n\\n${procedDtail['Create Procedure']}$$\\n\\nDELIMITER ;`);\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/trigger.ts",
"new_path": "src/model/other/trigger.ts",
"diff": "@@ -38,7 +38,7 @@ export class TriggerNode implements INode, IConnection {\nQueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SHOW CREATE TRIGGER ${this.database}.${this.name}`)\n.then((procedDtail) => {\nprocedDtail = procedDtail[0]\n- QueryUnit.createSQLTextDocument(`DELIMITER $$\\n\\nDROP TRIGGER IF EXISTS ${procedDtail['Trigger']}$$ \\n\\n${procedDtail['SQL Original Statement']}$$\\n\\nDELIMITER ;`);\n+ QueryUnit.showSQLTextDocument(`DELIMITER $$\\n\\nDROP TRIGGER IF EXISTS ${procedDtail['Trigger']}$$ \\n\\n${procedDtail['SQL Original Statement']}$$\\n\\nDELIMITER ;`);\n});\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
browser in same panel
|
141,908 |
08.03.2020 01:23:04
| -28,800 |
39b953a48f1d95d6bb34347f2e121a34519b2bf6
|
support browser user
|
[
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/user.svg",
"diff": "+<?xml version=\"1.0\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg t=\"1583601634548\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"2972\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"200\" height=\"200\"><defs><style type=\"text/css\"></style></defs><path d=\"M977.92 856.576V796.16c0-123.904-219.648-157.696-219.648-157.696h-443.392S92.16 672.256 92.16 796.16v60.416s-0.512 45.568 71.168 47.104c71.68 1.536 373.76 0 373.76 0s300.544 1.536 372.224 0 68.608-47.104 68.608-47.104z\" fill=\"#F04D4E\" p-id=\"2973\"></path><path d=\"M614.4 629.76h-76.288l-223.232 4.608S92.16 672.768 92.16 796.672v60.416s-0.512 45.568 71.168 47.104c71.68 1.536 72.192-1.024 72.192-1.024L453.632 737.28H614.4V629.76z\" fill=\"#D84850\" p-id=\"2974\"></path><path d=\"M404.48 501.76h266.24v163.84h-266.24z\" fill=\"#C7928E\" p-id=\"2975\"></path><path d=\"M785.408 268.288S819.2 371.712 727.04 433.664v-185.344l58.368 19.968zM274.432 268.288S256 371.712 332.8 433.664v-185.344l-58.368 19.968z\" fill=\"#333333\" p-id=\"2976\"></path><path d=\"M332.8 249.344v188.928s45.056 162.816 205.824 162.816S742.4 435.2 742.4 435.2v-172.544s10.24-245.76-203.776-245.76S332.8 249.344 332.8 249.344z\" fill=\"#FECCCB\" p-id=\"2977\"></path><path d=\"M537.6 601.088c-158.72 0-204.8-162.816-204.8-162.816v-188.928s-10.24-232.96 204.8-232.96V601.088z\" fill=\"#D8AEAF\" p-id=\"2978\"></path><path d=\"M450.048 150.016S484.352 286.72 801.792 286.72c0 0-5.12-273.408-263.168-273.408s-266.24 273.408-266.24 273.408 108.032-29.184 177.664-136.704z\" fill=\"#2B2B2B\" p-id=\"2979\"></path><path d=\"M399.872 549.376l-84.48 88.064 138.24 102.4L541.184 670.72z\" fill=\"#B6D5D0\" p-id=\"2980\"></path><path d=\"M673.28 549.376L757.76 637.44l-137.728 102.4L531.968 670.72z\" fill=\"#B6D5D0\" p-id=\"2981\"></path></svg>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -16,6 +16,8 @@ export class CacheKey{\nexport class ModelType{\npublic static CONNECTION=\"connection\"\npublic static DATABASE=\"database\"\n+ public static USER_GROUP=\"userGroup\"\n+ public static USER=\"user\"\npublic static TABLE=\"table\"\npublic static COLUMN=\"column\"\npublic static INFO=\"info\";\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/common/util.ts",
"diff": "+export class Util {\n+ /**\n+ * trim array, got from SO.\n+ * @param origin origin array\n+ * @param attr duplicate check attribute\n+ */\n+ static trim<T>(origin: T[], attr: string): T[] {\n+ let seen = new Set();\n+ return origin.filter(item => {\n+ let temp = item[attr];\n+ return seen.has(temp) ? false : seen.add(temp);\n+ });\n+ }\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/DatabaseCache.ts",
"new_path": "src/database/DatabaseCache.ts",
"diff": "import { ExtensionContext, TreeItemCollapsibleState } from \"vscode\";\nimport { CacheKey, ModelType } from \"../common/Constants\";\nimport { ColumnNode } from \"../model/table/columnNode\";\n-import { DatabaseNode } from \"../model/DatabaseNode\";\n+import { DatabaseNode } from \"../model/database/databaseNode\";\nimport { INode } from \"../model/INode\";\nimport { TableNode } from \"../model/table/tableNode\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "import * as vscode from \"vscode\";\nimport { QueryUnit } from \"./database/QueryUnit\";\nimport { ConnectionNode } from \"./model/ConnectionNode\";\n-import { DatabaseNode } from \"./model/DatabaseNode\";\n+import { DatabaseNode } from \"./model/database/databaseNode\";\nimport { INode } from \"./model/INode\";\nimport { TableNode } from \"./model/table/tableNode\";\nimport { MySQLTreeDataProvider } from \"./provider/MysqlTreeDataProvider\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "import * as path from \"path\";\nimport * as vscode from \"vscode\";\n-import { ModelType, CacheKey, Constants } from \"../common/Constants\";\n+import { CacheKey, Constants, ModelType } from \"../common/Constants\";\n+import { ConnectionManager } from \"../database/ConnectionManager\";\n+import { DatabaseCache } from \"../database/DatabaseCache\";\nimport { QueryUnit } from \"../database/QueryUnit\";\nimport { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\nimport { IConnection } from \"./Connection\";\n-import { DatabaseNode } from \"./DatabaseNode\";\n+import { DatabaseNode } from \"./database/databaseNode\";\n+import { UserGroup } from \"./database/userGroup\";\nimport { InfoNode } from \"./InfoNode\";\nimport { INode } from \"./INode\";\n-import { DatabaseCache } from \"../database/DatabaseCache\";\n-import { ConnectionManager } from \"../database/ConnectionManager\";\nexport class ConnectionNode implements INode, IConnection {\n@@ -44,6 +45,7 @@ export class ConnectionNode implements INode, IConnection {\ndatabaseNodes = databases.map<DatabaseNode>((database) => {\nreturn new DatabaseNode(this.host, this.user, this.password, this.port, database.Database, this.certPath);\n})\n+ databaseNodes.unshift(new UserGroup(this.host, this.user, this.password, this.port,'mysql', this.certPath))\nDatabaseCache.setDataBaseListOfConnection(this.identify, databaseNodes)\nreturn databaseNodes;\n"
},
{
"change_type": "RENAME",
"old_path": "src/model/databaseNode.ts",
"new_path": "src/model/database/databaseNode.ts",
"diff": "+import mysqldump from 'mysqldump';\nimport * as path from \"path\";\nimport * as vscode from \"vscode\";\n-import mysqldump from 'mysqldump'\n-import { QueryUnit } from \"../database/QueryUnit\";\n-import { InfoNode } from \"./InfoNode\";\n-import { INode } from \"./INode\";\n-import { TableNode } from \"./table/tableNode\";\n-import { DatabaseCache } from \"../database/DatabaseCache\";\n-import { ModelType, Constants } from \"../common/Constants\";\n-import { Console } from \"../common/OutputChannel\";\n-import { IConnection } from \"./Connection\";\n-import { ConnectionManager } from \"../database/ConnectionManager\";\n-import { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\n-import { TableGroup } from \"./table/tableGroup\";\n-import { ViewGroup } from \"./table/viewGroup\";\n-import { FunctionGroup } from \"./other/functionGroup\";\n-import { ProcedureGroup } from \"./other/procedureGroup\";\n-import { TriggerGroup } from \"./other/triggerGroup\";\n+import { Constants, ModelType } from \"../../common/Constants\";\n+import { Console } from \"../../common/OutputChannel\";\n+import { ConnectionManager } from \"../../database/ConnectionManager\";\n+import { DatabaseCache } from \"../../database/DatabaseCache\";\n+import { QueryUnit } from \"../../database/QueryUnit\";\n+import { MySQLTreeDataProvider } from \"../../provider/MysqlTreeDataProvider\";\n+import { IConnection } from \"../Connection\";\n+import { INode } from \"../INode\";\n+import { FunctionGroup } from \"../other/functionGroup\";\n+import { ProcedureGroup } from \"../other/procedureGroup\";\n+import { TriggerGroup } from \"../other/triggerGroup\";\n+import { TableGroup } from \"../table/tableGroup\";\n+import { ViewGroup } from \"../table/viewGroup\";\nexport class DatabaseNode implements INode, IConnection {\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/model/database/userGroup.ts",
"diff": "+import * as path from \"path\";\n+import * as vscode from \"vscode\";\n+import { Constants, ModelType } from \"../../common/Constants\";\n+import { DatabaseCache } from \"../../database/DatabaseCache\";\n+import { IConnection } from \"../Connection\";\n+import { INode } from \"../INode\";\n+import { DatabaseNode } from \"./databaseNode\";\n+import { TableNode } from \"../table/tableNode\";\n+import { ConnectionManager } from \"../../database/ConnectionManager\";\n+import { QueryUnit } from \"../../database/QueryUnit\";\n+import { InfoNode } from \"../InfoNode\";\n+import { Util } from \"../../common/util\";\n+\n+export class UserGroup extends DatabaseNode {\n+\n+ identify: string;\n+ type: string = ModelType.DATABASE;\n+ constructor(readonly host: string, readonly user: string,\n+ readonly password: string, readonly port: string, readonly database: string,\n+ readonly certPath: string) {\n+ super(host, user, password, port, database, certPath);\n+ }\n+\n+ public getTreeItem(): vscode.TreeItem {\n+\n+ this.identify = `${this.host}_${this.port}_${this.user}_${ModelType.USER_GROUP}`\n+ return {\n+ label: \"USER\",\n+ collapsibleState: DatabaseCache.getElementState(this),\n+ contextValue: ModelType.USER_GROUP,\n+ iconPath: path.join(Constants.RES_PATH, \"user.svg\")\n+ }\n+\n+ }\n+\n+ public async getChildren(isRresh: boolean = false): Promise<INode[]> {\n+ let userNodes = DatabaseCache.getTableListOfDatabase(this.identify)\n+ if (userNodes && !isRresh) {\n+ return userNodes\n+ }\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT USER,HOST FROM mysql.user;`)\n+ .then((tables) => {\n+ userNodes = Util.trim(tables,'USER').map<UserNode>((table) => {\n+ return new UserNode(this.host, this.user, this.password, this.port, this.database, table.USER, this.certPath)\n+ })\n+ DatabaseCache.setTableListOfDatabase(this.identify, userNodes)\n+ return userNodes;\n+ })\n+ .catch((err) => {\n+ return [new InfoNode(err)];\n+ });\n+\n+ }\n+\n+}\n+\n+\n+export class UserNode extends TableNode {\n+ public getTreeItem(): vscode.TreeItem {\n+\n+ this.identify = `${this.host}_${this.port}_${this.table}`\n+ return {\n+ label: this.table,\n+ collapsibleState: DatabaseCache.getElementState(this),\n+ contextValue: ModelType.USER,\n+ iconPath: path.join(Constants.RES_PATH, \"user.svg\")\n+ // command: {\n+ // command: \"mysql.template.sql\",\n+ // title: \"Run Select Statement\",\n+ // arguments: [this, true]\n+ // }\n+ };\n+\n+ }\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionManager.ts",
"new_path": "src/provider/CompletionManager.ts",
"diff": "import * as vscode from \"vscode\";\nimport { DatabaseCache } from \"../database/DatabaseCache\";\n-import { DatabaseNode } from \"../model/DatabaseNode\";\n+import { DatabaseNode } from \"../model/database/databaseNode\";\nimport { ColumnNode } from \"../model/table/columnNode\";\nimport { TableNode } from \"../model/table/tableNode\";\nimport { INode } from \"../model/INode\";\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support browser user
|
141,908 |
08.03.2020 01:53:17
| -28,800 |
3cb358a7039bb706632826439c2c064604a25458
|
support user browser
|
[
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -13,6 +13,7 @@ import { SqlViewManager } from \"./database/SqlViewManager\";\nimport { ProcedureNode } from \"./model/other/Procedure\";\nimport { FunctionNode } from \"./model/other/function\";\nimport { TriggerNode } from \"./model/other/Trigger\";\n+import { UserNode } from \"./model/database/userGroup\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -94,6 +95,10 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.show.trigger\", (triggerNode: TriggerNode) => {\ntriggerNode.showSource();\n})\n+ ,\n+ vscode.commands.registerCommand(\"mysql.user.sql\", (userNode: UserNode) => {\n+ userNode.selectSqlTemplate();\n+ })\n);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/userGroup.ts",
"new_path": "src/model/database/userGroup.ts",
"diff": "import * as path from \"path\";\nimport * as vscode from \"vscode\";\nimport { Constants, ModelType } from \"../../common/Constants\";\n+import { ConnectionManager } from \"../../database/ConnectionManager\";\nimport { DatabaseCache } from \"../../database/DatabaseCache\";\n+import { QueryUnit } from \"../../database/QueryUnit\";\nimport { IConnection } from \"../Connection\";\n+import { InfoNode } from \"../InfoNode\";\nimport { INode } from \"../INode\";\nimport { DatabaseNode } from \"./databaseNode\";\n-import { TableNode } from \"../table/tableNode\";\n-import { ConnectionManager } from \"../../database/ConnectionManager\";\n-import { QueryUnit } from \"../../database/QueryUnit\";\n-import { InfoNode } from \"../InfoNode\";\n-import { Util } from \"../../common/util\";\nexport class UserGroup extends DatabaseNode {\n@@ -34,42 +32,51 @@ export class UserGroup extends DatabaseNode {\n}\npublic async getChildren(isRresh: boolean = false): Promise<INode[]> {\n- let userNodes = DatabaseCache.getTableListOfDatabase(this.identify)\n- if (userNodes && !isRresh) {\n- return userNodes\n- }\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT USER,HOST FROM mysql.user;`)\n+ let userNodes =[]\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT DISTINCT USER FROM mysql.user;`)\n.then((tables) => {\n- userNodes = Util.trim(tables,'USER').map<UserNode>((table) => {\n- return new UserNode(this.host, this.user, this.password, this.port, this.database, table.USER, this.certPath)\n+ userNodes = tables.map<UserNode>((table) => {\n+ return new UserNode(this.host, this.user, this.password, this.port, table.USER, this.certPath)\n})\n- DatabaseCache.setTableListOfDatabase(this.identify, userNodes)\nreturn userNodes;\n})\n.catch((err) => {\nreturn [new InfoNode(err)];\n});\n-\n}\n}\n-export class UserNode extends TableNode {\n+export class UserNode implements INode, IConnection {\n+ type: string;\n+ identify: string;\n+ constructor(readonly host: string, readonly user: string, readonly password: string,\n+ readonly port: string, readonly name: string,\n+ readonly certPath: string) {\n+ }\npublic getTreeItem(): vscode.TreeItem {\n-\n- this.identify = `${this.host}_${this.port}_${this.table}`\n+ this.identify = `${this.host}_${this.port}_${this.name}`\nreturn {\n- label: this.table,\n+ label: this.name,\ncollapsibleState: DatabaseCache.getElementState(this),\ncontextValue: ModelType.USER,\n- iconPath: path.join(Constants.RES_PATH, \"user.svg\")\n- // command: {\n- // command: \"mysql.template.sql\",\n- // title: \"Run Select Statement\",\n- // arguments: [this, true]\n- // }\n+ iconPath: path.join(Constants.RES_PATH, \"user.svg\"),\n+ command: {\n+ command: \"mysql.user.sql\",\n+ title: \"Run User Detail Statement\",\n+ arguments: [this, true]\n+ }\n};\n+ }\n+ public async getChildren(isRresh: boolean = false): Promise<INode[]> {\n+ return [];\n+ }\n+\n+ public async selectSqlTemplate() {\n+ const sql = `SELECT USER 0USER,HOST 1HOST,Super_priv,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv,Drop_priv,Index_priv,Alter_priv FROM mysql.user where user='${this.name}';`;\n+ QueryUnit.runQuery(sql, this);\n}\n+\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support user browser
|
141,908 |
08.03.2020 02:10:58
| -28,800 |
1b11f44d0ebfcfe56a4703531937c20c25084997
|
refactor reload logic
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "@@ -49,7 +49,7 @@ export class SqlViewManager {\n}\n- public static showConnectPage(mysqlTreeDataProvider: MySQLTreeDataProvider) {\n+ public static showConnectPage(mysqlTreeDataProvider) {\nthis.createWebviewPanel({\nviewPath: \"connect\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -40,28 +40,28 @@ export function activate(context: vscode.ExtensionContext) {\nsqlTreeProvider.init()\n}),\nvscode.commands.registerCommand(\"mysql.addDatabase\", (connectionNode: ConnectionNode) => {\n- connectionNode.createDatabase(sqlTreeProvider)\n+ connectionNode.createDatabase()\n}),\nvscode.commands.registerCommand(\"mysql.deleteDatabase\", (databaseNode: DatabaseNode) => {\n- databaseNode.deleteDatatabase(sqlTreeProvider)\n+ databaseNode.deleteDatatabase()\n}),\nvscode.commands.registerCommand(\"mysql.addConnection\", () => {\nSqlViewManager.showConnectPage(sqlTreeProvider)\n}),\nvscode.commands.registerCommand(\"mysql.changeTableName\", (tableNode: TableNode) => {\n- tableNode.changeTableName(sqlTreeProvider)\n+ tableNode.changeTableName()\n}),\nvscode.commands.registerCommand(\"mysql.table.truncate\", (tableNode: TableNode) => {\ntableNode.truncateTable()\n}),\nvscode.commands.registerCommand(\"mysql.table.drop\", (tableNode: TableNode) => {\n- tableNode.dropTable(sqlTreeProvider)\n+ tableNode.dropTable()\n}),\nvscode.commands.registerCommand(\"mysql.changeColumnName\", (columnNode: ColumnNode) => {\n- columnNode.changeColumnName(sqlTreeProvider)\n+ columnNode.changeColumnName()\n}),\nvscode.commands.registerCommand(\"mysql.deleteConnection\", (connectionNode: ConnectionNode) => {\n- connectionNode.deleteConnection(context, sqlTreeProvider);\n+ connectionNode.deleteConnection(context);\n}),\nvscode.commands.registerCommand(\"mysql.runQuery\", () => {\nQueryUnit.runQuery();\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "@@ -60,21 +60,21 @@ export class ConnectionNode implements INode, IConnection {\nConnectionManager.getConnection(this)\n}\n- public createDatabase(sqlTreeProvider: MySQLTreeDataProvider) {\n+ public createDatabase() {\nvscode.window.showInputBox({ placeHolder: 'Input you want to create new database name.' }).then(async inputContent => {\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), `create database ${inputContent} default character set = 'utf8' `).then(() => {\nDatabaseCache.clearDatabaseCache(this.identify)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\nvscode.window.showInformationMessage(`create database ${inputContent} success!`)\n})\n})\n}\n- public async deleteConnection(context: vscode.ExtensionContext, mysqlTreeDataProvider: MySQLTreeDataProvider) {\n+ public async deleteConnection(context: vscode.ExtensionContext) {\nconst connections = context.globalState.get<{ [key: string]: IConnection }>(CacheKey.ConectionsKey);\ndelete connections[this.id];\nawait context.globalState.update(CacheKey.ConectionsKey, connections);\n- mysqlTreeDataProvider.refresh();\n+ MySQLTreeDataProvider.refresh();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/databaseNode.ts",
"new_path": "src/model/database/databaseNode.ts",
"diff": "@@ -77,12 +77,12 @@ export class DatabaseNode implements INode, IConnection {\n}\n- deleteDatatabase(sqlTreeProvider: MySQLTreeDataProvider) {\n+ deleteDatatabase() {\nvscode.window.showInputBox({ prompt: `Are you want to Delete Database ${this.database} ? `, placeHolder: 'Input y to confirm.' }).then(async inputContent => {\nif (inputContent.toLocaleLowerCase() == 'y') {\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), `DROP DATABASE ${this.database}`).then(() => {\nDatabaseCache.clearDatabaseCache(`${this.host}_${this.port}_${this.user}`)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\nvscode.window.showInformationMessage(`Delete database ${this.database} success!`)\n})\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/function.ts",
"new_path": "src/model/other/function.ts",
"diff": "@@ -71,7 +71,7 @@ export class FunctionNode implements INode, IConnection {\nif (inputContent.toLocaleLowerCase() == 'y') {\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), `DROP TABLE ${this.database}.${this.name}`).then(() => {\nDatabaseCache.clearTableCache(`${this.host}_${this.port}_${this.user}_${this.database}`)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\nvscode.window.showInformationMessage(`Delete table ${this.name} success!`)\n})\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/procedure.ts",
"new_path": "src/model/other/procedure.ts",
"diff": "@@ -71,7 +71,7 @@ export class ProcedureNode implements INode, IConnection {\nif (inputContent.toLocaleLowerCase() == 'y') {\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), `DROP TABLE ${this.database}.${this.name}`).then(() => {\nDatabaseCache.clearTableCache(`${this.host}_${this.port}_${this.user}_${this.database}`)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\nvscode.window.showInformationMessage(`Delete table ${this.name} success!`)\n})\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/trigger.ts",
"new_path": "src/model/other/trigger.ts",
"diff": "@@ -70,7 +70,7 @@ export class TriggerNode implements INode, IConnection {\nif (inputContent.toLocaleLowerCase() == 'y') {\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), `DROP TABLE ${this.database}.${this.name}`).then(() => {\nDatabaseCache.clearTableCache(`${this.host}_${this.port}_${this.user}_${this.database}`)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\nvscode.window.showInformationMessage(`Delete table ${this.name} success!`)\n})\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/columnNode.ts",
"new_path": "src/model/table/columnNode.ts",
"diff": "@@ -39,7 +39,7 @@ export class ColumnNode implements INode, IConnection {\nreturn [];\n}\n- public async changeColumnName( mysqlTreeDataProvider: MySQLTreeDataProvider) {\n+ public async changeColumnName() {\nconst columnName = this.column.COLUMN_NAME\nvscode.window.showInputBox({ value: columnName, placeHolder: 'newColumnName', prompt: `You will changed ${this.table}.${columnName} to new column name!` }).then(async newColumnName => {\n@@ -47,7 +47,7 @@ export class ColumnNode implements INode, IConnection {\nconst sql = `alter table ${this.database}.${this.table} change column ${columnName} ${newColumnName} ${this.column.COLUMN_TYPE}`\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), sql).then((rows) => {\nDatabaseCache.clearColumnCache(`${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`)\n- mysqlTreeDataProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\n})\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -62,27 +62,27 @@ export class TableNode implements INode, IConnection {\n}\n- public changeTableName(sqlTreeProvider: MySQLTreeDataProvider) {\n+ public changeTableName() {\nvscode.window.showInputBox({ value: this.table, placeHolder: 'newTableName', prompt: `You will changed ${this.database}.${this.table} to new table name!` }).then(async newTableName => {\nif (!newTableName) return\nconst sql = `alter table ${this.database}.${this.table} rename ${newTableName}`\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), sql).then((rows) => {\nDatabaseCache.clearTableCache(`${this.host}_${this.port}_${this.user}_${this.database}`)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\n})\n})\n}\n- public dropTable(sqlTreeProvider: MySQLTreeDataProvider) {\n+ public dropTable() {\nvscode.window.showInputBox({ prompt: `Are you want to drop table ${this.table} ? `, placeHolder: 'Input y to confirm.' }).then(async inputContent => {\nif (inputContent.toLocaleLowerCase() == 'y') {\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), `DROP TABLE ${this.database}.${this.table}`).then(() => {\nDatabaseCache.clearTableCache(`${this.host}_${this.port}_${this.user}_${this.database}`)\n- sqlTreeProvider.refresh()\n+ MySQLTreeDataProvider.refresh()\nvscode.window.showInformationMessage(`Delete table ${this.table} success!`)\n})\n} else {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/mysqlTreeDataProvider.ts",
"new_path": "src/provider/mysqlTreeDataProvider.ts",
"diff": "@@ -7,9 +7,12 @@ import { INode } from \"../model/INode\";\nexport class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\npublic _onDidChangeTreeData: vscode.EventEmitter<INode> = new vscode.EventEmitter<INode>();\npublic readonly onDidChangeTreeData: vscode.Event<INode> = this._onDidChangeTreeData.event;\n+ public static instance:MySQLTreeDataProvider\nconstructor(private context: vscode.ExtensionContext) {\n+ MySQLTreeDataProvider.instance=this\nthis.init()\n+\n}\nasync init() {\n@@ -20,7 +23,7 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\n})\n})\n})\n- this.refresh()\n+ MySQLTreeDataProvider.refresh()\n}\npublic getTreeItem(element: INode): Promise<vscode.TreeItem> | vscode.TreeItem {\n@@ -46,11 +49,11 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\nconnections[`${connectionOptions.host}_${connectionOptions.port}_${connectionOptions.user}`] = connectionOptions;\nawait this.context.globalState.update(CacheKey.ConectionsKey, connections);\n- this.refresh();\n+ MySQLTreeDataProvider.refresh();\n}\n- public refresh(element?: INode): void {\n- this._onDidChangeTreeData.fire(element);\n+ public static refresh(element?: INode): void {\n+ this.instance._onDidChangeTreeData.fire(element);\n}\npublic async getConnectionNodes(): Promise<ConnectionNode[]> {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
refactor reload logic
|
141,908 |
08.03.2020 18:19:59
| -28,800 |
1b435a1d99b785d627d9adc0deaea303b21d2a22
|
support update column info
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "MySQL management tool Plus\n-> This plugin forked from [MySQL (Jun Han)](https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-mysql)\n+> This plugin forked from [MySQL](https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-mysql)\n>\n> Many amazing improvements have been made\n>\n+> Welcome to contribute in [repository](https://github.com/cweijan/vscode-mysql)\n+>\n> You can see changes in the [changelog](/CHANGELOG.md)\n+\n## Features\n* Manage MySQL Connections\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"dark\": \"resources/dark/edit.svg\"\n}\n},\n+ {\n+ \"command\": \"mysql.column.add\",\n+ \"title\": \"Add Column Template\",\n+ \"category\": \"MySQL\"\n+ },\n+ {\n+ \"command\": \"mysql.column.update\",\n+ \"title\": \"Modify Column Template\",\n+ \"category\": \"MySQL\"\n+ },\n+ {\n+ \"command\": \"mysql.column.drop\",\n+ \"title\": \"Drop column Template\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.template.view\",\n\"title\": \"Create New View\",\n\"dark\": \"resources/dark/add.svg\"\n}\n},\n+\n{\n\"command\": \"mysql.delete.user\",\n\"title\": \"Drop User\",\n\"category\": \"MySQL\"\n},\n+ {\n+ \"command\": \"mysql.change.user\",\n+ \"title\": \"Change User Password\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.delete.view\",\n\"title\": \"Drop View\",\n\"command\": \"mysql.delete.user\",\n\"when\": \"view == github.cweijan.mysql && viewItem == user\",\n\"group\": \"1_mysql@1\"\n+ },{\n+ \"command\": \"mysql.change.user\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == user\",\n+ \"group\": \"1_mysql@1\"\n},\n{\n\"command\": \"mysql.newQuery\",\n\"when\": \"view == github.cweijan.mysql && viewItem == column\",\n\"group\": \"inline\"\n},\n+ {\n+ \"command\": \"mysql.column.add\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == column\",\n+ \"group\": \"1_mysql@0\"\n+ },\n+ {\n+ \"command\": \"mysql.column.update\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == column\",\n+ \"group\": \"2_mysql@0\"\n+ },\n+ {\n+ \"command\": \"mysql.column.drop\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == column\",\n+ \"group\": \"3_mysql@0\"\n+ },\n{\n\"command\": \"mysql.template.view\",\n\"when\": \"view == github.cweijan.mysql && viewItem == viewGroup\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -63,6 +63,15 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.changeColumnName\", (columnNode: ColumnNode) => {\ncolumnNode.changeColumnName()\n}),\n+ vscode.commands.registerCommand(\"mysql.column.add\", (columnNode: ColumnNode) => {\n+ columnNode.addColumnTemplate()\n+ }),\n+ vscode.commands.registerCommand(\"mysql.column.update\", (columnNode: ColumnNode) => {\n+ columnNode.updateColumnTemplate()\n+ }),\n+ vscode.commands.registerCommand(\"mysql.column.drop\", (columnNode: ColumnNode) => {\n+ columnNode.dropColumnTemplate()\n+ }),\nvscode.commands.registerCommand(\"mysql.deleteConnection\", (connectionNode: ConnectionNode) => {\nconnectionNode.deleteConnection(context);\n}),\n@@ -130,6 +139,9 @@ export function activate(context: vscode.ExtensionContext) {\n}),\nvscode.commands.registerCommand(\"mysql.delete.trigger\", (triggerNode: TriggerNode) => {\ntriggerNode.drop()\n+ }) ,\n+ vscode.commands.registerCommand(\"mysql.change.user\", (userNode: UserNode) => {\n+ userNode.changePasswordTemplate()\n})\n);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/userGroup.ts",
"new_path": "src/model/database/userGroup.ts",
"diff": "@@ -96,7 +96,11 @@ export class UserNode implements INode, IConnection {\nvscode.window.showInformationMessage(`Cancel drop user ${this.name}!`)\n}\n})\n+ }\n+ changePasswordTemplate() {\n+ ConnectionManager.getConnection(this, true)\n+ QueryUnit.createSQLTextDocument(`update mysql.user set password=PASSWORD(\"newPassword\") where User='${this.name}';\\nFLUSH PRIVILEGES;\\n-- since mysql version 5.7, password column need change to authentication_string=PASSWORD(\"test\")`);\n}\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/columnNode.ts",
"new_path": "src/model/table/columnNode.ts",
"diff": "@@ -15,7 +15,6 @@ class ColumnTreeItem extends vscode.TreeItem {\n}\nexport class ColumnNode implements INode, IConnection {\n-\nidentify: string;\ntype: string = ModelType.COLUMN;\nconstructor(readonly host: string, readonly user: string, readonly password: string,\n@@ -32,6 +31,11 @@ export class ColumnNode implements INode, IConnection {\ncollapsibleState: vscode.TreeItemCollapsibleState.None,\ncontextValue: ModelType.COLUMN,\niconPath: path.join(Constants.RES_PATH, this.column.COLUMN_KEY === \"PRI\" ? \"b_primary.png\" : \"b_props.png\"),\n+ command: {\n+ command: \"mysql.column.update\",\n+ title: \"Update Column Statement\",\n+ arguments: [this, true]\n+ }\n};\n}\n@@ -44,7 +48,7 @@ export class ColumnNode implements INode, IConnection {\nconst columnName = this.column.COLUMN_NAME\nvscode.window.showInputBox({ value: columnName, placeHolder: 'newColumnName', prompt: `You will changed ${this.table}.${columnName} to new column name!` }).then(async newColumnName => {\nif (!newColumnName) return\n- const sql = `alter table ${this.database}.${this.table} change column ${columnName} ${newColumnName} ${this.column.COLUMN_TYPE}`\n+ const sql = `alter table ${this.database}.${this.table} change column ${columnName} ${newColumnName} ${this.column.COLUMN_TYPE} comment '${this.column.COLUMN_COMMENT}'`\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), sql).then((rows) => {\nDatabaseCache.clearColumnCache(`${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`)\nMySQLTreeDataProvider.refresh()\n@@ -53,4 +57,18 @@ export class ColumnNode implements INode, IConnection {\n})\n}\n+ addColumnTemplate() {\n+ ConnectionManager.getConnection(this, true)\n+ QueryUnit.createSQLTextDocument(`ALTER TABLE ${this.database}.${this.table} ADD COLUMN name type NOT NULL comment '';`);\n+ }\n+ updateColumnTemplate() {\n+ ConnectionManager.getConnection(this, true)\n+ QueryUnit.showSQLTextDocument(`ALTER TABLE ${this.database}.${this.table} CHANGE ${this.column.COLUMN_NAME} ${this.column.COLUMN_NAME} ${this.column.COLUMN_TYPE} NOT NULL comment '${this.column.COLUMN_COMMENT}';`);\n+ }\n+ dropColumnTemplate() {\n+ ConnectionManager.getConnection(this, true)\n+ QueryUnit.createSQLTextDocument(`ALTER TABLE ${this.database}.${this.table} DROP COLUMN ${this.column.COLUMN_NAME};`);\n+ }\n+\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableGroup.ts",
"new_path": "src/model/table/tableGroup.ts",
"diff": "@@ -33,7 +33,7 @@ export class TableGroup implements INode, IConnection {\nif (tableNodes && !isRresh) {\nreturn tableNodes\n}\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' LIMIT ${QueryUnit.maxTableCount}`)\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' and TABLE_TYPE='BASE TABLE' LIMIT ${QueryUnit.maxTableCount} ;`)\n.then((tables) => {\ntableNodes = tables.map<TableNode>((table) => {\nreturn new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME, this.certPath)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/mysqlTreeDataProvider.ts",
"new_path": "src/provider/mysqlTreeDataProvider.ts",
"diff": "@@ -4,6 +4,7 @@ import { IConnection } from \"../model/Connection\";\nimport { ConnectionNode } from \"../model/ConnectionNode\";\nimport { INode } from \"../model/INode\";\nimport { ConnectionManager } from \"../database/ConnectionManager\";\n+import { DatabaseCache } from \"../database/DatabaseCache\";\nexport class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\npublic _onDidChangeTreeData: vscode.EventEmitter<INode> = new vscode.EventEmitter<INode>();\n@@ -27,6 +28,7 @@ export class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\n})\n})\n})\n+ DatabaseCache.clearColumnCache()\nMySQLTreeDataProvider.refresh()\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "syntaxes/mysql.tmLanguage.json",
"new_path": "syntaxes/mysql.tmLanguage.json",
"diff": "\"scopeName\": \"source.sql\",\n\"patterns\": [\n{\n- \"match\": \"TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED\",\n+ \"match\": \"TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED|PRIVILEGES|FLUSH\",\n\"name\": \"keyword.mysql\"\n},\n{\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support update column info
|
141,908 |
08.03.2020 19:36:14
| -28,800 |
def9e2fa9094a4384aa7235451cf059300d7b5f4
|
manage index simplistic
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -45,3 +45,4 @@ MySQL management tool Plus\n## Future Plain\n- Beautify query result page.\n- Edit data alive on query result page.\n+- Record sql execute history.\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"dark\": \"resources/dark/edit.svg\"\n}\n},\n+ {\n+ \"command\": \"mysql.index.template\",\n+ \"title\": \"Index Manage Template\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.changeColumnName\",\n\"title\": \"change column name\",\n\"dark\": \"resources/dark/add.svg\"\n}\n},\n-\n{\n\"command\": \"mysql.delete.user\",\n\"title\": \"Drop User\",\n\"command\": \"mysql.delete.user\",\n\"when\": \"view == github.cweijan.mysql && viewItem == user\",\n\"group\": \"1_mysql@1\"\n- },{\n+ },\n+ {\n\"command\": \"mysql.change.user\",\n\"when\": \"view == github.cweijan.mysql && viewItem == user\",\n\"group\": \"1_mysql@1\"\n{\n\"command\": \"mysql.changeTableName\",\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n- \"group\": \"1_inline\"\n+ \"group\": \"1_inline@0\"\n+ },\n+ {\n+ \"command\": \"mysql.index.template\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == table\",\n+ \"group\": \"1_inline@1\"\n},\n{\n\"command\": \"mysql.copy.insert\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -51,7 +51,7 @@ export class QueryUnit {\nsql = activeTextEditor.document.getText(selection);\n}\n}\n-\n+ sql = sql.replace(/--.+/ig, '');\nconnection.query(sql, (err, data) => {\nlet isDDL = sql.match(this.ddlPattern);\nif (Array.isArray(data) && !isDDL) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -54,6 +54,9 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.changeTableName\", (tableNode: TableNode) => {\ntableNode.changeTableName()\n}),\n+ vscode.commands.registerCommand(\"mysql.index.template\", (tableNode: TableNode) => {\n+ tableNode.indexTemplate()\n+ }),\nvscode.commands.registerCommand(\"mysql.table.truncate\", (tableNode: TableNode) => {\ntableNode.truncateTable()\n}),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/columnNode.ts",
"new_path": "src/model/table/columnNode.ts",
"diff": "@@ -22,12 +22,21 @@ export class ColumnNode implements INode, IConnection {\nreadonly certPath: string, private readonly column: any) {\n}\n+ private getIndex(columnKey:string){\n+ switch(columnKey){\n+ case 'UNI':return \"UniqueKey\"\n+ case 'MUL':return \"IndexKey\"\n+ case 'PRI':return \"PrimaryKey\"\n+ }\n+ return '';\n+ }\n+\npublic getTreeItem(): ColumnTreeItem {\nreturn {\ncolumnName: `${this.column.COLUMN_NAME}`,\ndetail: `${this.column.COLUMN_TYPE}`,\ndocument: `${this.column.COLUMN_COMMENT}`,\n- label: `${this.column.COLUMN_NAME} : ${this.column.COLUMN_TYPE} ${this.column.COLUMN_COMMENT}`,\n+ label: `${this.column.COLUMN_NAME} : ${this.column.COLUMN_TYPE} ${this.getIndex(this.column.COLUMN_KEY)} ${this.column.COLUMN_COMMENT}`,\ncollapsibleState: vscode.TreeItemCollapsibleState.None,\ncontextValue: ModelType.COLUMN,\niconPath: path.join(Constants.RES_PATH, this.column.COLUMN_KEY === \"PRI\" ? \"b_primary.png\" : \"b_props.png\"),\n@@ -59,7 +68,7 @@ export class ColumnNode implements INode, IConnection {\naddColumnTemplate() {\nConnectionManager.getConnection(this, true)\n- QueryUnit.createSQLTextDocument(`ALTER TABLE ${this.database}.${this.table} ADD COLUMN name type NOT NULL comment '';`);\n+ QueryUnit.createSQLTextDocument(`ALTER TABLE ${this.database}.${this.table} ADD COLUMN columnName columnType NOT NULL comment '';`);\n}\nupdateColumnTemplate() {\nConnectionManager.getConnection(this, true)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableGroup.ts",
"new_path": "src/model/table/tableGroup.ts",
"diff": "@@ -33,7 +33,7 @@ export class TableGroup implements INode, IConnection {\nif (tableNodes && !isRresh) {\nreturn tableNodes\n}\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' and TABLE_TYPE='BASE TABLE' LIMIT ${QueryUnit.maxTableCount} ;`)\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '${this.database}' and TABLE_TYPE<>'VIEW' LIMIT ${QueryUnit.maxTableCount} ;`)\n.then((tables) => {\ntableNodes = tables.map<TableNode>((table) => {\nreturn new TableNode(this.host, this.user, this.password, this.port, this.database, table.TABLE_NAME, this.certPath)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -47,7 +47,7 @@ export class TableNode implements INode, IConnection {\nif (columnNodes && !isRresh) {\nreturn columnNodes;\n}\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT * FROM information_schema.columns WHERE table_schema = '${this.database}' AND table_name = '${this.table}';`)\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT COLUMN_NAME,COLUMN_TYPE,COLUMN_COMMENT,COLUMN_TYPE,COLUMN_KEY FROM information_schema.columns WHERE table_schema = '${this.database}' AND table_name = '${this.table}';`)\n.then((columns) => {\ncolumnNodes = columns.map<ColumnNode>((column) => {\nreturn new ColumnNode(this.host, this.user, this.password, this.port, this.database, this.table, this.certPath, column);\n@@ -106,6 +106,16 @@ export class TableNode implements INode, IConnection {\n}\n+ indexTemplate() {\n+ ConnectionManager.getConnection(this, true)\n+ QueryUnit.showSQLTextDocument(`-- ALTER TABLE ${this.database}.${this.table} DROP INDEX [indexName];\n+-- ALTER TABLE ${this.database}.${this.table} ADD [UNIQUE|KEY|PRIMARY KEY] INDEX ([column]);`)\n+ setTimeout(() => {\n+ QueryUnit.runQuery(`SELECT column_name,table_schema,index_name,non_unique FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema='${this.database}' and table_name='${this.table}';`, this)\n+ }, 10);\n+\n+ }\n+\npublic async selectSqlTemplate(run: Boolean) {\nconst sql = `SELECT * FROM ${this.database}.${this.table} LIMIT 1000;`;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionManager.ts",
"new_path": "src/provider/CompletionManager.ts",
"diff": "@@ -9,7 +9,7 @@ import { ModelType } from \"../common/Constants\";\nexport class CompletionManager {\n- private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"PROCEDURE\", \"TRIGGER\"]\n+ private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"PROCEDURE\", \"TRIGGER\",\"INDEX\",\"CHANGE\",\"COMMENT\",\"COLUMN\",\"ADD\",'SHOW',\"PRIVILEGES\",\"IDENTIFIED\",\"VIEW\",\"CURSOR\"]\nprivate keywordComplectionItems: vscode.CompletionItem[] = []\ngetComplectionItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {\n"
},
{
"change_type": "MODIFY",
"old_path": "syntaxes/mysql.tmLanguage.json",
"new_path": "syntaxes/mysql.tmLanguage.json",
"diff": "\"scopeName\": \"source.sql\",\n\"patterns\": [\n{\n- \"match\": \"TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED|PRIVILEGES|FLUSH\",\n+ \"match\": \"(?i)\\\\b(TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED|PRIVILEGES|FLUSH|SHOW|INDEX|CHANGE|COMMENT|COLUMN|ADD|UNIQUE)\\\\b\",\n\"name\": \"keyword.mysql\"\n},\n{\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
manage index simplistic
|
141,908 |
09.03.2020 00:08:43
| -28,800 |
27e85dfaceaa5c6d79d720aa0f39e4af3df1ba67
|
change active when query table data
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -121,6 +121,7 @@ export class TableNode implements INode, IConnection {\nconst sql = `SELECT * FROM ${this.database}.${this.table} LIMIT 1000;`;\nif (run) {\n+ ConnectionManager.getConnection(this,true)\nQueryUnit.runQuery(sql, this);\n} else {\nQueryUnit.createSQLTextDocument(sql);\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
change active when query table data
|
141,908 |
11.03.2020 17:57:02
| -28,800 |
1081e27a38bfe1314781c678ee1ad1f0c8d867f0
|
query page optimize
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-manager\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"1.6.2\",\n+ \"version\": \"1.6.34\",\n\"publisher\": \"cweijan\",\n\"icon\": \"logo.png\",\n\"engines\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<style>\nbody {\nbackground-color: #F7F7F7;\n+ font-family: \"Helvetica Neue\",Helvetica,\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft YaHei\",Arial,sans-serif;\n}\n.hint {\nmargin-top: 8px;\n}\n- .toolbar {\n- margin: 5px;\n- }\n-\n.cell {\noverflow: hidden !important;\ntext-overflow: unset !important;\n<body>\n<div id=\"app\">\n<div class=\"hint\">\n- <el-input type=\"textarea\" autosize v-model=\"result.sql\" style=\"width: 600px;\">\n- </el-input>\n- <div class=\"toolbar\">\n- <span>executeTime : </span><span v-text=\"updateTime\"></span>\n- <span>costTime : </span><span v-text=\"result.costTime\"></span>ms\n+ <el-row style=\"margin-bottom: 10px;\">\n+ <el-input type=\"textarea\" autosize v-model=\"result.sql\" style=\"width: 600px;\"></el-input>\n<el-button type=\"danger\" @click='execute' round>Execute</el-button>\n- </div>\n+ </el-row>\n<el-row>\n- <el-button type=\"warning\" @click=\"deleteTemplate\" round>Delete Template</el-button>\n+ <el-cow>\n<el-input v-model=\"search\" style=\"width:200px\" placeholder=\"Type to search\" />\n+ </el-cow>\n+ <el-cow>\n+ <span>costTime: </span><span v-text=\"result.costTime\"></span>ms,\n+ <span>row: {{result.rows.length}}, Col: {{columnCount}}</span>\n+ </el-cow>\n</el-row>\n</div>\n- <el-table id=\"dataTable\" v-loading='loading'\n+ <el-table id=\"dataTable\" v-loading='loading' size='small' highlight-current-row='true'\n:data=\"result.rows.filter(data => !search || JSON.stringify(data).toLowerCase().includes(search.toLowerCase()))\"\nstyle=\"width: 100%\" border @cell-click=\"celledit\">\n- <el-table-column :label=\"key\" v-for=\"(value,key) in result.rows[0]\" :key=\"key\"\n- show-overflow-tooltip align=\"center\">\n+ <el-table-column :label=\"key\" v-for=\"(value,key) in result.rows[0]\" :key=\"key\" show-overflow-tooltip\n+ align=\"center\">\n<template slot-scope=\"scope\">\n- <span>{{scope.row[key]}}</span>\n+ <span v-html='dataformat(scope.row[key])'></span>\n</template>\n</el-table-column>\n</el-table>\n</body>\n<script>\n- var formatNow = function (formatStr) {\n- var date = new Date();\n- var zeroize = function (value, length) {\n- if (!length) {\n- length = 2;\n- }\n- value = new String(value);\n- for (var i = 0, zeros = ''; i < (length - value.length); i++) {\n- zeros += '0';\n- }\n- return zeros + value;\n- };\n- return formatStr.replace(/\"[^\"]*\"|'[^']*'|\\b(?:d{1,4}|M{1,4}|yy(?:yy)?|([hHmstT])\\1?|[lLZ])\\b/g, function ($0) {\n- switch ($0) {\n- case 'd': return date.getDate();\n- case 'dd': return zeroize(date.getDate());\n- case 'ddd': return ['Sun', 'Mon', 'Tue', 'Wed', 'Thr', 'Fri', 'Sat'][date.getDay()];\n- case 'dddd': return ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][date.getDay()];\n- case 'M': return date.getMonth() + 1;\n- case 'MM': return zeroize(date.getMonth() + 1);\n- case 'MMM': return ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][date.getMonth()];\n- case 'MMMM': return ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'][date.getMonth()];\n- case 'yy': return new String(date.getFullYear()).substr(2);\n- case 'yyyy': return date.getFullYear();\n- case 'h': return date.getHours() % 12 || 12;\n- case 'hh': return zeroize(date.getHours() % 12 || 12);\n- case 'H': return date.getHours();\n- case 'HH': return zeroize(date.getHours());\n- case 'm': return date.getMinutes();\n- case 'mm': return zeroize(date.getMinutes());\n- case 's': return date.getSeconds();\n- case 'ss': return zeroize(date.getSeconds());\n- case 'l': return date.getMilliseconds();\n- case 'll': return zeroize(date.getMilliseconds());\n- case 'tt': return date.getHours() < 12 ? 'am' : 'pm';\n- case 'TT': return date.getHours() < 12 ? 'AM' : 'PM';\n- }\n- });\n- }\nconst vscode = acquireVsCodeApi();\nconst previousState = vscode.getState();\nconst vue = new Vue({\nsql: '',\ncostTime: 0\n},\n- updateTime: formatNow('yyyy-MM-dd HH:mm:ss'),\nsearch: '',\nloading: false\n},\nmethods: {\ncelledit(row, column, cell, event) {\n- cell.contentEditable = true;\n- cell.focus()\n+ // cell.contentEditable = true;\n+ // cell.focus()\n},\nexecute() {\nvscode.postMessage({\n},\ndeleteTemplate() {\nthis.result.sql = `DELETE FROM [table] WHERE id= `;\n+ },\n+ dataformat(origin) {\n+ if (origin == undefined || origin == null) {\n+ return \"<b>(NULL)</b>\";\n+ }\n+ return origin;\n+ }\n+ },\n+ computed: {\n+ columnCount() {\n+ if (this.result.rows == undefined || this.result.rows[0] == undefined) return 0;\n+ return Object.keys(this.result.rows[0]).length;\n}\n}\n})\nvue.result.sql = event.data.sql\nvue.result.costTime = event.data.costTime\nvue.loading = false\n- vue.updateTime = formatNow('yyyy-MM-dd HH:mm:ss')\n- vscode.setState({ result: vue.result });\n+ // instead by retainContextWhenHidden=true\n+ // vscode.setState({ result: vue.result });\ndocument.write(previousState + \":\" + count)\n});\n</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "@@ -41,7 +41,7 @@ export class SqlViewManager {\n}\nviewOption.viewPath = \"result\"\n- viewOption.viewTitle = \"result\"\n+ viewOption.viewTitle = \"Query\"\nthis.createWebviewPanel(viewOption).then(webviewPanel => {\nthis.resultWebviewPanel = webviewPanel\n@@ -95,7 +95,7 @@ export class SqlViewManager {\n\"mysql.sql.result\",\nviewOption.viewTitle,\ncolumnType,\n- { enableScripts: true }\n+ { enableScripts: true,retainContextWhenHidden:true }\n);\nwebviewPanel.webview.html = data.replace(/\\$\\{webviewPath\\}/gi,\nvscode.Uri.file(`${this.extensionPath}/resources/webview`)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
query page optimize
|
141,908 |
18.03.2020 00:25:45
| -28,800 |
c9330e216b04ed00db76ac7979ae66eadbac2c2b
|
get sql divisiton with semicolon on editor
|
[
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -13,6 +13,14 @@ export class CacheKey{\n}\n+\n+export class Cursor{\n+ static FIRST_POSITION=new vscode.Position(0, 0);\n+ static getRangeStartTo(end:vscode.Position):vscode.Range{\n+ return new vscode.Range(this.FIRST_POSITION,end);\n+ }\n+}\n+\nexport class ModelType{\npublic static CONNECTION=\"connection\"\npublic static DATABASE=\"database\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/util.ts",
"new_path": "src/common/util.ts",
"diff": "+\n+import { Position, TextDocument } from \"vscode\";\n+\nexport class Util {\n/**\n* trim array, got from SO.\n@@ -11,4 +14,10 @@ export class Util {\nreturn seen.has(temp) ? false : seen.add(temp);\n});\n}\n+\n+ static getDocumentLastPosition(document: TextDocument): Position {\n+ let lastLine = document.lineCount - 1;\n+ return new Position(lastLine, document.lineAt(lastLine).text.length);\n+ }\n+\n}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "\"use strict\";\nimport * as vscode from \"vscode\";\n-import { IConnection } from \"../model/Connection\";\n+import { Cursor } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\n-import { SqlViewManager } from \"./SqlViewManager\";\n-import { ConnectionManager } from \"./ConnectionManager\";\n+import { Util } from \"../common/util\";\n+import { IConnection } from \"../model/Connection\";\nimport { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\n+import { ConnectionManager } from \"./ConnectionManager\";\n+import { SqlViewManager } from \"./SqlViewManager\";\nexport class QueryUnit {\npublic static readonly maxTableCount = QueryUnit.getConfiguration().get<number>(\"maxTableCount\");\n@@ -46,7 +48,7 @@ export class QueryUnit {\nconst activeTextEditor = vscode.window.activeTextEditor;\nconst selection = activeTextEditor.selection;\nif (selection.isEmpty) {\n- sql = activeTextEditor.document.getText();\n+ sql = this.obtainSql(activeTextEditor);\n} else {\nsql = activeTextEditor.document.getText(selection);\n}\n@@ -61,6 +63,7 @@ export class QueryUnit {\nConsole.log(`execute sql success:${sql}`)\n}\nif (err) {\n+ //TODO trans output to query page\nConsole.log(err);\n} else if (isDDL) {\nMySQLTreeDataProvider.instance.init()\n@@ -68,6 +71,26 @@ export class QueryUnit {\n});\n}\n+\n+ private static batchPattern = /(TRIGGER|PROCEDURE|FUNCTION)/ig\n+ private static obtainSql(activeTextEditor: vscode.TextEditor): string {\n+\n+ var content = activeTextEditor.document.getText()\n+ if (content.match(this.batchPattern)) return content;\n+\n+ var sqlList = content.split(\";\");\n+ var doc_cursor = activeTextEditor.document.getText(Cursor.getRangeStartTo(activeTextEditor.selection.active)).length;\n+ var index = 0;\n+ for (let sql of sqlList) {\n+ index += (sql.length + 1)\n+ if (doc_cursor < index) {\n+ return sql.trim() + \";\";\n+ }\n+ }\n+\n+ return '';\n+ }\n+\npublic static async createSQLTextDocument(sql: string = \"\") {\nconst textDocument = await vscode.workspace.openTextDocument({ content: sql, language: \"sql\" });\nreturn vscode.window.showTextDocument(textDocument);\n@@ -79,8 +102,7 @@ export class QueryUnit {\nif (this.sqlDocument && !this.sqlDocument.document.isClosed && !this.sqlDocument['_disposed'] && this.sqlDocument.document.isUntitled) {\nthis.sqlDocument.edit((editBuilder) => {\n- let lastLine = this.sqlDocument.document.lineCount - 1;\n- editBuilder.replace(new vscode.Range(new vscode.Position(0, 0), new vscode.Position(lastLine, this.sqlDocument.document.lineAt(lastLine).text.length)), sql);\n+ editBuilder.replace(Cursor.getRangeStartTo(Util.getDocumentLastPosition(this.sqlDocument.document)), sql);\n})\n} else {\nconst textDocument = await vscode.workspace.openTextDocument({ content: sql, language: \"sql\" });\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
get sql divisiton with semicolon on editor
|
141,908 |
18.03.2020 00:38:27
| -28,800 |
c7059c134fee1d5c0cc9666519e1afb36b29639f
|
Optimization of result display
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "@@ -35,9 +35,14 @@ export class SqlViewManager {\npublic static showQueryResult(viewOption: ViewOption) {\nif (this.resultWebviewPanel) {\n+ if (this.resultWebviewPanel.visible) {\nthis.resultWebviewPanel.webview.postMessage(viewOption)\nthis.resultWebviewPanel.reveal(vscode.ViewColumn.Two, true);\nreturn;\n+ } else {\n+ this.resultWebviewPanel.dispose()\n+ }\n+\n}\nviewOption.viewPath = \"result\"\n@@ -94,7 +99,7 @@ export class SqlViewManager {\nconst webviewPanel = await vscode.window.createWebviewPanel(\n\"mysql.sql.result\",\nviewOption.viewTitle,\n- columnType,\n+ {viewColumn:columnType,preserveFocus:true},\n{ enableScripts: true, retainContextWhenHidden: true }\n);\nwebviewPanel.webview.html = data.replace(/\\$\\{webviewPath\\}/gi,\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Optimization of result display
|
141,908 |
18.03.2020 22:51:07
| -28,800 |
36df131ba277309ad553acde6794481379841486
|
fix mysql 8.0 get procedure|function fail
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/other/functionGroup.ts",
"new_path": "src/model/other/functionGroup.ts",
"diff": "@@ -33,10 +33,10 @@ export class FunctionGroup implements INode, IConnection {\nif (tableNodes && !isRresh) {\nreturn tableNodes\n}\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT specific_name FROM mysql.proc WHERE db = '${this.database}' and type='FUNCTION'`)\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT ROUTINE_NAME FROM information_schema.routines WHERE ROUTINE_SCHEMA = '${this.database}' and ROUTINE_TYPE='FUNCTION'`)\n.then((tables) => {\ntableNodes = tables.map<FunctionNode>((table) => {\n- return new FunctionNode(this.host, this.user, this.password, this.port, this.database, table.specific_name, this.certPath)\n+ return new FunctionNode(this.host, this.user, this.password, this.port, this.database, table.ROUTINE_NAME, this.certPath)\n})\nDatabaseCache.setTableListOfDatabase(this.identify, tableNodes)\nif (tableNodes.length == 0) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/other/procedureGroup.ts",
"new_path": "src/model/other/procedureGroup.ts",
"diff": "import * as path from \"path\";\nimport * as vscode from \"vscode\";\n+import { Constants, ModelType } from \"../../common/Constants\";\n+import { ConnectionManager } from \"../../database/ConnectionManager\";\n+import { DatabaseCache } from \"../../database/DatabaseCache\";\nimport { QueryUnit } from \"../../database/QueryUnit\";\n+import { IConnection } from \"../Connection\";\nimport { InfoNode } from \"../InfoNode\";\nimport { INode } from \"../INode\";\n-import { DatabaseCache } from \"../../database/DatabaseCache\";\n-import { ConnectionManager } from \"../../database/ConnectionManager\";\n-import { TableNode } from \"../table/tableNode\";\n-import { IConnection } from \"../Connection\";\n-import { Constants, ModelType } from \"../../common/Constants\";\nimport { ProcedureNode } from \"./Procedure\";\nexport class ProcedureGroup implements INode, IConnection {\n@@ -34,10 +33,10 @@ export class ProcedureGroup implements INode, IConnection {\nif (tableNodes && !isRresh) {\nreturn tableNodes\n}\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT specific_name FROM mysql.proc WHERE db = '${this.database}' and type='PROCEDURE'`)\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT ROUTINE_NAME FROM information_schema.routines WHERE ROUTINE_SCHEMA = '${this.database}' and ROUTINE_TYPE='PROCEDURE'`)\n.then((tables) => {\ntableNodes = tables.map<INode>((table) => {\n- return new ProcedureNode(this.host, this.user, this.password, this.port, this.database, table.specific_name, this.certPath)\n+ return new ProcedureNode(this.host, this.user, this.password, this.port, this.database, table.ROUTINE_NAME, this.certPath)\n})\nDatabaseCache.setTableListOfDatabase(this.identify, tableNodes)\nif (tableNodes.length == 0) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
fix mysql 8.0 get procedure|function fail
|
141,908 |
19.03.2020 10:41:49
| -28,800 |
019c4aa7e8df58409e808c2c7d03a33dc7f40b1a
|
fix many connection
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "+## 1.6.35 (2020/3/18)\n+- get sql divisiton with semicolon on editor\n+- fix mysql 8.0 get function|procedure info fail.\n+\n## 1.6.2 (2020/3/9)\n- Beautify query result page.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-manager\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"1.6.34\",\n+ \"version\": \"1.6.35\",\n\"publisher\": \"cweijan\",\n\"icon\": \"logo.png\",\n\"engines\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<div class=\"hint\">\n<el-row style=\"margin-bottom: 10px;\">\n<el-input type=\"textarea\" autosize v-model=\"result.sql\" style=\"width: 600px;\"></el-input>\n- <el-button type=\"danger\" @click='execute' round>Execute</el-button>\n</el-row>\n<el-row>\n<el-cow>\n<el-input v-model=\"search\" style=\"width:200px\" placeholder=\"Type to search\" />\n</el-cow>\n+ <el-cow>\n+ <el-button type=\"danger\" @click='execute' >Execute</el-button>\n+ </el-cow>\n<el-cow>\n<span>costTime: </span><span v-text=\"result.costTime\"></span>ms,\n<span>row: {{result.rows.length}}, Col: {{columnCount}}</span>\n"
},
{
"change_type": "DELETE",
"old_path": "resources/webview/table.html",
"new_path": null,
"diff": "-<html>\n-\n-<head>\n- <title>result</title>\n- <link rel=\"stylesheet\" href=\"${webviewPath}/css/table.css\">\n- <script src=\"${webviewPath}/vue.js\"></script>\n-</head>\n-\n-<body>\n- <div id=\"app\">\n- <table>\n- <tr>\n- <th>column-name</th>\n- <th>type</th>\n- <th>length</th>\n- <th>default-value</th>\n- <th>primary</th>\n- <th>unique</th>\n- <th>not-null</th>\n- <th>unsigned</th>\n- <th>comment</th>\n- </tr>\n- <tr v-for=\"column in columns\">\n- <td v-text=\"\"></td>\n- <td>\n- <select></select>\n- </td>\n- <td v-text=\"\"></td>\n- <td v-text=\"\"></td>\n- <td><input :model=\"\" type=\"checkbox\"></td>\n- <td><input :model=\"\" type=\"checkbox\"></td>\n- <td><input :model=\"\" type=\"checkbox\"></td>\n- <td><input :model=\"\" type=\"checkbox\"></td>\n- <td v-text=\"\"></td>\n- </tr>\n- </table>\n- </div>\n-</body>\n-<script>\n- const vscode = acquireVsCodeApi();\n- const previousState = vscode.getState();\n- var sql = \"\";\n- var temp = previousState ? previousState.temp : {};\n- const vue = new Vue({\n- el: '#app',\n- data: previousState ? previousState.metadata : {\n- metadata: {\n- columns: [{}, {}],\n- type: 'create',\n- tableName: '',\n- engine: '',\n- charset: 'utf8',\n- database: ''\n- }\n- }\n- })\n- vscode.postMessage({\n- command: 'webview.table.execute',\n- text: sql\n- })\n- window.addEventListener('message', event => {\n- vue.metadata = data\n- if (vue.metadata.type == \"change\") temp = data;\n- vscode.setState({ metadata: vue.metadata, temp: temp });\n- });\n-</script>\n-\n-</html>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -2,8 +2,6 @@ import * as vscode from \"vscode\";\nimport * as path from \"path\";\nexport class Constants {\n- /** db connection alive time :10minute */\n- public static EXPIRE_TIME=10*60*1000;\npublic static RES_PATH=path.join(vscode.extensions.getExtension('cweijan.vscode-mysql-manager').extensionPath,\"resources\");\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/ConnectionManager.ts",
"new_path": "src/database/ConnectionManager.ts",
"diff": "@@ -4,6 +4,7 @@ import { IConnection } from \"../model/Connection\";\nimport { Constants } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\nimport { Global } from \"../common/Global\";\n+import { QueryUnit } from \"./QueryUnit\";\nexport class ConnectionManager {\n@@ -24,7 +25,6 @@ export class ConnectionManager {\nif (this.lastActiveConnection && this.lastActiveConnection.state == 'authenticated') {\nreturn this.lastActiveConnection\n}\n-\nreturn this.getConnection(Object.assign({ multipleStatements: true }, this.lastConnectionOption))\n}\n@@ -33,37 +33,41 @@ export class ConnectionManager {\nif (!connectionOptions.multipleStatements) connectionOptions.multipleStatements = true\n- const key = `${connectionOptions.host}_${connectionOptions.port}_${connectionOptions.user}_${connectionOptions.password}_${connectionOptions.database}`\n-\n- let useCache = false\n+ const key = `${connectionOptions.host}_${connectionOptions.port}_${connectionOptions.user}_${connectionOptions.password}`\n- if (!this.connectionCache[key] ||\n- (this.connectionCache[key] && this.connectionCache[key].conneciton.state != 'authenticated')) {\n+ return new Promise((resolve, reject) => {\n- this.connectionCache[key] = {\n- connectionOptions: connectionOptions,\n- conneciton: this.createConnection(connectionOptions)\n- };\n- } else {\n- useCache = true;\n+ if (this.connectionCache[key] && this.connectionCache[key].conneciton.state == 'authenticated') {\n+ if (connectionOptions.database) {\n+ QueryUnit.queryPromise(this.connectionCache[key].conneciton, `use ${connectionOptions.database}`).then(() => {\n+ if (changeActive || this.lastActiveConnection == undefined) {\n+ this.lastConnectionOption = this.connectionCache[key].connectionOptions\n+ this.lastActiveConnection = this.connectionCache[key].conneciton\n+ Global.updateStatusBarItems(connectionOptions);\n}\n-\n- return new Promise((resolve, reject) => {\n- if (useCache) {\n+ resolve(this.connectionCache[key].conneciton)\n+ }).catch(error => {\n+ reject(error)\n+ })\n+ } else {\nif (changeActive || this.lastActiveConnection == undefined) {\nthis.lastConnectionOption = this.connectionCache[key].connectionOptions\nthis.lastActiveConnection = this.connectionCache[key].conneciton\n- Global.updateStatusBarItems(this.lastConnectionOption);\n+ Global.updateStatusBarItems(connectionOptions);\n}\nresolve(this.connectionCache[key].conneciton)\n- return;\n}\n+ } else {\n+ this.connectionCache[key] = {\n+ connectionOptions: connectionOptions,\n+ conneciton: this.createConnection(connectionOptions)\n+ };\nthis.connectionCache[key].conneciton.connect((err: Error) => {\nif (!err) {\nif (changeActive || this.lastActiveConnection == undefined) {\nthis.lastConnectionOption = connectionOptions\nthis.lastActiveConnection = this.connectionCache[key].conneciton\n- Global.updateStatusBarItems(this.lastConnectionOption);\n+ Global.updateStatusBarItems(connectionOptions);\n}\nresolve(this.lastActiveConnection);\n} else {\n@@ -72,13 +76,15 @@ export class ConnectionManager {\nreject(err.message);\n}\n});\n+ }\n+\n});\n}\npublic static createConnection(connectionOptions: IConnection): any {\n- const newConnectionOptions: any = Object.assign({ useConnectionPooling: true, connectTimeout: Constants.EXPIRE_TIME }, connectionOptions);\n+ const newConnectionOptions: any = Object.assign({ useConnectionPooling: true }, connectionOptions);\nif (connectionOptions.certPath && fs.existsSync(connectionOptions.certPath)) {\nnewConnectionOptions.ssl = {\nca: fs.readFileSync(connectionOptions.certPath),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connection.ts",
"new_path": "src/model/connection.ts",
"diff": "@@ -3,7 +3,7 @@ export interface IConnection {\nreadonly user: string;\npassword?: string;\nreadonly port: string;\n- readonly database?: string;\n+ database?: string;\nmultipleStatements?: boolean;\nreadonly certPath: string;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
fix many connection
|
141,908 |
19.03.2020 10:43:01
| -28,800 |
ee03397518cedc89de64db910f6317a6b81c0871
|
query logic refactor
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -56,18 +56,21 @@ export class QueryUnit {\nsql = sql.replace(/--.+/ig, '');\nlet executeTime = new Date().getTime()\nconnection.query(sql, (err, data) => {\n- let isDDL = sql.match(this.ddlPattern);\n- if (Array.isArray(data) && !isDDL) {\n- SqlViewManager.showQueryResult({ sql, data, splitResultView: true, costTime: new Date().getTime() - executeTime });\n- } else {\n- Console.log(`execute sql success:${sql}`)\n- }\nif (err) {\n//TODO trans output to query page\nConsole.log(err);\n- } else if (isDDL) {\n+ return;\n+ }\n+ if (sql.match(this.ddlPattern)) {\nMySQLTreeDataProvider.instance.init()\n+ return;\n+ }\n+ if (Array.isArray(data)) {\n+ SqlViewManager.showQueryResult({ sql, data, splitResultView: true, costTime: new Date().getTime() - executeTime });\n+ } else {\n+ Console.log(`execute sql success:${sql}`)\n}\n+\n});\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
query logic refactor
|
141,908 |
20.03.2020 06:41:11
| -28,800 |
b3f5e3959462efe9961033b00e7a9f10e2229d17
|
support sql format
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"dependencies\": {\n\"mysql\": \"^2.15.0\",\n- \"mysqldump\": \"^2.2.1\"\n+ \"mysqldump\": \"^2.2.1\",\n+ \"sql-formatter\": \"^2.3.3\"\n},\n\"__metadata\": {\n\"id\": \"38c08d09-caa0-4988-8ffb-bcbd51f86e55\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -19,6 +19,7 @@ import { TriggerGroup } from \"./model/other/triggerGroup\";\nimport { ProcedureGroup } from \"./model/other/procedureGroup\";\nimport { ViewGroup } from \"./model/table/viewGroup\";\nimport { ViewNode } from \"./model/table/viewNode\";\n+import { SqlFormatProvider } from \"./provider/SqlFormatProvider\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -38,6 +39,7 @@ export function activate(context: vscode.ExtensionContext) {\n})\ncontext.subscriptions.push(\n+ vscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormatProvider()),\nvscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.'),\nvscode.commands.registerCommand(\"mysql.refresh\", (node: INode) => {\nsqlTreeProvider.init()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/SqlFormatProvider.ts",
"diff": "+import * as vscode from \"vscode\";\n+import sqlFormatter = require('sql-formatter');\n+\n+export class SqlFormatProvider implements vscode.DocumentRangeFormattingEditProvider {\n+\n+ provideDocumentRangeFormattingEdits(document: vscode.TextDocument, range: vscode.Range, options: vscode.FormattingOptions, token: vscode.CancellationToken): vscode.ProviderResult<vscode.TextEdit[]> {\n+\n+ return [new vscode.TextEdit(range, sqlFormatter.format(document.getText(range)))];\n+ }\n+\n+\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support sql format
|
141,908 |
20.03.2020 09:16:18
| -28,800 |
d6c21aa3b421feb8eb3d5a21d2d425ec633bed8e
|
table name inference
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -21,11 +21,10 @@ export class TableNode implements INode, IConnection {\nconstructor(readonly host: string, readonly user: string, readonly password: string,\nreadonly port: string, readonly database: string, readonly table: string,\nreadonly certPath: string) {\n+ this.identify = `${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`\n}\npublic getTreeItem(): vscode.TreeItem {\n-\n- this.identify = `${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`\nreturn {\nlabel: this.table,\ncollapsibleState: DatabaseCache.getElementState(this),\n@@ -41,8 +40,6 @@ export class TableNode implements INode, IConnection {\n}\npublic async getChildren(isRresh: boolean = false): Promise<INode[]> {\n-\n- this.identify = `${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`\nlet columnNodes = DatabaseCache.getColumnListOfTable(this.identify)\nif (columnNodes && !isRresh) {\nreturn columnNodes;\n"
},
{
"change_type": "DELETE",
"old_path": "src/provider/CompletionManager.ts",
"new_path": null,
"diff": "-import * as vscode from \"vscode\";\n-import { DatabaseCache } from \"../database/DatabaseCache\";\n-import { DatabaseNode } from \"../model/database/databaseNode\";\n-import { ColumnNode } from \"../model/table/columnNode\";\n-import { TableNode } from \"../model/table/tableNode\";\n-import { INode } from \"../model/INode\";\n-import { Util } from \"../common/util\";\n-import { ModelType } from \"../common/Constants\";\n-\n-export class CompletionManager {\n-\n- private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"PROCEDURE\", \"TRIGGER\",\"INDEX\",\"CHANGE\",\"COMMENT\",\"COLUMN\",\"ADD\",'SHOW',\"PRIVILEGES\",\"IDENTIFIED\",\"VIEW\",\"CURSOR\",\"EXPLAIN\"]\n- private keywordComplectionItems: vscode.CompletionItem[] = []\n-\n- getComplectionItems(document: vscode.TextDocument, position: vscode.Position): vscode.CompletionItem[] {\n-\n- let completionItems = []\n-\n- const prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\n- const preChart = document.getText(new vscode.Range(prePostion, position))\n- if (preChart != \".\" && preChart != \" \") {\n- completionItems = completionItems.concat(this.keywordComplectionItems)\n- }\n- if ((position.character == 0)) return completionItems\n-\n- let wordRange = document.getWordRangeAtPosition(prePostion)\n- const inputWord = document.getText(wordRange)\n- if (inputWord && preChart == '.') {\n- let subComplectionItems = this.generateTableComplectionItem(inputWord)\n- if (subComplectionItems.length == 0) {\n- subComplectionItems = this.generateColumnComplectionItem(inputWord)\n- }\n- completionItems = completionItems.concat(subComplectionItems)\n- } else {\n- completionItems = completionItems.concat(this.generateDatabaseComplectionItem(), this.generateTableComplectionItem())\n- }\n-\n- return completionItems\n- }\n- constructor() {\n- this.initKeywordComplectionItem()\n- }\n-\n- private initKeywordComplectionItem() {\n- this.keywordList.forEach(keyword => {\n- let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n- keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n- this.keywordComplectionItems.push(keywordComplectionItem)\n- })\n- }\n-\n- private generateDatabaseComplectionItem(): vscode.CompletionItem[] {\n-\n- let databaseNodes = DatabaseCache.getDatabaseNodeList()\n- return databaseNodes.map<vscode.CompletionItem>(databaseNode => {\n- let completionItem = new vscode.CompletionItem(databaseNode.getTreeItem().label)\n- completionItem.kind = vscode.CompletionItemKind.Struct\n- return completionItem\n- })\n- }\n-\n- private generateTableComplectionItem(inputWord?: string): vscode.CompletionItem[] {\n-\n- let tableNodes: INode[] = []\n- if (inputWord) {\n- DatabaseCache.getDatabaseNodeList().forEach(databaseNode => {\n- if (databaseNode.database == inputWord) tableNodes = DatabaseCache.getTableListOfDatabase(databaseNode.identify)\n- })\n- } else {\n- tableNodes = DatabaseCache.getTableNodeList()\n- }\n-\n- return tableNodes.map<vscode.CompletionItem>((tableNode: TableNode) => {\n- let treeItem = tableNode.getTreeItem();\n- let completionItem = new vscode.CompletionItem(treeItem.label)\n- switch (tableNode.type) {\n- case ModelType.TABLE:\n- completionItem.kind = vscode.CompletionItemKind.Function;\n- break;\n- case ModelType.VIEW:\n- completionItem.kind = vscode.CompletionItemKind.Module;\n- break;\n- case ModelType.PROCEDURE:\n- completionItem.kind = vscode.CompletionItemKind.Reference;\n- break;\n- case ModelType.FUNCTION:\n- completionItem.kind = vscode.CompletionItemKind.Method;\n- break;\n- case ModelType.TRIGGER:\n- completionItem.kind = vscode.CompletionItemKind.Event;\n- break;\n- }\n-\n-\n- return completionItem\n- })\n- }\n-\n- generateColumnComplectionItem(inputWord: string): vscode.CompletionItem[] {\n-\n- if (!inputWord) return []\n- let columnNodes: ColumnNode[] = []\n- DatabaseCache.getTableNodeList().forEach(tableNode => {\n- if (tableNode.table == inputWord) columnNodes = DatabaseCache.getColumnListOfTable(tableNode.identify)\n- })\n-\n- return columnNodes.map<vscode.CompletionItem>(columnNode => {\n- let completionItem = new vscode.CompletionItem(columnNode.getTreeItem().columnName)\n- completionItem.detail = columnNode.getTreeItem().detail\n- completionItem.documentation = columnNode.getTreeItem().document\n- completionItem.kind = vscode.CompletionItemKind.Function\n- return completionItem\n- })\n- }\n-\n-}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "-import * as vscode from 'vscode';\n-import { CompletionManager } from './CompletionManager';\n+import * as vscode from \"vscode\";\n+import { ModelType } from \"../common/Constants\";\n+import { DatabaseCache } from \"../database/DatabaseCache\";\n+import { INode } from \"../model/INode\";\n+import { ColumnNode } from \"../model/table/columnNode\";\n+import { TableNode } from \"../model/table/tableNode\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\n+ constructor() {\n+ this.initKeywordComplectionItem()\n+ }\n+ async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): Promise<vscode.CompletionItem[]> {\n+\n+ let completionItems = []\n- constructor(private complectionManager = new CompletionManager()) { }\n+ const prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\n+ const preChart = document.getText(new vscode.Range(prePostion, position))\n+ if (preChart != \".\" && preChart != \" \") {\n+ completionItems = completionItems.concat(this.keywordComplectionItems)\n+ }\n+ if ((position.character == 0)) return completionItems\n- provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {\n+ let wordRange = document.getWordRangeAtPosition(prePostion)\n+ const inputWord = document.getText(wordRange)\n+ if (inputWord && preChart == '.') {\n+ let subComplectionItems = this.generateTableComplectionItem(inputWord)\n+ if (subComplectionItems.length == 0) {\n+ subComplectionItems = await this.generateColumnComplectionItem(inputWord)\n+ if (subComplectionItems.length == 0) {\n+ let tableReg = new RegExp(\"\\\\w+(?=\\\\s*\\\\b\" + inputWord + \"\\\\b)\", 'ig')\n+ let currentSql = document.getText();\n+ let result = tableReg.exec(currentSql)\n+ for (; result != null && subComplectionItems.length == 0;) {\n+ subComplectionItems = await this.generateColumnComplectionItem(result[0])\n+ result = tableReg.exec(currentSql)\n+ }\n+ }\n+ }\n+ completionItems = completionItems.concat(subComplectionItems)\n+ } else {\n+ completionItems = completionItems.concat(this.generateDatabaseComplectionItem(), this.generateTableComplectionItem())\n+ }\n- return this.complectionManager.getComplectionItems(document, position)\n+ return completionItems\n}\nresolveCompletionItem?(item: vscode.CompletionItem): vscode.ProviderResult<vscode.CompletionItem> {\nreturn item;\n}\n+ private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COMMENT\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n+ private keywordComplectionItems: vscode.CompletionItem[] = []\n+\n+ private initKeywordComplectionItem() {\n+ this.keywordList.forEach(keyword => {\n+ let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n+ keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n+ this.keywordComplectionItems.push(keywordComplectionItem)\n+ })\n+ }\n+\n+ private generateDatabaseComplectionItem(): vscode.CompletionItem[] {\n+\n+ let databaseNodes = DatabaseCache.getDatabaseNodeList()\n+ return databaseNodes.map<vscode.CompletionItem>(databaseNode => {\n+ let completionItem = new vscode.CompletionItem(databaseNode.getTreeItem().label)\n+ completionItem.kind = vscode.CompletionItemKind.Struct\n+ return completionItem\n+ })\n+ }\n+\n+ private generateTableComplectionItem(inputWord?: string): vscode.CompletionItem[] {\n+\n+ let tableNodes: INode[] = []\n+ if (inputWord) {\n+ DatabaseCache.getDatabaseNodeList().forEach(databaseNode => {\n+ if (databaseNode.database == inputWord) tableNodes = DatabaseCache.getTableListOfDatabase(databaseNode.identify)\n+ })\n+ } else {\n+ tableNodes = DatabaseCache.getTableNodeList()\n+ }\n+\n+ return tableNodes.map<vscode.CompletionItem>((tableNode: TableNode) => {\n+ let treeItem = tableNode.getTreeItem();\n+ let completionItem = new vscode.CompletionItem(treeItem.label)\n+ switch (tableNode.type) {\n+ case ModelType.TABLE:\n+ completionItem.kind = vscode.CompletionItemKind.Function;\n+ break;\n+ case ModelType.VIEW:\n+ completionItem.kind = vscode.CompletionItemKind.Module;\n+ break;\n+ case ModelType.PROCEDURE:\n+ completionItem.kind = vscode.CompletionItemKind.Reference;\n+ break;\n+ case ModelType.FUNCTION:\n+ completionItem.kind = vscode.CompletionItemKind.Method;\n+ break;\n+ case ModelType.TRIGGER:\n+ completionItem.kind = vscode.CompletionItemKind.Event;\n+ break;\n+ }\n+\n+ return completionItem\n+ })\n+ }\n+\n+ async generateColumnComplectionItem(inputWord: string): Promise<vscode.CompletionItem[]> {\n+\n+ if (!inputWord) return []\n+ let columnNodes: ColumnNode[] = []\n+\n+ for (const tableNode of DatabaseCache.getTableNodeList()) {\n+ if (tableNode.table == inputWord) {\n+ columnNodes = (await tableNode.getChildren()) as ColumnNode[]\n+ break;\n+ }\n+ }\n+\n+ return columnNodes.map<vscode.CompletionItem>(columnNode => {\n+ let completionItem = new vscode.CompletionItem(columnNode.getTreeItem().columnName)\n+ completionItem.detail = columnNode.getTreeItem().detail\n+ completionItem.documentation = columnNode.getTreeItem().document\n+ completionItem.kind = vscode.CompletionItemKind.Function\n+ return completionItem\n+ })\n+ }\n+\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
table name inference
|
141,908 |
20.03.2020 17:06:46
| -28,800 |
30ced547d3f9b2c4ee708af3bc327c175bf029a5
|
support record history
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "+## 1.6.37\n+- Table name inference\n+- Sql formatter\n+- Record History\n+\n## 1.6.36 (2020/3/19)\n- Fix many mysql connection error.\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "]\n},\n\"commands\": [\n+ {\n+ \"command\": \"mysql.hisotry.open\",\n+ \"title\": \"Open History\",\n+ \"category\": \"MySQL\",\n+ \"icon\": \"resources/history.svg\"\n+ },\n{\n\"command\": \"mysql.refresh\",\n\"title\": \"Refresh\",\n{\n\"command\": \"mysql.refresh\",\n\"when\": \"view == github.cweijan.mysql\",\n+ \"group\": \"navigation@1\"\n+ },\n+ {\n+ \"command\": \"mysql.hisotry.open\",\n+ \"when\": \"view == github.cweijan.mysql\",\n\"group\": \"navigation@0\"\n}\n],\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/history.svg",
"diff": "+<svg id=\"Outline\" enable-background=\"new 0 0 512 512\" height=\"512\" viewBox=\"0 0 512 512\" width=\"512\" xmlns=\"http://www.w3.org/2000/svg\"><g><path d=\"m32 456c.025 22.081 17.919 39.975 40 40h296c61.851.006 111.996-50.129 112.002-111.98.004-43.264-24.912-82.66-64.002-101.199v-162.821c0-2.122-.843-4.157-2.343-5.657l-96-96c-1.5-1.5-3.535-2.343-5.657-2.343h-240c-22.081.025-39.975 17.919-40 40zm432-72c0 53.019-42.981 96-96 96s-96-42.981-96-96 42.981-96 96-96c52.995.06 95.94 43.005 96 96zm-144-340.687 68.687 68.687h-44.687c-13.249-.015-23.985-10.751-24-24zm-272 12.687c.015-13.248 10.752-23.985 24-24h232v56c.025 22.081 17.919 39.975 40 40h56v148.666c-59.265-17.683-121.643 16.025-139.327 75.289-14.627 49.023 5.828 101.725 49.696 128.045h-238.369c-13.248-.015-23.985-10.752-24-24z\"/><path d=\"m160 168c0 4.418 3.582 8 8 8h192c4.418 0 8-3.582 8-8s-3.582-8-8-8h-192c-4.418 0-8 3.582-8 8z\"/><path d=\"m88 224h160c4.418 0 8-3.582 8-8s-3.582-8-8-8h-160c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m280 256h-64c-4.418 0-8 3.582-8 8s3.582 8 8 8h64c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m88 320h144c4.418 0 8-3.582 8-8s-3.582-8-8-8h-144c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m88 176h48c4.418 0 8-3.582 8-8s-3.582-8-8-8h-48c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m360 208h-80c-4.418 0-8 3.582-8 8s3.582 8 8 8h80c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m88 272h96c4.418 0 8-3.582 8-8s-3.582-8-8-8h-96c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m216 400h-32c-4.418 0-8 3.582-8 8s3.582 8 8 8h32c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m88 416h64c4.418 0 8-3.582 8-8s-3.582-8-8-8h-64c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m88 368h48c4.418 0 8-3.582 8-8s-3.582-8-8-8h-48c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m88 128h96c4.418 0 8-3.582 8-8s-3.582-8-8-8h-96c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m216 352h-48c-4.418 0-8 3.582-8 8s3.582 8 8 8h48c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m322.879 329.854c-3.395 2.828-3.854 7.873-1.026 11.267 0 0 0 .001.001.001 0 0 30.333 36.449 39.97 47.964.971 1.161 2.556 2.512 5.331 2.87.28.036.563.044.845.044h56c4.418 0 8-3.582 8-8s-3.582-8-8-8h-52.253l-37.6-45.122c-2.828-3.394-7.873-3.853-11.268-1.024z\"/></g></svg>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -11,6 +11,10 @@ export class CacheKey{\n}\n+export class CommandKey{\n+ static RecordHistory=\"mysql.hisotry.record\"\n+ static Refresh=\"mysql.refresh\"\n+}\nexport class Cursor{\nstatic FIRST_POSITION=new vscode.Position(0, 0);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/ConnectionManager.ts",
"new_path": "src/database/ConnectionManager.ts",
"diff": "import * as fs from \"fs\";\nimport * as mysql from \"mysql\";\nimport { IConnection } from \"../model/Connection\";\n-import { Constants } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\nimport { Global } from \"../common/Global\";\nimport { QueryUnit } from \"./QueryUnit\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "\"use strict\";\nimport * as vscode from \"vscode\";\n-import { Cursor } from \"../common/Constants\";\n+import { Cursor, CommandKey } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\nimport { Util } from \"../common/util\";\nimport { IConnection } from \"../model/Connection\";\n-import { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\nimport { ConnectionManager } from \"./ConnectionManager\";\nimport { SqlViewManager } from \"./SqlViewManager\";\n@@ -44,7 +43,9 @@ export class QueryUnit {\nconnection = await ConnectionManager.getConnection(connectionOptions)\n}\n+ let fromEditor = false;\nif (!sql) {\n+ fromEditor = true;\nconst activeTextEditor = vscode.window.activeTextEditor;\nconst selection = activeTextEditor.selection;\nif (selection.isEmpty) {\n@@ -61,8 +62,10 @@ export class QueryUnit {\nConsole.log(err);\nreturn;\n}\n+ if (fromEditor)\n+ vscode.commands.executeCommand(CommandKey.RecordHistory, sql)\nif (sql.match(this.ddlPattern)) {\n- MySQLTreeDataProvider.instance.init()\n+ vscode.commands.executeCommand(CommandKey.Refresh)\nreturn;\n}\nif (Array.isArray(data)) {\n@@ -70,7 +73,6 @@ export class QueryUnit {\n} else {\nConsole.log(`execute sql success:${sql}`)\n}\n-\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -3,7 +3,6 @@ import * as vscode from \"vscode\";\nimport { QueryUnit } from \"./database/QueryUnit\";\nimport { ConnectionNode } from \"./model/ConnectionNode\";\nimport { DatabaseNode } from \"./model/database/databaseNode\";\n-import { INode } from \"./model/INode\";\nimport { TableNode } from \"./model/table/tableNode\";\nimport { MySQLTreeDataProvider } from \"./provider/MysqlTreeDataProvider\";\nimport { CompletionProvider } from \"./provider/CompletionProvider\";\n@@ -20,16 +19,19 @@ import { ProcedureGroup } from \"./model/other/procedureGroup\";\nimport { ViewGroup } from \"./model/table/viewGroup\";\nimport { ViewNode } from \"./model/table/viewNode\";\nimport { SqlFormatProvider } from \"./provider/SqlFormatProvider\";\n+import { HistoryManager } from \"./extension/HistoryManager\";\n+import { CommandKey } from \"./common/Constants\";\nexport function activate(context: vscode.ExtensionContext) {\n- DatabaseCache.initCache(context)\n+ DatabaseCache.initCache(context)\nSqlViewManager.initExtesnsionPath(context.extensionPath)\n+ var historyManager = new HistoryManager(context)\n- const sqlTreeProvider = new MySQLTreeDataProvider(context);\n+ var mysqlTreeDataProvider=new MySQLTreeDataProvider(context);\nconst treeview = vscode.window.createTreeView(\"github.cweijan.mysql\", {\n- treeDataProvider: sqlTreeProvider\n+ treeDataProvider: mysqlTreeDataProvider\n})\ntreeview.onDidCollapseElement(event => {\nDatabaseCache.storeElementState(event.element, vscode.TreeItemCollapsibleState.Collapsed)\n@@ -41,8 +43,14 @@ export function activate(context: vscode.ExtensionContext) {\ncontext.subscriptions.push(\nvscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormatProvider()),\nvscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.'),\n- vscode.commands.registerCommand(\"mysql.refresh\", (node: INode) => {\n- sqlTreeProvider.init()\n+ vscode.commands.registerCommand(CommandKey.Refresh, () => {\n+ mysqlTreeDataProvider.init()\n+ }),\n+ vscode.commands.registerCommand(\"mysql.hisotry.open\", () => {\n+ historyManager.showHistory()\n+ }),\n+ vscode.commands.registerCommand(CommandKey.RecordHistory, (sql: string) => {\n+ historyManager.recordHistory(sql)\n}),\nvscode.commands.registerCommand(\"mysql.addDatabase\", (connectionNode: ConnectionNode) => {\nconnectionNode.createDatabase()\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/extension/HistoryManager.ts",
"diff": "+import * as fs from \"fs\";\n+import * as vscode from \"vscode\";\n+import { Console } from \"../common/OutputChannel\";\n+import { QueryUnit } from \"../database/QueryUnit\";\n+export class HistoryManager {\n+\n+ constructor(private context: vscode.ExtensionContext) {\n+ }\n+\n+ showHistory() {\n+ var historyPath = this.context.globalStoragePath + '/history.sql'\n+ if (fs.existsSync(historyPath)) {\n+ QueryUnit.showSQLTextDocument(fs.readFileSync(historyPath, { encoding: 'utf8' }))\n+ } else {\n+ Console.log(\"history is empty.\")\n+ }\n+ }\n+\n+ recordHistory(sql: string) {\n+ if (!sql) return;\n+ return new Promise(() => {\n+ var gsPath = this.context.globalStoragePath\n+ if (!fs.existsSync(gsPath)) {\n+ fs.mkdirSync(gsPath)\n+ }\n+ fs.appendFileSync(gsPath + '/history.sql', `/*${this.getNowDate()}*/ ${sql}\\n`, { encoding: 'utf8' });\n+\n+ })\n+ }\n+\n+ private getNowDate(): string {\n+ const date = new Date();\n+ let month: string | number = date.getMonth() + 1;\n+ let strDate: string | number = date.getDate();\n+\n+ if (month <= 9) {\n+ month = \"0\" + month;\n+ }\n+\n+ if (strDate <= 9) {\n+ strDate = \"0\" + strDate;\n+ }\n+\n+ return date.getFullYear() + \"-\" + month + \"-\" + strDate + \" \"\n+ + date.getHours() + \":\" + date.getMinutes() + \":\" + date.getSeconds();\n+ }\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/mysqlTreeDataProvider.ts",
"new_path": "src/provider/mysqlTreeDataProvider.ts",
"diff": "@@ -3,7 +3,6 @@ import { CacheKey } from \"../common/Constants\";\nimport { IConnection } from \"../model/Connection\";\nimport { ConnectionNode } from \"../model/ConnectionNode\";\nimport { INode } from \"../model/INode\";\n-import { ConnectionManager } from \"../database/ConnectionManager\";\nimport { DatabaseCache } from \"../database/DatabaseCache\";\nexport class MySQLTreeDataProvider implements vscode.TreeDataProvider<INode> {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support record history
|
141,908 |
20.03.2020 17:17:26
| -28,800 |
2f66f3361c13a16a25838015a3a5930bd184c624
|
history record costTime
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -43,6 +43,5 @@ MySQL management tool Plus\n* `vscode-mysql.maxTableCount`: The maximum table count shown in the tree view. (Default is **500**) -->\n## Future Plain\n-- Record sql execute history.\n-- Ssl connect\n-- bookmark\n\\ No newline at end of file\n+- Ssl connect.\n+- Bookmark sql.\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/history.svg",
"new_path": "resources/history.svg",
"diff": "-<svg id=\"Outline\" enable-background=\"new 0 0 512 512\" height=\"512\" viewBox=\"0 0 512 512\" width=\"512\" xmlns=\"http://www.w3.org/2000/svg\"><g><path d=\"m32 456c.025 22.081 17.919 39.975 40 40h296c61.851.006 111.996-50.129 112.002-111.98.004-43.264-24.912-82.66-64.002-101.199v-162.821c0-2.122-.843-4.157-2.343-5.657l-96-96c-1.5-1.5-3.535-2.343-5.657-2.343h-240c-22.081.025-39.975 17.919-40 40zm432-72c0 53.019-42.981 96-96 96s-96-42.981-96-96 42.981-96 96-96c52.995.06 95.94 43.005 96 96zm-144-340.687 68.687 68.687h-44.687c-13.249-.015-23.985-10.751-24-24zm-272 12.687c.015-13.248 10.752-23.985 24-24h232v56c.025 22.081 17.919 39.975 40 40h56v148.666c-59.265-17.683-121.643 16.025-139.327 75.289-14.627 49.023 5.828 101.725 49.696 128.045h-238.369c-13.248-.015-23.985-10.752-24-24z\"/><path d=\"m160 168c0 4.418 3.582 8 8 8h192c4.418 0 8-3.582 8-8s-3.582-8-8-8h-192c-4.418 0-8 3.582-8 8z\"/><path d=\"m88 224h160c4.418 0 8-3.582 8-8s-3.582-8-8-8h-160c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m280 256h-64c-4.418 0-8 3.582-8 8s3.582 8 8 8h64c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m88 320h144c4.418 0 8-3.582 8-8s-3.582-8-8-8h-144c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m88 176h48c4.418 0 8-3.582 8-8s-3.582-8-8-8h-48c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m360 208h-80c-4.418 0-8 3.582-8 8s3.582 8 8 8h80c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m88 272h96c4.418 0 8-3.582 8-8s-3.582-8-8-8h-96c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m216 400h-32c-4.418 0-8 3.582-8 8s3.582 8 8 8h32c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m88 416h64c4.418 0 8-3.582 8-8s-3.582-8-8-8h-64c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m88 368h48c4.418 0 8-3.582 8-8s-3.582-8-8-8h-48c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m88 128h96c4.418 0 8-3.582 8-8s-3.582-8-8-8h-96c-4.418 0-8 3.582-8 8s3.582 8 8 8z\"/><path d=\"m216 352h-48c-4.418 0-8 3.582-8 8s3.582 8 8 8h48c4.418 0 8-3.582 8-8s-3.582-8-8-8z\"/><path d=\"m322.879 329.854c-3.395 2.828-3.854 7.873-1.026 11.267 0 0 0 .001.001.001 0 0 30.333 36.449 39.97 47.964.971 1.161 2.556 2.512 5.331 2.87.28.036.563.044.845.044h56c4.418 0 8-3.582 8-8s-3.582-8-8-8h-52.253l-37.6-45.122c-2.828-3.394-7.873-3.853-11.268-1.024z\"/></g></svg>\n\\ No newline at end of file\n+<svg id=\"Flat\" height=\"512\" viewBox=\"0 0 512 512\" width=\"512\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"m376 488h-304a32 32 0 0 1 -32-32v-400a32 32 0 0 1 32-32h240l96 96v336a32 32 0 0 1 -32 32z\" fill=\"#e9eef2\"/><g fill=\"#c3c6c7\"><path d=\"m408 120h-64a32 32 0 0 1 -32-32v-64z\"/><path d=\"m360 176h-192a8 8 0 0 1 0-16h192a8 8 0 0 1 0 16z\"/><path d=\"m248 224h-160a8 8 0 0 1 0-16h160a8 8 0 0 1 0 16z\"/><path d=\"m280 272h-64a8 8 0 0 1 0-16h64a8 8 0 0 1 0 16z\"/><path d=\"m232 320h-144a8 8 0 0 1 0-16h144a8 8 0 0 1 0 16z\"/><path d=\"m136 176h-48a8 8 0 0 1 0-16h48a8 8 0 0 1 0 16z\"/><path d=\"m360 224h-80a8 8 0 0 1 0-16h80a8 8 0 0 1 0 16z\"/><path d=\"m184 272h-96a8 8 0 0 1 0-16h96a8 8 0 0 1 0 16z\"/><path d=\"m216 416h-32a8 8 0 0 1 0-16h32a8 8 0 0 1 0 16z\"/><path d=\"m152 416h-64a8 8 0 0 1 0-16h64a8 8 0 0 1 0 16z\"/><path d=\"m136 368h-48a8 8 0 0 1 0-16h48a8 8 0 0 1 0 16z\"/><path d=\"m184 128h-96a8 8 0 0 1 0-16h96a8 8 0 0 1 0 16z\"/><path d=\"m216 368h-48a8 8 0 0 1 0-16h48a8 8 0 0 1 0 16z\"/></g><circle cx=\"368\" cy=\"384\" fill=\"#f79539\" r=\"104\"/><path d=\"m424 376h-52.253l-37.6-45.122a8 8 0 0 0 -12.292 10.244l40 48a7.985 7.985 0 0 0 6.145 2.878h56a8 8 0 0 0 0-16z\" fill=\"#e9eef2\"/></svg>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -62,14 +62,15 @@ export class QueryUnit {\nConsole.log(err);\nreturn;\n}\n+ var costTime=new Date().getTime() - executeTime\nif (fromEditor)\n- vscode.commands.executeCommand(CommandKey.RecordHistory, sql)\n+ vscode.commands.executeCommand(CommandKey.RecordHistory, sql,costTime)\nif (sql.match(this.ddlPattern)) {\nvscode.commands.executeCommand(CommandKey.Refresh)\nreturn;\n}\nif (Array.isArray(data)) {\n- SqlViewManager.showQueryResult({ sql, data, splitResultView: true, costTime: new Date().getTime() - executeTime });\n+ SqlViewManager.showQueryResult({ sql, data, splitResultView: true, costTime: costTime });\n} else {\nConsole.log(`execute sql success:${sql}`)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -49,8 +49,8 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.hisotry.open\", () => {\nhistoryManager.showHistory()\n}),\n- vscode.commands.registerCommand(CommandKey.RecordHistory, (sql: string) => {\n- historyManager.recordHistory(sql)\n+ vscode.commands.registerCommand(CommandKey.RecordHistory, (sql: string,costTime:number) => {\n+ historyManager.recordHistory(sql,costTime)\n}),\nvscode.commands.registerCommand(\"mysql.addDatabase\", (connectionNode: ConnectionNode) => {\nconnectionNode.createDatabase()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension/HistoryManager.ts",
"new_path": "src/extension/HistoryManager.ts",
"diff": "@@ -16,14 +16,14 @@ export class HistoryManager {\n}\n}\n- recordHistory(sql: string) {\n+ recordHistory(sql: string, costTime: number) {\nif (!sql) return;\nreturn new Promise(() => {\nvar gsPath = this.context.globalStoragePath\nif (!fs.existsSync(gsPath)) {\nfs.mkdirSync(gsPath)\n}\n- fs.appendFileSync(gsPath + '/history.sql', `/*${this.getNowDate()}*/ ${sql}\\n`, { encoding: 'utf8' });\n+ fs.appendFileSync(gsPath + '/history.sql', `/*${this.getNowDate()} [${costTime} ms] */ ${sql}\\n`, { encoding: 'utf8' });\n})\n}\n@@ -42,6 +42,13 @@ export class HistoryManager {\n}\nreturn date.getFullYear() + \"-\" + month + \"-\" + strDate + \" \"\n- + date.getHours() + \":\" + date.getMinutes() + \":\" + date.getSeconds();\n+ + this.pad(date.getHours(), 2) + \":\" + this.pad(date.getMinutes(),2) + \":\" + this.pad(date.getSeconds(),2);\n}\n+\n+ pad(n: any, width: number, z?: any): number {\n+ z = z || '0';\n+ n = n + '';\n+ return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;\n+ }\n+\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
history record costTime
|
141,908 |
20.03.2020 20:28:25
| -28,800 |
79db827afc37896f6d9f09bff8fcb92118e934cd
|
support import sql file
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n{\n\"command\": \"mysql.deleteDatabase\",\n- \"title\": \"Delete Database\",\n+ \"title\": \"Drop Database\",\n\"category\": \"MySQL\"\n},\n{\n\"title\": \"Delete SQL Template\",\n\"category\": \"MySQL\"\n},\n+ {\n+ \"command\": \"mysql.data.import\",\n+ \"title\": \"Import Data\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.data.export\",\n\"title\": \"Export Data\",\n\"when\": \"view == github.cweijan.mysql && viewItem == connection\",\n\"group\": \"2_mysql@1\"\n},\n+ {\n+ \"command\": \"mysql.data.import\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == connection\",\n+ \"group\": \"3_mysql@1\"\n+ },\n{\n\"command\": \"mysql.deleteConnection\",\n\"when\": \"view == github.cweijan.mysql && viewItem == connection\",\n\"when\": \"view == github.cweijan.mysql && viewItem == database\",\n\"group\": \"mysql@5\"\n},\n+ {\n+ \"command\": \"mysql.data.import\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == database\",\n+ \"group\": \"mysql@6\"\n+ },\n{\n\"command\": \"mysql.template.sql\",\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n\"vscode\": \"^1.1.33\"\n},\n\"dependencies\": {\n+ \"execsql\": \"0.0.3\",\n\"mysql\": \"^2.15.0\",\n\"mysqldump\": \"^2.2.1\",\n\"sql-formatter\": \"^2.3.3\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "\"use strict\";\nimport * as vscode from \"vscode\";\n+import * as fs from \"fs\";\nimport { Cursor, CommandKey } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\nimport { Util } from \"../common/util\";\n@@ -8,6 +9,7 @@ import { ConnectionManager } from \"./ConnectionManager\";\nimport { SqlViewManager } from \"./SqlViewManager\";\nexport class QueryUnit {\n+\npublic static readonly maxTableCount = QueryUnit.getConfiguration().get<number>(\"maxTableCount\");\npublic static getConfiguration(): vscode.WorkspaceConfiguration {\n@@ -117,4 +119,41 @@ export class QueryUnit {\nreturn this.sqlDocument;\n}\n+ static runFile(connection: any, fsPath: string) {\n+ var stats = fs.statSync(fsPath)\n+ var startTime = new Date()\n+ var fileSize = stats[\"size\"]\n+ let success = true;\n+ if (fileSize > 1024 * 1024 * 100) {\n+ success = this.executeByLine(connection, fsPath)\n+ } else {\n+ var fileContent = fs.readFileSync(fsPath, 'utf8')\n+ connection.query(fileContent, (err, data) => {\n+ if (err) {\n+ Console.log(err)\n+ success = false;\n+ }\n+ })\n+ }\n+ if (success)\n+ Console.log(`import success, cost time : ${new Date().getTime() - startTime.getTime()}ms`)\n+\n}\n+\n+ private static executeByLine(connection: any, fsPath: string) {\n+ var readline = require('readline');\n+ var rl = readline.createInterface({\n+ input: fs.createReadStream(fsPath.replace(\"\\\\\", \"/\")),\n+ terminal: false\n+ });\n+ rl.on('line', (chunk) => {\n+ let sql = chunk.toString('utf8');\n+ connection.query(sql, (err, sets, fields) => {\n+ if (err) Console.log(`execute sql ${sql} fail,${err}`)\n+ });\n+ });\n+ return true;\n+ }\n+\n+}\n+\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -97,6 +97,11 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.template.sql\", (tableNode: TableNode, run: Boolean) => {\ntableNode.selectSqlTemplate(run);\n}),\n+ vscode.commands.registerCommand(\"mysql.data.import\", (iNode: DatabaseNode|ConnectionNode) => {\n+ vscode.window.showOpenDialog({filters:{ 'Sql': ['sql'] }, canSelectMany: false, openLabel: \"Select sql file to import\", canSelectFiles: true, canSelectFolders: false }).then(filePath => {\n+ iNode.importData(filePath[0].fsPath)\n+ })\n+ }),\nvscode.commands.registerCommand(\"mysql.data.export\", (iNode: TableNode | DatabaseNode) => {\nvscode.window.showOpenDialog({ canSelectMany: false, openLabel: \"Select export file path\", canSelectFiles: false, canSelectFolders: true }).then(folderPath => {\niNode.backupData(folderPath[0].fsPath)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension/HistoryManager.ts",
"new_path": "src/extension/HistoryManager.ts",
"diff": "import * as fs from \"fs\";\nimport * as vscode from \"vscode\";\n-import { Console } from \"../common/OutputChannel\";\n-import { QueryUnit } from \"../database/QueryUnit\";\nexport class HistoryManager {\nconstructor(private context: vscode.ExtensionContext) {\n@@ -9,11 +7,10 @@ export class HistoryManager {\nshowHistory() {\nvar historyPath = this.context.globalStoragePath + '/history.sql'\n- if (fs.existsSync(historyPath)) {\n- QueryUnit.showSQLTextDocument(fs.readFileSync(historyPath, { encoding: 'utf8' }))\n- } else {\n- Console.log(\"history is empty.\")\n- }\n+ var openPath = vscode.Uri.file(historyPath);\n+ vscode.workspace.openTextDocument(openPath).then(doc => {\n+ vscode.window.showTextDocument(doc);\n+ });\n}\nrecordHistory(sql: string, costTime: number) {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/connectionNode.ts",
"new_path": "src/model/connectionNode.ts",
"diff": "import * as path from \"path\";\nimport * as vscode from \"vscode\";\nimport { CacheKey, Constants, ModelType } from \"../common/Constants\";\n+import { Console } from \"../common/OutputChannel\";\nimport { ConnectionManager } from \"../database/ConnectionManager\";\nimport { DatabaseCache } from \"../database/DatabaseCache\";\nimport { QueryUnit } from \"../database/QueryUnit\";\n@@ -11,6 +12,7 @@ import { UserGroup } from \"./database/userGroup\";\nimport { InfoNode } from \"./InfoNode\";\nimport { INode } from \"./INode\";\n+\nexport class ConnectionNode implements INode, IConnection {\nidentify: string;\n@@ -77,4 +79,12 @@ export class ConnectionNode implements INode, IConnection {\nMySQLTreeDataProvider.refresh();\n}\n+\n+ importData(fsPath: string) {\n+ Console.log(`Doing import ${this.host}:${this.port}...`)\n+ ConnectionManager.getConnection(this).then(connection => {\n+ QueryUnit.runFile(connection,fsPath)\n+ })\n+ }\n+\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/database/databaseNode.ts",
"new_path": "src/model/database/databaseNode.ts",
"diff": "import mysqldump from 'mysqldump';\nimport * as path from \"path\";\n+\nimport * as vscode from \"vscode\";\nimport { Constants, ModelType } from \"../../common/Constants\";\nimport { Console } from \"../../common/OutputChannel\";\n@@ -45,6 +46,12 @@ export class DatabaseNode implements INode, IConnection {\nnew TriggerGroup(this.host, this.user, this.password, this.port, this.database, this.certPath)]\n}\n+ importData(fsPath: string) {\n+ Console.log(`Doing import ${this.host}:${this.port}_${this.database}...`)\n+ ConnectionManager.getConnection(this).then(connection => {\n+ QueryUnit.runFile(connection,fsPath)\n+ })\n+ }\npublic backupData(exportPath: string) {\n"
},
{
"change_type": "MODIFY",
"old_path": "tslint.json",
"new_path": "tslint.json",
"diff": "{\n\"extends\": \"tslint:recommended\",\n+ \"linterOptions\": {\n+ \"exclude\": [\n+ \"node_modules/**\"\n+ ]\n+ },\n\"rules\": {\n\"variable-name\": [\ntrue,\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support import sql file
|
141,908 |
20.03.2020 21:12:59
| -28,800 |
28a0183c6791199bd1203245119a15f7db9d311e
|
Stability optimization
|
[
{
"change_type": "MODIFY",
"old_path": "CHANGELOG.md",
"new_path": "CHANGELOG.md",
"diff": "- Table name inference\n- Sql formatter\n- Record History\n+- Import sql file\n## 1.6.36 (2020/3/19)\n- Fix many mysql connection error.\n"
},
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -45,3 +45,4 @@ MySQL management tool Plus\n## Future Plain\n- Ssl connect.\n- Bookmark sql.\n+- Hover Info.\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -3,6 +3,7 @@ import * as path from \"path\";\nexport class Constants {\npublic static RES_PATH=path.join(vscode.extensions.getExtension('cweijan.vscode-mysql-manager').extensionPath,\"resources\");\n+ public static DEFAULT_SIZE=200;\n}\nexport class CacheKey{\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -80,7 +80,7 @@ export class QueryUnit {\n}\n- private static batchPattern = /(TRIGGER|PROCEDURE|FUNCTION)/ig\n+ private static batchPattern = /\\s+(TRIGGER|PROCEDURE|FUNCTION)\\s+/ig\nprivate static obtainSql(activeTextEditor: vscode.TextEditor): string {\nvar content = activeTextEditor.document.getText()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -115,7 +115,7 @@ export class TableNode implements INode, IConnection {\npublic async selectSqlTemplate(run: Boolean) {\n- const sql = `SELECT * FROM ${this.database}.${this.table} LIMIT 1000;`;\n+ const sql = `SELECT * FROM ${this.database}.${this.table} LIMIT ${Constants.DEFAULT_SIZE};`;\nif (run) {\nConnectionManager.getConnection(this, true)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -8,7 +8,7 @@ import { TableNode } from \"../model/table/tableNode\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\nconstructor() {\n- this.initKeywordComplectionItem()\n+ this.initDefaultComplectionItem()\n}\nasync provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): Promise<vscode.CompletionItem[]> {\n@@ -17,7 +17,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nconst prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\nconst preChart = document.getText(new vscode.Range(prePostion, position))\nif (preChart != \".\" && preChart != \" \") {\n- completionItems = completionItems.concat(this.keywordComplectionItems)\n+ completionItems = completionItems.concat(this.defaultComplectionItems)\n}\nif ((position.character == 0)) return completionItems\n@@ -49,14 +49,22 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nreturn item;\n}\n- private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COMMENT\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n- private keywordComplectionItems: vscode.CompletionItem[] = []\n+ private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\",\"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COMMENT\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n+ private functionList: string[] = [\"CHAR_LENGTH\",\"CONCAT\",\"NOW\",\"DATE_ADD\",\"DATE_SUB\",\"MAX\",\"COUNT\",\"MIN\",\"SUM\",\"AVG\",\"LENGTH\",\"IF\",\"IFNULL\",\"MD5\",\"SHA\",\"CURRENT_TIME\",\"CURRENT_DATE\",\"DATE_FORMAT\",\"CAST\"]\n+ private defaultComplectionItems: vscode.CompletionItem[] = []\n- private initKeywordComplectionItem() {\n+ private initDefaultComplectionItem() {\nthis.keywordList.forEach(keyword => {\nlet keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\nkeywordComplectionItem.kind = vscode.CompletionItemKind.Property\n- this.keywordComplectionItems.push(keywordComplectionItem)\n+ this.defaultComplectionItems.push(keywordComplectionItem)\n+ })\n+ this.functionList.forEach(keyword => {\n+ let functionComplectionItem = new vscode.CompletionItem(keyword + \" \")\n+ functionComplectionItem.kind = vscode.CompletionItemKind.Function\n+ functionComplectionItem.insertText = new vscode.SnippetString(keyword + \"($1)\")\n+ this.defaultComplectionItems.push(functionComplectionItem)\n+\n})\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "syntaxes/mysql.tmLanguage.json",
"new_path": "syntaxes/mysql.tmLanguage.json",
"diff": "\"match\": \"(?i)\\\\b(TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED|PRIVILEGES|FLUSH|SHOW|INDEX|CHANGE|COMMENT|COLUMN|ADD|UNIQUE|EXPLAIN)\\\\b\",\n\"name\": \"keyword.mysql\"\n},\n+ {\n+ \"match\": \"(?i)\\\\b(DATE_ADD|DATE_SUB|CURRENT_DATE|DATE_FORMAT|CAST|CHAR_LENGTH|avg|checksum_agg|count|count_big|grouping|grouping_id|max|min|sum|stdev|stdevp|var|varp)\\\\b\",\n+ \"name\": \"support.function.aggregate.sql\"\n+ },\n{\n\"match\": \"((?<!@)@)\\\\b(\\\\w+)\\\\b\",\n\"name\": \"text.variable\"\n\"match\": \"\\\\|\\\\|\",\n\"name\": \"keyword.operator.concatenator.sql\"\n},\n- {\n- \"match\": \"(?i)\\\\b(avg|checksum_agg|count|count_big|grouping|grouping_id|max|min|sum|stdev|stdevp|var|varp)\\\\b\",\n- \"name\": \"support.function.aggregate.sql\"\n- },\n{\n\"match\": \"(?i)\\\\b(cast|convert|parse|try_cast|try_convert|try_parse)\\\\b\",\n\"name\": \"support.function.conversion.sql\"\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
Stability optimization
|
141,908 |
20.03.2020 22:16:33
| -28,800 |
c7fa5374af9f352ea428d47d47a9cfff5c0335fd
|
support hover table get info
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "@@ -45,4 +45,3 @@ MySQL management tool Plus\n## Future Plain\n- Ssl connect.\n- Bookmark sql.\n\\ No newline at end of file\n-- Hover Info.\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"vscode\": \"^1.1.33\"\n},\n\"dependencies\": {\n- \"execsql\": \"0.0.3\",\n\"mysql\": \"^2.15.0\",\n\"mysqldump\": \"^2.2.1\",\n\"sql-formatter\": \"^2.3.3\"\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -21,6 +21,7 @@ import { ViewNode } from \"./model/table/viewNode\";\nimport { SqlFormatProvider } from \"./provider/SqlFormatProvider\";\nimport { HistoryManager } from \"./extension/HistoryManager\";\nimport { CommandKey } from \"./common/Constants\";\n+import { TableHoverProvider } from \"./provider/TableHoverProvider\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -42,6 +43,7 @@ export function activate(context: vscode.ExtensionContext) {\ncontext.subscriptions.push(\nvscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormatProvider()),\n+ vscode.languages.registerHoverProvider('sql',new TableHoverProvider()),\nvscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.'),\nvscode.commands.registerCommand(CommandKey.Refresh, () => {\nmysqlTreeDataProvider.init()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/columnNode.ts",
"new_path": "src/model/table/columnNode.ts",
"diff": "@@ -19,7 +19,7 @@ export class ColumnNode implements INode, IConnection {\ntype: string = ModelType.COLUMN;\nconstructor(readonly host: string, readonly user: string, readonly password: string,\nreadonly port: string, readonly database: string, private readonly table: string,\n- readonly certPath: string, private readonly column: any) {\n+ readonly certPath: string, public readonly column: any) {\n}\nprivate getIndex(columnKey:string){\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -26,13 +26,13 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nif (inputWord && preChart == '.') {\nlet subComplectionItems = this.generateTableComplectionItem(inputWord)\nif (subComplectionItems.length == 0) {\n- subComplectionItems = await this.generateColumnComplectionItem(inputWord)\n+ subComplectionItems = await CompletionProvider.generateColumnComplectionItem(inputWord)\nif (subComplectionItems.length == 0) {\nlet tableReg = new RegExp(\"\\\\w+(?=\\\\s*\\\\b\" + inputWord + \"\\\\b)\", 'ig')\nlet currentSql = document.getText();\nlet result = tableReg.exec(currentSql)\nfor (; result != null && subComplectionItems.length == 0;) {\n- subComplectionItems = await this.generateColumnComplectionItem(result[0])\n+ subComplectionItems = await CompletionProvider.generateColumnComplectionItem(result[0])\nresult = tableReg.exec(currentSql)\n}\n}\n@@ -114,7 +114,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\n})\n}\n- async generateColumnComplectionItem(inputWord: string): Promise<vscode.CompletionItem[]> {\n+ static async generateColumnComplectionItem(inputWord: string): Promise<vscode.CompletionItem[]> {\nif (!inputWord) return []\nlet columnNodes: ColumnNode[] = []\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/TableHoverProvider.ts",
"diff": "+import * as vscode from 'vscode';\n+import { HoverProvider } from \"vscode\";\n+import { DatabaseCache } from \"../database/DatabaseCache\";\n+import { ColumnNode } from \"../model/table/columnNode\";\n+\n+\n+export class TableHoverProvider implements HoverProvider {\n+\n+ async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Hover> {\n+\n+ const tableName = document.getText(document.getWordRangeAtPosition(position));\n+ for (const tableNode of DatabaseCache.getTableNodeList()) {\n+ if (tableNode.table == tableName) {\n+ let columnNodes = (await tableNode.getChildren()) as ColumnNode[]\n+ let hoverContent=`table: ${tableName}`;\n+ for (const columnNode of columnNodes) {\n+ hoverContent+=`\n+${columnNode.column.COLUMN_NAME} ${columnNode.column.COLUMN_TYPE} ${columnNode.column.COLUMN_COMMENT?'comment '+columnNode.column.COLUMN_COMMENT:''} `\n+ }\n+ let markdownStr=new vscode.MarkdownString()\n+ markdownStr.appendCodeblock(hoverContent,'sql')\n+ return new vscode.Hover(markdownStr)\n+ }\n+ }\n+\n+ return null;\n+ }\n+\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support hover table get info
|
141,908 |
22.03.2020 22:56:14
| -28,800 |
7ce727358ba96bdaaf7f11e4bb020f9ce9cfa2eb
|
more keyword support
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -81,7 +81,7 @@ export class QueryUnit {\nprivate static batchPattern = /\\s+(TRIGGER|PROCEDURE|FUNCTION)\\s+/ig\n- private static obtainSql(activeTextEditor: vscode.TextEditor): string {\n+ static obtainSql(activeTextEditor: vscode.TextEditor): string {\nvar content = activeTextEditor.document.getText()\nif (content.match(this.batchPattern)) return content;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -4,15 +4,57 @@ import { DatabaseCache } from \"../database/DatabaseCache\";\nimport { INode } from \"../model/INode\";\nimport { ColumnNode } from \"../model/table/columnNode\";\nimport { TableNode } from \"../model/table/tableNode\";\n+import { QueryUnit } from \"../database/QueryUnit\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\n-\nconstructor() {\nthis.initDefaultComplectionItem()\n}\n+ private keywordList: string[] = [ \"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n+ private functionList: string[] = [\"decimal\",\"char\", \"varchar\", \"CHAR_LENGTH\", \"CONCAT\", \"NOW\", \"DATE_ADD\", \"DATE_SUB\", \"MAX\", \"COUNT\", \"MIN\", \"SUM\", \"AVG\", \"LENGTH\", \"IF\", \"IFNULL\", \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\"]\n+ private defaultComplectionItems: vscode.CompletionItem[] = []\n+ private tableKeywordList: string[] = [\"AUTO_INCREMENT\",\"NULL\",\"NOT\",\"PRIMARY\", \"CURRENT_TIME\",\"DEFAULT\",\"COMMENT\",\"UNIQUE\",\"KEY\"]\n+ private tableKeywordComplectionItems: vscode.CompletionItem[] = []\n+ private typeList: string[] = [\"INTEGER\",\"smallint\",\"tinyint\",\"MEDIUMINT\",\"bigint\",\"numeric\",\"bit\",\"long\", \"int\", \"float\", \"double\",\"TEXT\",\"SET\", \"blob\", \"timestamp\", \"date\",\"time\",\"YEAR\", \"datetime\"]\n+ private typeComplectionItems: vscode.CompletionItem[] = []\n+\n+ private initDefaultComplectionItem() {\n+ this.keywordList.forEach(keyword => {\n+ let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n+ keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n+ this.defaultComplectionItems.push(keywordComplectionItem)\n+ })\n+ this.functionList.forEach(keyword => {\n+ let functionComplectionItem = new vscode.CompletionItem(keyword + \" \")\n+ functionComplectionItem.kind = vscode.CompletionItemKind.Function\n+ functionComplectionItem.insertText = new vscode.SnippetString(keyword + \"($1)\")\n+ this.defaultComplectionItems.push(functionComplectionItem)\n+ })\n+ this.tableKeywordList.forEach(keyword => {\n+ let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n+ keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n+ this.tableKeywordComplectionItems.push(keywordComplectionItem)\n+ })\n+ this.typeList.forEach(columnType => {\n+ let columnTypeComplectionItem = new vscode.CompletionItem(columnType + \" \")\n+ columnTypeComplectionItem.kind = vscode.CompletionItemKind.TypeParameter\n+ this.typeComplectionItems.push(columnTypeComplectionItem)\n+ })\n+ }\n+\n+ private createReg=/CREATE TABLE/ig;\n+ private programReg=/(FUNCTION|PROCEDURE)/ig;\nasync provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): Promise<vscode.CompletionItem[]> {\n+ var sql=QueryUnit.obtainSql(vscode.window.activeTextEditor)\n+ if(sql && sql.match(this.createReg)){\n+ return this.typeComplectionItems.concat(this.tableKeywordComplectionItems);\n+ }\n+\nlet completionItems = []\n+ if(sql && sql.match(this.programReg)){\n+ completionItems=this.typeComplectionItems\n+ }\nconst prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\nconst preChart = document.getText(new vscode.Range(prePostion, position))\n@@ -49,25 +91,6 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nreturn item;\n}\n- private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\",\"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COMMENT\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n- private functionList: string[] = [\"CHAR_LENGTH\",\"CONCAT\",\"NOW\",\"DATE_ADD\",\"DATE_SUB\",\"MAX\",\"COUNT\",\"MIN\",\"SUM\",\"AVG\",\"LENGTH\",\"IF\",\"IFNULL\",\"MD5\",\"SHA\",\"CURRENT_TIME\",\"CURRENT_DATE\",\"DATE_FORMAT\",\"CAST\"]\n- private defaultComplectionItems: vscode.CompletionItem[] = []\n-\n- private initDefaultComplectionItem() {\n- this.keywordList.forEach(keyword => {\n- let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n- keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n- this.defaultComplectionItems.push(keywordComplectionItem)\n- })\n- this.functionList.forEach(keyword => {\n- let functionComplectionItem = new vscode.CompletionItem(keyword + \" \")\n- functionComplectionItem.kind = vscode.CompletionItemKind.Function\n- functionComplectionItem.insertText = new vscode.SnippetString(keyword + \"($1)\")\n- this.defaultComplectionItems.push(functionComplectionItem)\n-\n- })\n- }\n-\nprivate generateDatabaseComplectionItem(): vscode.CompletionItem[] {\nlet databaseNodes = DatabaseCache.getDatabaseNodeList()\n"
},
{
"change_type": "MODIFY",
"old_path": "syntaxes/mysql.tmLanguage.json",
"new_path": "syntaxes/mysql.tmLanguage.json",
"diff": "\"scopeName\": \"source.sql\",\n\"patterns\": [\n{\n- \"match\": \"(?i)\\\\b(TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED|PRIVILEGES|FLUSH|SHOW|INDEX|CHANGE|COMMENT|COLUMN|ADD|UNIQUE|EXPLAIN)\\\\b\",\n+ \"match\": \"(?i)\\\\b(DEFAULT|long|double|AUTO_INCREMENT|TRIGGER|DEFINER|FOR|EACH|CURSOR|VIEW|IDENTIFIED|PRIVILEGES|FLUSH|SHOW|INDEX|CHANGE|COMMENT|COLUMN|ADD|UNIQUE|EXPLAIN)\\\\b\",\n\"name\": \"keyword.mysql\"\n},\n{\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
more keyword support
|
141,908 |
22.03.2020 23:27:31
| -28,800 |
af5e55b1ca25a0b8f8ea406d8ad9e503129a7683
|
block mysql table
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -44,6 +44,11 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nprivate createReg = /CREATE TABLE/ig;\nprivate programReg = /(FUNCTION|PROCEDURE)/ig;\n+ /**\n+ * Main function\n+ * @param document\n+ * @param position\n+ */\nasync provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): Promise<vscode.CompletionItem[]> {\nvar sql = QueryUnit.obtainSql(vscode.window.activeTextEditor)\n@@ -51,13 +56,14 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nreturn this.typeComplectionItems.concat(this.tableKeywordComplectionItems);\n}\n- let completionItems = []\n- if(sql && sql.match(this.programReg)){\n- completionItems=this.typeComplectionItems\n- }\n+ let completionItems = [];\nconst prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\nconst preChart = document.getText(new vscode.Range(prePostion, position))\n+\n+ if (preChart != \".\" && sql && sql.match(this.programReg)) {\n+ completionItems = this.typeComplectionItems\n+ }\nif (preChart != \".\" && preChart != \" \") {\ncompletionItems = completionItems.concat(this.defaultComplectionItems)\n}\n@@ -101,6 +107,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\n})\n}\n+ private blockDbReg = /(mysql|performance_schema|information_schema)/ig\nprivate generateTableComplectionItem(inputWord?: string): vscode.CompletionItem[] {\nlet tableNodes: INode[] = []\n@@ -109,7 +116,9 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nif (databaseNode.database == inputWord) tableNodes = DatabaseCache.getTableListOfDatabase(databaseNode.identify)\n})\n} else {\n- tableNodes = DatabaseCache.getTableNodeList()\n+ tableNodes = DatabaseCache.getTableNodeList().filter(databaseNode => {\n+ return !databaseNode.database.match(this.blockDbReg)\n+ })\n}\nreturn tableNodes.map<vscode.CompletionItem>((tableNode: TableNode) => {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
block mysql table
|
141,908 |
23.03.2020 03:11:44
| -28,800 |
07067dd8c527bcf21da8a77dbddd7741564a527e
|
open setting for windows
|
[
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "out\nnode_modules\n.vscode-test/\n-.vsix\n+*.vsix\n+package-lock.json\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n\"commands\": [\n{\n- \"command\": \"mysql.hisotry.open\",\n+ \"command\": \"mysql.history.open\",\n\"title\": \"Open History\",\n\"category\": \"MySQL\",\n\"icon\": \"resources/history.svg\"\n},\n+ {\n+ \"command\": \"mysql.setting.open\",\n+ \"title\": \"Open Setting\",\n+ \"category\": \"MySQL\",\n+ \"icon\": \"resources/settings.svg\"\n+ },\n{\n\"command\": \"mysql.refresh\",\n\"title\": \"Refresh\",\n\"group\": \"navigation@1\"\n},\n{\n- \"command\": \"mysql.hisotry.open\",\n+ \"command\": \"mysql.setting.open\",\n+ \"title\": \"Open Setting\",\n+ \"when\": \"view == github.cweijan.mysql\",\n+ \"group\": \"navigation@-1\"\n+ },\n+ {\n+ \"command\": \"mysql.history.open\",\n\"when\": \"view == github.cweijan.mysql\",\n\"group\": \"navigation@0\"\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/settings.svg",
"diff": "+<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n+<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\n+<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n+ viewBox=\"0 0 513.067 513.067\" style=\"enable-background:new 0 0 513.067 513.067;\" xml:space=\"preserve\">\n+<g>\n+ <path style=\"fill:#F3705A;\" d=\"M273.067,387.733v-23.467l-32-7.467c-1.067-6.4-2.133-11.733-4.267-17.067l24.533-22.4\n+ L249.6,297.067l-30.933,9.6c-4.267-4.267-8.533-8.533-12.8-12.8l9.6-30.933L195.2,251.2l-22.4,24.533\n+ c-5.333-2.133-11.733-3.2-17.067-4.267l-7.467-32H124.8l-7.467,32c-6.4,1.067-11.733,2.133-17.067,4.267l-22.4-24.533L57.6,262.933\n+ l9.6,30.933c-4.267,4.267-8.533,8.533-12.8,12.8l-30.933-9.6l-11.733,20.267l24.533,22.4c-2.133,5.333-3.2,11.733-4.267,17.067\n+ l-32,7.467v23.467l32,7.467c1.067,6.4,2.133,11.733,4.267,17.067l-24.533,22.4l11.733,20.267l30.933-9.6\n+ c4.267,4.267,8.533,8.533,12.8,12.8l-9.6,30.933L77.867,500.8l22.4-24.533c5.333,2.133,11.733,3.2,17.067,4.267l7.467,32h23.467\n+ l7.467-32c6.4-1.067,11.733-2.133,17.067-4.267l22.4,24.533l20.267-11.733l-9.6-30.933c4.267-4.267,8.533-8.533,12.8-12.8\n+ l30.933,9.6l11.733-20.267l-24.533-22.4c2.133-5.333,3.2-11.733,4.267-17.067L273.067,387.733z M136.533,440c-35.2,0-64-28.8-64-64\n+ s28.8-64,64-64s64,28.8,64,64S171.733,440,136.533,440z\"/>\n+ <path style=\"fill:#F3705A;\" d=\"M136.533,353.6c-12.8,0-22.4,10.667-22.4,22.4c0,12.8,10.667,22.4,22.4,22.4\n+ c12.8,0,22.4-10.667,22.4-22.4C158.933,363.2,149.333,353.6,136.533,353.6z\"/>\n+</g>\n+<g>\n+ <path style=\"fill:#66C6B9;\" d=\"M504.533,219.2L512,192.533L477.867,174.4c1.067-7.467,1.067-14.933,0-21.333l35.2-18.133\n+ l-8.533-27.733l-39.467,2.133c-3.2-6.4-6.4-12.8-10.667-19.2l21.333-33.067L455.467,36.8L422.4,58.133\n+ c-5.333-4.267-11.733-7.467-18.133-10.667L406.4,8l-27.733-7.467l-18.133,35.2c-7.467-1.067-14.933-1.067-21.333,0l-17.067-35.2\n+ L294.4,8l2.133,39.467c-6.4,3.2-12.8,6.4-19.2,10.667L244.267,36.8L224,56l21.333,33.067c-4.267,5.333-7.467,11.733-10.667,18.133\n+ l-39.467-2.133l-7.467,27.733l35.2,18.133c-1.067,7.467-1.067,14.933,0,21.333l-35.2,18.133l7.467,27.733L234.667,216\n+ c3.2,6.4,6.4,12.8,10.667,19.2L224,268.267l20.267,20.267l33.067-21.333c5.333,4.267,11.733,7.467,18.133,10.667l-2.133,39.467\n+ l27.733,7.467l18.133-34.133c7.467,1.067,14.933,1.067,21.333,0l18.133,35.2L406.4,318.4l-2.133-39.467\n+ c6.4-3.2,12.8-6.4,19.2-10.667l33.067,21.333l20.267-20.267l-21.333-33.067c4.267-5.333,7.467-11.733,10.667-18.133L504.533,219.2z\n+ M333.867,222.4c-33.067-8.533-52.267-42.667-43.733-75.733S332.8,94.4,365.867,102.933c33.067,8.533,52.267,42.667,43.733,75.733\n+ C400,211.733,365.867,230.933,333.867,222.4z\"/>\n+ <path style=\"fill:#66C6B9;\" d=\"M357.333,136c-14.933-4.267-29.867,4.267-34.133,19.2c-4.267,14.933,4.267,29.867,19.2,34.133\n+ c14.933,4.267,29.867-4.267,34.133-19.2C379.733,155.2,371.2,140.267,357.333,136z\"/>\n+</g>\n+<path style=\"fill:#FFD15C;\" d=\"M182.4,165.867V139.2l-24.533-5.333c-1.067-5.333-3.2-10.667-6.4-14.933L165.333,97.6l-19.2-19.2\n+ L124.8,92.267c-4.267-3.2-9.6-5.333-14.933-6.4l-5.333-24.533H77.867l-5.333,24.533c-5.333,1.067-10.667,3.2-14.933,6.4L36.267,78.4\n+ l-19.2,19.2l13.867,20.267c-3.2,5.333-5.333,9.6-6.4,16L0,139.2v26.667l24.533,5.333c1.067,5.333,3.2,10.667,6.4,14.933\n+ L17.067,206.4l19.2,19.2L57.6,211.733c4.267,3.2,9.6,5.333,14.933,6.4l5.333,24.533h26.667l5.333-24.533\n+ c5.333-1.067,10.667-3.2,16-6.4l20.267,13.867l19.2-19.2l-13.867-21.333c3.2-4.267,5.333-9.6,6.4-14.933L182.4,165.867z\n+ M91.733,177.6c-13.867,0-24.533-10.667-24.533-24.533s10.667-24.533,24.533-24.533s24.533,10.667,24.533,24.533\n+ S104.533,177.6,91.733,177.6z\"/>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+<g>\n+</g>\n+</svg>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -13,7 +13,7 @@ export class CacheKey{\n}\nexport class CommandKey{\n- static RecordHistory=\"mysql.hisotry.record\"\n+ static RecordHistory=\"mysql.history.record\"\nstatic Refresh=\"mysql.refresh\"\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -23,6 +23,7 @@ import { HistoryManager } from \"./extension/HistoryManager\";\nimport { CommandKey } from \"./common/Constants\";\nimport { TableHoverProvider } from \"./provider/TableHoverProvider\";\nimport { TableGroup } from \"./model/table/tableGroup\";\n+import { MysqlSetting } from \"./extension/MysqlSetting\";\nexport function activate(context: vscode.ExtensionContext) {\n@@ -49,7 +50,7 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(CommandKey.Refresh, () => {\nmysqlTreeDataProvider.init()\n}),\n- vscode.commands.registerCommand(\"mysql.hisotry.open\", () => {\n+ vscode.commands.registerCommand(\"mysql.history.open\", () => {\nhistoryManager.showHistory()\n}),\nvscode.commands.registerCommand(CommandKey.RecordHistory, (sql: string,costTime:number) => {\n@@ -137,6 +138,9 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.template.procedure\", (procedureGroup: ProcedureGroup) => {\nprocedureGroup.createTemplate();\n}),\n+ vscode.commands.registerCommand(\"mysql.setting.open\", (procedureGroup: ProcedureGroup) => {\n+ MysqlSetting.open();\n+ }),\nvscode.commands.registerCommand(\"mysql.template.view\", (viewGroup: ViewGroup) => {\nviewGroup.createTemplate();\n}),\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/extension/MysqlSetting.ts",
"diff": "+import * as vscode from \"vscode\";\n+import * as fs from \"fs\";\n+import process = require('process');\n+\n+\n+export class MysqlSetting {\n+ private static x64 = \"C:\\\\Program Files\\\\MySQL\";\n+ private static x86 = \"C:\\\\Program Files (x86)\\\\MySQL\";\n+ static open() {\n+ if(!process.platform.match(/win/ig)){\n+ vscode.window.showErrorMessage(\"Only Support Windows OS.\")\n+ return;\n+ }\n+ var isOpen = this.check(this.x86)\n+ if (!isOpen) {\n+ var isOpen = this.check(this.x64)\n+ if (!isOpen) {\n+ vscode.window.showErrorMessage(\"Cannot find mysql setting in your machine.\")\n+ }\n+ }\n+ }\n+\n+ static check(param): boolean {\n+ for (const fileName of fs.readdirSync(param)) {\n+ const serverPath = param + \"\\\\\" + fileName;\n+ if (fs.statSync(serverPath).isDirectory) {\n+ vscode.workspace.openTextDocument(vscode.Uri.file(`${serverPath}\\\\my.ini`)).then(doc => {\n+ vscode.window.showTextDocument(doc);\n+ });\n+ return true;\n+ }\n+ }\n+ return false;\n+ }\n+\n+\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
open setting for windows
|
141,908 |
23.03.2020 06:47:57
| -28,800 |
a472c565ceb927a316581ac8a86f70f1d760cc60
|
order column
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "</el-cow>\n<el-cow>\n<span>costTime: </span><span v-text=\"result.costTime\"></span>ms,\n- <span>row: {{result.rows.length}}, Col: {{columnCount}}</span>\n+ <span>row: {{result.data.length}}, Col: {{columnCount}}</span>\n</el-cow>\n</el-row>\n</div>\n- <el-table id=\"dataTable\" v-loading='loading' size='small' highlight-current-row='true'\n- :data=\"result.rows.filter(data => !search || JSON.stringify(data).toLowerCase().includes(search.toLowerCase()))\"\n- style=\"width: 100%\" border @cell-click=\"celledit\">\n- <el-table-column :label=\"key\" v-for=\"(value,key) in result.rows[0]\" :key=\"key\" show-overflow-tooltip\n- align=\"center\">\n+ <div :style=\"'width:' + tableWidth + 'px;overflow:scroll'\">\n+ <el-table id=\"dataTable\" v-loading='loading' size='small'\n+ :data=\"result.data.filter(data => !search || JSON.stringify(data).toLowerCase().includes(search.toLowerCase()))\"\n+ border @cell-click=\"celledit\">\n+ <el-table-column :label=\"column\" v-for=\"(column) in result.columnList\" :key=\"column\" align=\"center\"\n+ v-if=\"result.columnList\" :width=\"computeWidth(column)\">\n+ <template slot-scope=\"scope\">\n+ <span v-html='dataformat(scope.row[column])'></span>\n+ </template>\n+ </el-table-column>\n+ <el-table-column :label=\"key\" v-for=\"(value,key) in result.data[0]\" :key=\"key\" align=\"center\"\n+ v-if=\"!result.columnList\" :width=\"computeWidth(key)\">\n<template slot-scope=\"scope\">\n<span v-html='dataformat(scope.row[key])'></span>\n</template>\n</el-table-column>\n</el-table>\n</div>\n+ </div>\n</body>\n<script>\nel: '#app',\ndata: {\nresult: previousState ? previousState.result : {\n- rows: [],\n+ data: [],\nsql: '',\n- costTime: 0\n+ costTime: 0,\n+ widthCache: {},\n+ tableWidth: null\n},\nsearch: '',\nloading: false\n},\nmethods: {\n+ updateWidth() {\n+ let width = 0;\n+ for (const key in this.widthCache) {\n+ width = width + parseInt(this.widthCache[key])\n+ }\n+ this.tableWidth = width;\n+ },\n+ computeWidth(key, index) {\n+\n+ if (this.widthCache[key]) return this.widthCache[key];\n+ if (!index) index = 0\n+ if (!this.result.data[index] || index > 10) return 60;\n+ var value = this.result.data[index][key];\n+ var dynamic = value ? ((value + \"\").length) * 10 : ((key + \"\").length) * 10;\n+ if (dynamic > 600) dynamic = 600;\n+ if (dynamic < 60) dynamic = 60;\n+ var nextDynamic = this.computeWidth(key, ++index)\n+ if (dynamic < nextDynamic) dynamic = nextDynamic;\n+ this.widthCache[key] = dynamic;\n+ this.updateWidth()\n+ return dynamic;\n+ },\ncelledit(row, column, cell, event) {\n- // cell.contentEditable = true;\n+ cell.contentEditable = true;\n// cell.focus()\n},\nexecute() {\n},\ncomputed: {\ncolumnCount() {\n- if (this.result.rows == undefined || this.result.rows[0] == undefined) return 0;\n- return Object.keys(this.result.rows[0]).length;\n+ if (this.result.data == undefined || this.result.data[0] == undefined) return 0;\n+ return Object.keys(this.result.data[0]).length;\n}\n}\n})\nwindow.addEventListener('message', event => {\n- vue.result.rows = event.data.data\n- vue.result.sql = event.data.sql\n- vue.result.costTime = event.data.costTime\n+ vue.result = event.data\nvue.loading = false\n+ vue.widthCache = {}\n// instead by retainContextWhenHidden=true\n// vscode.setState({ result: vue.result });\n- document.write(previousState + \":\" + count)\n});\n</script>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/ConnectionManager.ts",
"new_path": "src/database/ConnectionManager.ts",
"diff": "@@ -7,70 +7,49 @@ import { QueryUnit } from \"./QueryUnit\";\nexport class ConnectionManager {\n- private static connectionCache = {}\nprivate static lastConnectionOption: IConnection;\n- private static lastActiveConnection: any;\n+ private static activeConnection: any;\n- public static updateLastActiveConnection(connectionOptions: IConnection): any {\n- this.lastConnectionOption = connectionOptions\n+ public static getLastConnectionOption() {\n+ return this.lastConnectionOption\n}\npublic static getLastActiveConnection() {\n- if (!this.lastConnectionOption) {\n+ if (!this.activeConnection) {\nreturn undefined;\n}\n- if (this.lastActiveConnection && this.lastActiveConnection.state == 'authenticated') {\n- return this.lastActiveConnection\n- }\n+\nreturn this.getConnection(Object.assign({ multipleStatements: true }, this.lastConnectionOption))\n}\npublic static getConnection(connectionOptions: IConnection, changeActive: Boolean = false): Promise<any> {\n- if (!connectionOptions.multipleStatements) connectionOptions.multipleStatements = true\n-\n- const key = `${connectionOptions.host}_${connectionOptions.port}_${connectionOptions.user}_${connectionOptions.password}`\n+ connectionOptions.multipleStatements = true\n+ this.lastConnectionOption = connectionOptions\n+ if (changeActive) Global.updateStatusBarItems(connectionOptions);\nreturn new Promise((resolve, reject) => {\n-\n- if (this.connectionCache[key] && this.connectionCache[key].conneciton.state == 'authenticated') {\n+ let connection = this.activeConnection\n+ if (connection && connection.state == 'authenticated') {\nif (connectionOptions.database) {\n- QueryUnit.queryPromise(this.connectionCache[key].conneciton, `use \\`${connectionOptions.database}\\``).then(() => {\n- if (changeActive || this.lastActiveConnection == undefined) {\n- this.lastConnectionOption = this.connectionCache[key].connectionOptions\n- this.lastActiveConnection = this.connectionCache[key].conneciton\n- Global.updateStatusBarItems(connectionOptions);\n- }\n- resolve(this.connectionCache[key].conneciton)\n+ QueryUnit.queryPromise(connection, `use \\`${connectionOptions.database}\\``).then(() => {\n+ resolve(connection)\n}).catch(error => {\nreject(error)\n})\n} else {\n- if (changeActive || this.lastActiveConnection == undefined) {\n- this.lastConnectionOption = this.connectionCache[key].connectionOptions\n- this.lastActiveConnection = this.connectionCache[key].conneciton\n- Global.updateStatusBarItems(connectionOptions);\n- }\n- resolve(this.connectionCache[key].conneciton)\n+ resolve(connection)\n}\n} else {\n- this.connectionCache[key] = {\n- connectionOptions: connectionOptions,\n- conneciton: this.createConnection(connectionOptions)\n- };\n- this.connectionCache[key].conneciton.connect((err: Error) => {\n+ this.activeConnection = this.createConnection(connectionOptions);\n+ this.activeConnection.connect((err: Error) => {\nif (!err) {\n- if (changeActive || this.lastActiveConnection == undefined) {\n- this.lastConnectionOption = connectionOptions\n- this.lastActiveConnection = this.connectionCache[key].conneciton\n- Global.updateStatusBarItems(connectionOptions);\n- }\n- resolve(this.lastActiveConnection);\n+ resolve(this.activeConnection);\n} else {\n- this.connectionCache[key] = undefined\n+ this.activeConnection = undefined\nConsole.log(`${err.stack}\\n${err.message}`)\nreject(err.message);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/DatabaseCache.ts",
"new_path": "src/database/DatabaseCache.ts",
"diff": "@@ -168,6 +168,15 @@ export class DatabaseCache {\nreturn result;\n}\n+ static getTable(databaseIdentify:string,tableName:String):TableNode{\n+ let tableList = this.databaseNodeMapTableNode[databaseIdentify +\"_\"+ ModelType.TABLE_GROUP]\n+ if(!tableList)return null;\n+ for (const tableNode of tableList) {\n+ if(tableNode.table==tableName)return tableNode;\n+ }\n+ return null;\n+ }\n+\n/**\n* get table tree data\n* @param tableIdentify\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -37,9 +37,14 @@ export class QueryUnit {\nreturn;\n}\nlet connection: any;\n- if (!connectionOptions && !(connection = await ConnectionManager.getLastActiveConnection())) {\n+ if (!connectionOptions) {\n+ if (!(connection = await ConnectionManager.getLastActiveConnection())) {\nvscode.window.showWarningMessage(\"No MySQL Server or Database selected\");\nreturn;\n+ } else {\n+ connectionOptions = ConnectionManager.getLastConnectionOption()\n+ }\n+\n} else if (connectionOptions) {\nconnectionOptions.multipleStatements = true;\nconnection = await ConnectionManager.getConnection(connectionOptions)\n@@ -72,7 +77,7 @@ export class QueryUnit {\nreturn;\n}\nif (Array.isArray(data)) {\n- SqlViewManager.showQueryResult({ sql, data, splitResultView: true, costTime: costTime });\n+ SqlViewManager.showQueryResult({ splitResultView: true, extra: { sql, data, costTime } }, connectionOptions);\n} else {\nConsole.log(`execute sql success:${sql}`)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "-import { WebviewPanel } from \"vscode\";\n-\"use strict\";\nimport * as fs from \"fs\";\nimport * as vscode from \"vscode\";\n+import { WebviewPanel } from \"vscode\";\n+import { OperateType } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\n-import { ConnectionManager } from \"./ConnectionManager\";\n+import { IConnection } from \"../model/Connection\";\nimport { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\n-import { OperateType } from \"../common/Constants\";\n+import { ConnectionManager } from \"./ConnectionManager\";\n+import { DatabaseCache } from \"./DatabaseCache\";\nimport { QueryUnit } from \"./QueryUnit\";\n+import { ColumnNode } from \"../model/table/columnNode\";\n+\"use strict\";\nexport class ViewOption {\nviewPath?: string;\nviewTitle?: string;\n- sql?: string;\n- data?: any;\nsplitResultView: boolean = false;\n- costTime?: number;\n+ extra?: any;\n/**\n* receive webview send message\n*/\n@@ -28,15 +29,24 @@ export class SqlViewManager {\nstatic tableEditWebviewPanel: WebviewPanel\nstatic tableCreateWebviewPanel: WebviewPanel\nstatic extensionPath: string\n- public static initExtesnsionPath(extensionPath: string) {\n+ static initExtesnsionPath(extensionPath: string) {\nthis.extensionPath = extensionPath\n}\n- public static showQueryResult(viewOption: ViewOption) {\n+ static async showQueryResult(viewOption: ViewOption, opt: IConnection) {\n+\n+ let tableName = this.getTable(viewOption.extra)\n+ let tableNode = DatabaseCache.getTable(`${opt.host}_${opt.port}_${opt.user}_${opt.database}`, tableName)\n+ if (tableNode) {\n+ let columnList = (await tableNode.getChildren()).map((columnNode: ColumnNode) => {\n+ return columnNode.column.COLUMN_NAME\n+ })\n+ viewOption.extra['columnList']=columnList\n+ }\nif (this.resultWebviewPanel) {\nif (this.resultWebviewPanel.visible) {\n- this.resultWebviewPanel.webview.postMessage(viewOption)\n+ this.resultWebviewPanel.webview.postMessage(viewOption.extra)\nthis.resultWebviewPanel.reveal(vscode.ViewColumn.Two, true);\nreturn;\n} else {\n@@ -50,7 +60,7 @@ export class SqlViewManager {\nthis.createWebviewPanel(viewOption).then(webviewPanel => {\nthis.resultWebviewPanel = webviewPanel\n- webviewPanel.webview.postMessage(viewOption)\n+ webviewPanel.webview.postMessage(viewOption.extra)\nwebviewPanel.onDidDispose(() => { this.resultWebviewPanel = undefined })\nwebviewPanel.webview.onDidReceiveMessage((params) => {\nif (params.type == OperateType.execute) {\n@@ -62,7 +72,25 @@ export class SqlViewManager {\n}\n- public static showConnectPage() {\n+ private static getTable(extra: any):string {\n+ if(!extra)return null;\n+ let sql=extra.sql;\n+ let baseMatch;\n+ if (sql && (baseMatch = (sql + \" \").match(/select\\s+\\*\\s+from\\s*(.+?)(?=[\\s;])/i)) && !sql.match(/\\bjoin\\b/ig)) {\n+ let expectTable: string = baseMatch[1];\n+ let temp: string[], table;\n+ if (expectTable.includes(\"`\")) {\n+ temp = expectTable.split(\"`\");\n+ table = temp[temp.length - 2];\n+ } else {\n+ temp = expectTable.split(\".\")\n+ table = temp[temp.length - 1]\n+ }\n+ return table;\n+ }\n+ }\n+\n+ static showConnectPage() {\nthis.createWebviewPanel({\nviewPath: \"connect\",\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
order column
|
141,908 |
06.04.2020 00:02:58
| -28,800 |
a2469a032171efd01cebd9cbc1579a9492a99cfc
|
fix result data init fail.
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "@@ -194,6 +194,7 @@ where \\`${event.data.primaryKey}\\`='#2'\n// instead by retainContextWhenHidden=true\n// vscode.setState({ result: vue.result });\n});\n+ vscode.postMessage({ type: 'init'})\n</script>\n</html>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -46,6 +46,7 @@ export class ModelType{\nexport class OperateType{\nstatic execute='execute';\n+ static init='init';\nstatic previous=2;\nstatic next=3;\nstatic save=4;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "@@ -37,6 +37,7 @@ export class SqlViewManager {\nstatic async showQueryResult(viewOption: ViewOption, opt: IConnection) {\nlet tableName = this.getTable(viewOption.extra)\n+ // load table infomation\nlet tableNode = DatabaseCache.getTable(`${opt.host}_${opt.port}_${opt.user}_${opt.database}`, tableName)\nif (tableNode) {\nlet primaryKey: string;\n@@ -51,6 +52,7 @@ export class SqlViewManager {\nviewOption.extra['database'] = opt.database\nviewOption.extra['table'] = tableName\n}\n+ // update result webview\nif (this.resultWebviewPanel) {\nif (this.resultWebviewPanel.visible) {\nthis.resultWebviewPanel.webview.postMessage(viewOption.extra)\n@@ -62,16 +64,20 @@ export class SqlViewManager {\n}\n+ // init result webview\nviewOption.viewPath = \"result\"\nviewOption.viewTitle = \"Query\"\n-\n- this.createWebviewPanel(viewOption).then(webviewPanel => {\n+ this.createWebviewPanel(viewOption).then(async webviewPanel => {\nthis.resultWebviewPanel = webviewPanel\n- webviewPanel.webview.postMessage(viewOption.extra)\nwebviewPanel.onDidDispose(() => { this.resultWebviewPanel = undefined })\nwebviewPanel.webview.onDidReceiveMessage((params) => {\n- if (params.type == OperateType.execute) {\n+ switch (params.type) {\n+ case OperateType.init:\n+ webviewPanel.webview.postMessage(viewOption.extra)\n+ break;\n+ case OperateType.execute:\nQueryUnit.runQuery(params.sql)\n+ break;\n}\n})\n})\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
fix result data init fail.
|
141,908 |
06.04.2020 02:33:27
| -28,800 |
5669dcb6859e7284e4255551bd4a95a98106d25b
|
show sql before data loading
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "tableWidth: null,\nwidthCache: {},\nsearch: '',\n- loading: false,\n+ loading: true,\nupdate: {\nsql: null,\nwhere: 'w',\n})\nwindow.addEventListener('message', event => {\n- vue.result = event.data\n- if (event.data.primaryKey && event.data.database && event.data.table) {\n- vue.update.sql = `update \\`${event.data.database}\\`.\\`${event.data.table}\\`\n+\n+ let data=event.data;\n+ if (data.primaryKey && data.database && data.table) {\n+ vue.update.sql = `update \\`${data.database}\\`.\\`${data.table}\\`\nset #1\n-where \\`${event.data.primaryKey}\\`='#2'\n-`\n+where \\`${data.primaryKey}\\`='#2' `\n}\n- vue.loading = false\n+ if(data.sql){\n+ vue.result.sql=data.sql;\n+ vue.result.costTime=0;\n+ vue.loading = true\n+ }\n+ if(data.costTime){\n+ vue.result.costTime=data.costTime\n+ }\n+ if(data.data!=null){\n+ vue.result.data=data.data;\nvue.widthCache = {}\n+ vue.loading = false\n+ }\n+\n// instead by retainContextWhenHidden=true\n// vscode.setState({ result: vue.result });\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -62,7 +62,11 @@ export class QueryUnit {\n}\n}\nsql = sql.replace(/--.+/ig, '');\n- let executeTime = new Date().getTime()\n+ const executeTime = new Date().getTime()\n+ const isDDL = sql.match(this.ddlPattern)\n+ if (!isDDL) {\n+ SqlViewManager.showQueryResult({ splitResultView: true, extra: { sql } }, connectionOptions);\n+ }\nconnection.query(sql, (err, data) => {\nif (err) {\n//TODO trans output to query page\n@@ -72,7 +76,7 @@ export class QueryUnit {\nvar costTime = new Date().getTime() - executeTime\nif (fromEditor)\nvscode.commands.executeCommand(CommandKey.RecordHistory, sql, costTime)\n- if (sql.match(this.ddlPattern)) {\n+ if (isDDL) {\nvscode.commands.executeCommand(CommandKey.Refresh)\nreturn;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "@@ -7,7 +7,6 @@ import { IConnection } from \"../model/Connection\";\nimport { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\nimport { ConnectionManager } from \"./ConnectionManager\";\nimport { DatabaseCache } from \"./DatabaseCache\";\n-import { QueryUnit } from \"./QueryUnit\";\nimport { ColumnNode } from \"../model/table/columnNode\";\n\"use strict\";\n@@ -25,17 +24,18 @@ export class ViewOption {\n}\nexport class SqlViewManager {\n- static resultWebviewPanel: WebviewPanel\n- static tableEditWebviewPanel: WebviewPanel\n- static tableCreateWebviewPanel: WebviewPanel\n+\nstatic extensionPath: string\nstatic initExtesnsionPath(extensionPath: string) {\nthis.extensionPath = extensionPath\n}\n-\n- static async showQueryResult(viewOption: ViewOption, opt: IConnection) {\n-\n+ private static resultWebviewPanel: WebviewPanel\n+ private static sendData: any;\n+ private static creating = false;\n+ public static async showQueryResult(viewOption: ViewOption, opt: IConnection) {\n+ this.sendData = viewOption.extra\n+ if (this.creating) return;\nlet tableName = this.getTable(viewOption.extra)\n// load table infomation\nlet tableNode = DatabaseCache.getTable(`${opt.host}_${opt.port}_${opt.user}_${opt.database}`, tableName)\n@@ -67,16 +67,18 @@ export class SqlViewManager {\n// init result webview\nviewOption.viewPath = \"result\"\nviewOption.viewTitle = \"Query\"\n+ this.creating = true;\nthis.createWebviewPanel(viewOption).then(async webviewPanel => {\nthis.resultWebviewPanel = webviewPanel\n- webviewPanel.onDidDispose(() => { this.resultWebviewPanel = undefined })\n+ this.creating = false;\n+ webviewPanel.onDidDispose(() => { this.resultWebviewPanel = undefined; this.creating = false; })\nwebviewPanel.webview.onDidReceiveMessage((params) => {\nswitch (params.type) {\ncase OperateType.init:\n- webviewPanel.webview.postMessage(viewOption.extra)\n+ webviewPanel.webview.postMessage(SqlViewManager.sendData)\nbreak;\ncase OperateType.execute:\n- QueryUnit.runQuery(params.sql)\n+ vscode.commands.executeCommand('mysql.runQuery', params.sql)\nbreak;\n}\n})\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -92,8 +92,9 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.deleteConnection\", (connectionNode: ConnectionNode) => {\nconnectionNode.deleteConnection(context);\n}),\n- vscode.commands.registerCommand(\"mysql.runQuery\", () => {\n- QueryUnit.runQuery();\n+ vscode.commands.registerCommand(\"mysql.runQuery\", (sql) => {\n+ if (typeof sql != 'string') sql = null\n+ QueryUnit.runQuery(sql);\n}),\nvscode.commands.registerCommand(\"mysql.newQuery\", (databaseOrConnectionNode: DatabaseNode | ConnectionNode) => {\ndatabaseOrConnectionNode.newQuery();\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
show sql before data loading
|
141,908 |
06.04.2020 03:47:46
| -28,800 |
5dba96a9b7ef7f6a4f9be48f1ea3e7e5a391bcf2
|
beautify sql format
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "},\n{\n\"command\": \"mysql.template.sql\",\n- \"title\": \"Select SQL Template\",\n+ \"title\": \"Select SQL\",\n\"category\": \"MySQL\"\n},\n{\n\"command\": \"mysql.template.delete\",\n- \"title\": \"Delete SQL Template\",\n+ \"title\": \"Delete SQL\",\n\"category\": \"MySQL\"\n},\n{\n},\n{\n\"command\": \"mysql.copy.insert\",\n- \"title\": \"Insert SQL Template\",\n+ \"title\": \"Insert SQL\",\n\"category\": \"MySQL\"\n},\n{\n\"command\": \"mysql.copy.update\",\n- \"title\": \"Update SQL Template\",\n+ \"title\": \"Update SQL\",\n\"category\": \"MySQL\"\n},\n{\n},\n{\n\"command\": \"mysql.changeTableName\",\n- \"title\": \"Change Table Name\",\n+ \"title\": \"Change Name\",\n\"category\": \"MySQL\",\n\"icon\": {\n\"light\": \"resources/light/edit.svg\",\n},\n{\n\"command\": \"mysql.index.template\",\n- \"title\": \"Index Manage Template\",\n+ \"title\": \"Index Manage\",\n\"category\": \"MySQL\"\n},\n{\n},\n{\n\"command\": \"mysql.column.add\",\n- \"title\": \"Add Column Template\",\n+ \"title\": \"Add Column\",\n\"category\": \"MySQL\"\n},\n{\n\"command\": \"mysql.column.update\",\n- \"title\": \"Modify Column Template\",\n+ \"title\": \"Modify Column\",\n\"category\": \"MySQL\"\n},\n{\n\"command\": \"mysql.column.drop\",\n- \"title\": \"Drop column Template\",\n+ \"title\": \"Drop column\",\n\"category\": \"MySQL\"\n},\n{\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n\"group\": \"1_inline@1\"\n},\n+\n+ {\n+ \"command\": \"mysql.column.add\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == table\",\n+ \"group\": \"1_inline@2\"\n+ },\n{\n\"command\": \"mysql.copy.insert\",\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n\"when\": \"view == github.cweijan.mysql && viewItem == column\",\n\"group\": \"inline\"\n},\n- {\n- \"command\": \"mysql.column.add\",\n- \"when\": \"view == github.cweijan.mysql && viewItem == column\",\n- \"group\": \"1_mysql@0\"\n- },\n- {\n- \"command\": \"mysql.column.update\",\n- \"when\": \"view == github.cweijan.mysql && viewItem == column\",\n- \"group\": \"2_mysql@0\"\n- },\n{\n\"command\": \"mysql.column.drop\",\n\"when\": \"view == github.cweijan.mysql && viewItem == column\",\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "@@ -198,8 +198,8 @@ where \\`${data.primaryKey}\\`='#2' `\nvue.result.costTime=data.costTime\n}\nif(data.data!=null){\n- vue.result.data=data.data;\nvue.widthCache = {}\n+ vue.result.data=data.data;\nvue.loading = false\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -80,8 +80,8 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.changeColumnName\", (columnNode: ColumnNode) => {\ncolumnNode.changeColumnName()\n}),\n- vscode.commands.registerCommand(\"mysql.column.add\", (columnNode: ColumnNode) => {\n- columnNode.addColumnTemplate()\n+ vscode.commands.registerCommand(\"mysql.column.add\", (tableNode: TableNode) => {\n+ tableNode.addColumnTemplate()\n}),\nvscode.commands.registerCommand(\"mysql.column.update\", (columnNode: ColumnNode) => {\ncolumnNode.updateColumnTemplate()\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/columnNode.ts",
"new_path": "src/model/table/columnNode.ts",
"diff": "@@ -66,17 +66,13 @@ export class ColumnNode implements INode, IConnection {\n})\n}\n- addColumnTemplate() {\n- ConnectionManager.getConnection(this, true)\n- QueryUnit.createSQLTextDocument(`ALTER TABLE \\`${this.database}\\`.\\`${this.table}\\` ADD COLUMN columnName columnType NOT NULL comment '';`);\n- }\nupdateColumnTemplate() {\nConnectionManager.getConnection(this, true)\n- QueryUnit.showSQLTextDocument(`ALTER TABLE \\`${this.database}\\`.\\`${this.table}\\` CHANGE \\`${this.column.COLUMN_NAME}\\` \\`${this.column.COLUMN_NAME}\\` ${this.column.COLUMN_TYPE} NOT NULL comment '${this.column.COLUMN_COMMENT}';`);\n+ QueryUnit.showSQLTextDocument(`ALTER TABLE \\n\\t\\`${this.database}\\`.\\`${this.table}\\` CHANGE \\`${this.column.COLUMN_NAME}\\` \\`${this.column.COLUMN_NAME}\\` ${this.column.COLUMN_TYPE} NOT NULL comment '${this.column.COLUMN_COMMENT}';`);\n}\ndropColumnTemplate() {\nConnectionManager.getConnection(this, true)\n- QueryUnit.createSQLTextDocument(`ALTER TABLE \\`${this.database}\\`.\\`${this.table}\\` DROP COLUMN \\`${this.column.COLUMN_NAME}\\`;`);\n+ QueryUnit.createSQLTextDocument(`ALTER TABLE \\n\\t\\`${this.database}\\`.\\`${this.table}\\` DROP COLUMN \\`${this.column.COLUMN_NAME}\\`;`);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -58,6 +58,14 @@ export class TableNode implements INode, IConnection {\n});\n}\n+ public addColumnTemplate() {\n+ ConnectionManager.getConnection(this, true)\n+ QueryUnit.createSQLTextDocument(`ALTER TABLE\n+ \\`${this.database}\\`.\\`${this.table}\\`\n+ADD\n+ COLUMN [column] [type] NOT NULL comment '';`);\n+ }\n+\npublic changeTableName() {\n@@ -133,9 +141,9 @@ export class TableNode implements INode, IConnection {\n.getChildren()\n.then((children: INode[]) => {\nconst childrenNames = children.map((child: any) => child.column.COLUMN_NAME);\n- let sql = `insert into ${this.database}.{this.table}\\n`\n+ let sql = `insert into \\n\\t${this.database}.${this.table} `\nsql += `(${childrenNames.toString().replace(/,/g, \", \")})\\n`\n- sql += \"values\\n\"\n+ sql += \"values\\n\\t\"\nsql += `('${childrenNames.toString().replace(/,/g, \", \")}');`\nQueryUnit.createSQLTextDocument(sql);\n});\n@@ -149,8 +157,8 @@ export class TableNode implements INode, IConnection {\nconst where = keysNames.map((name: string) => `${name} = ${name}`);\n- let sql = `delete from ${this.database}.${this.table} \\n`;\n- sql += `where ${where.toString().replace(/,/g, \"\\n and \")}`\n+ let sql = `delete from \\n\\t${this.database}.${this.table} \\n`;\n+ sql += `where \\n\\t${where.toString().replace(/,/g, \"\\n and \")}`\nQueryUnit.createSQLTextDocument(sql)\n});\n}\n@@ -165,8 +173,8 @@ export class TableNode implements INode, IConnection {\nconst sets = childrenNames.map((name: string) => `${name} = ${name}`);\nconst where = keysNames.map((name: string) => `${name} = '${name}'`);\n- let sql = `update ${this.database}.${this.table} \\nset ${sets.toString().replace(/,/g, \"\\n , \")}\\n`;\n- sql += `where ${where.toString().replace(/,/g, \"\\n and \")}`\n+ let sql = `update \\n\\t${this.database}.${this.table} \\nset \\n\\t${sets.toString().replace(/,/g, \",\\n \")}\\n`;\n+ sql += `where \\n\\t${where.toString().replace(/,/g, \"\\n and \")}`\nQueryUnit.createSQLTextDocument(sql)\n});\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
beautify sql format
|
141,908 |
06.04.2020 21:07:25
| -28,800 |
08b48059c2fea68d613082a5a03a97389be563f1
|
update to 1.6.40
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"name\": \"vscode-mysql-manager\",\n\"displayName\": \"MySQL\",\n\"description\": \"MySQL management tool\",\n- \"version\": \"1.6.37\",\n+ \"version\": \"1.6.40\",\n\"publisher\": \"cweijan\",\n\"icon\": \"logo.png\",\n\"engines\": {\n"
},
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<el-input v-model=\"search\" style=\"width:200px\" placeholder=\"Type to search\" />\n</el-cow>\n<el-cow>\n- <el-button type=\"danger\" @click='execute'>Execute</el-button>\n+ <el-button type=\"primary\" @click='execute'>Execute</el-button>\n</el-cow>\n<el-cow>\n<span>costTime: </span><span v-text=\"result.costTime\"></span>ms,\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
update to 1.6.40
|
141,908 |
07.04.2020 17:36:47
| -28,800 |
adbef79f782312eb85d4dc0b5d556a5bd6ca42d2
|
fix multi connection error
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/ConnectionManager.ts",
"new_path": "src/database/ConnectionManager.ts",
"diff": "@@ -8,7 +8,7 @@ import { QueryUnit } from \"./QueryUnit\";\nexport class ConnectionManager {\nprivate static lastConnectionOption: IConnection;\n- private static activeConnection: any;\n+ private static activeConnection={};\npublic static getLastConnectionOption() {\nreturn this.lastConnectionOption\n@@ -30,9 +30,10 @@ export class ConnectionManager {\nconnectionOptions.multipleStatements = true\nthis.lastConnectionOption = connectionOptions\nif (changeActive) Global.updateStatusBarItems(connectionOptions);\n+ const key = `${connectionOptions.host}_${connectionOptions.port}_${connectionOptions.user}_${connectionOptions.password}`\nreturn new Promise((resolve, reject) => {\n- let connection = this.activeConnection\n+ let connection = this.activeConnection[key]\nif (connection && connection.state == 'authenticated') {\nif (connectionOptions.database) {\nQueryUnit.queryPromise(connection, `use \\`${connectionOptions.database}\\``).then(() => {\n@@ -44,8 +45,8 @@ export class ConnectionManager {\nresolve(connection)\n}\n} else {\n- this.activeConnection = this.createConnection(connectionOptions);\n- this.activeConnection.connect((err: Error) => {\n+ this.activeConnection[key] = this.createConnection(connectionOptions);\n+ this.activeConnection[key].connect((err: Error) => {\nif (!err) {\nresolve(this.activeConnection);\n} else {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
fix multi connection error
|
141,908 |
09.04.2020 00:32:23
| -28,800 |
902b4ed2dbcb29f934cb2a0684988e0445793cfe
|
implement delete in page
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<div id=\"app\">\n<div class=\"hint\">\n<el-row style=\"margin-bottom: 10px;\">\n- <el-input type=\"textarea\" autosize v-model=\"result.sql\" style=\"width: 600px;\"></el-input>\n+ <el-input type=\"textarea\" autosize v-model=\"activeSql\" style=\"width: 600px;\"></el-input>\n</el-row>\n<el-row>\n<el-cow>\n<el-button v-if=\"result.primaryKey&&scope.row[result.primaryKey]\" @click=\"openEdit(scope.row)\"\ntype=\"text\" size=\"small\">Edit</el-button>\n<el-button v-if=\"result.primaryKey&&scope.row[result.primaryKey]\"\n- @click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"text\" size=\"small\">Delete</el-button>\n+ @click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"text\" size=\"small\">Delete\n+ </el-button>\n</template>\n</el-table-column>\n<!-- table view -->\nresult: previousState ? previousState.result : {\ndata: [],\nsql: '',\n- lastSql: '',\ncostTime: 0\n},\ntableWidth: null,\nsearch: '',\ndialogVisible: false,\nloading: true,\n+ activeSql: null,\n+ optSql: null,\nupdate: {\nsql: null,\nwhere: 'w',\ncancelButtonText: 'Cancel',\ntype: 'warning'\n}).then(() => {\n- const deleteSql=`delete from ${this.result.table} where ${this.result.primaryKey}='${primaryValue}'`;\n- this.$message({ type: 'success', message: deleteSql });\n- // this.$message({ type: 'success', message: 'Delete completed' });\n+ this.optSql = `delete from ${this.result.table} where ${this.result.primaryKey}='${primaryValue}'`;\n+ this.execute(this.optSql)\n}).catch(() => {\nthis.$message({ type: 'info', message: 'Delete canceled' });\n});\n// this.update.sql=row[this.result.primaryKey]\n}\n},\n- execute() {\n+ refresh(){\n+ if(this.result){\n+ this.execute(this.result.sql)\n+ }\n+ },\n+ execute(sql) {\n+ if (!sql ) sql = this.activeSql\nvscode.postMessage({\ntype: 'execute',\n- sql: this.result.sql\n+ sql: sql\n});\n- if (!this.result.sql.match(/^(alter|create|drop|delete|update|insert)/ig)) {\nthis.loading = true;\n- }\n},\ndeleteTemplate() {\nthis.result.sql = `DELETE FROM [table] WHERE id= `;\n}\n})\n- window.addEventListener('message', event => {\n-\n- let data = event.data;\n+ const handlerData = (data) => {\nif (data.primaryKey && data.database && data.table) {\nvue.update.sql = `update \\`${data.database}\\`.\\`${data.table}\\`\nset #1\n@@ -227,7 +230,7 @@ where \\`${data.primaryKey}\\`='#2' `\n}\nif (data.sql) {\nvue.result.sql = data.sql;\n- vue.result.lastSql = data.sql;\n+ vue.activeSql = data.sql;\nvue.result.costTime = 0;\nvue.loading = true\n}\n@@ -242,6 +245,26 @@ where \\`${data.primaryKey}\\`='#2' `\n// instead by retainContextWhenHidden=true\n// vscode.setState({ result: vue.result });\n+ }\n+\n+ const optDone = () => {\n+ vue.$message({ type: 'success', message: `execute ${vue.optSql} success!` });\n+ vue.refresh()\n+ }\n+\n+ window.addEventListener('message', event => {\n+ let type = event.data.type\n+ vue.loading = false;\n+ switch (event.data.type) {\n+ case \"data\":\n+ handlerData(event.data)\n+ break;\n+ case \"opt\":\n+ optDone()\n+ break;\n+ default:\n+ vue.$message({ type: 'success', message: JSON.stringify(event.data) });\n+ }\n});\nvscode.postMessage({ type: 'init' })\n</script>\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "resources/webview/test.html",
"diff": "+<html>\n+\n+<head>\n+ <title>result</title>\n+ <link rel=\"stylesheet\" href=\"css/element.css\">\n+ <script src=\"js/vue.js\"></script>\n+ <script src=\"js/element.js\"></script>\n+</head>\n+\n+<body>\n+ <div id=\"app\">\n+ <el-table :data=\"tableData\" style=\"width: 100%\" height=\"250\" @cell-click=\"celledit\">\n+ <el-table-column fixed prop=\"date\" label=\"Date\" width=\"150\"> </el-table-column>\n+ <el-table-column prop=\"name\" label=\"Name\" width=\"120\"> </el-table-column>\n+ <el-table-column prop=\"state\" label=\"State\" width=\"120\"> </el-table-column>\n+ <el-table-column prop=\"city\" label=\"City\" width=\"120\"> </el-table-column>\n+ <el-table-column prop=\"address\" label=\"Address\" width=\"300\"> </el-table-column>\n+ <el-table-column prop=\"zip\" label=\"Zip\" width=\"120\"> </el-table-column>\n+ </el-table>\n+ </div>\n+</body>\n+<script>\n+ const vue = new Vue({\n+ el: '#app',\n+ methods: {\n+ celledit(row, column, cell, event) {\n+ cell.contentEditable = true;\n+ }\n+ },\n+ data: {\n+ tableData: [{\n+ date: '2016-05-03', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }, {\n+ date: '2016-05-02', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }, {\n+ date: '2016-05-04', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }, {\n+ date: '2016-05-01', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }, {\n+ date: '2016-05-08', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }, {\n+ date: '2016-05-06', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }, {\n+ date: '2016-05-07', name: 'Tom', state: 'California', city: 'Los Angeles', address: 'No. 189, Grove St, Los Angeles', zip: 'CA 90036'\n+ }]\n+ }\n+ })\n+</script>\n+\n+</html>\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/constants.ts",
"new_path": "src/common/constants.ts",
"diff": "@@ -44,6 +44,14 @@ export class ModelType{\n}\n+export class MessageType{\n+ static data='data';\n+ /**\n+ * dml and ddl\n+ */\n+ static opt='opt';\n+}\n+\nexport class OperateType{\nstatic execute='execute';\nstatic init='init';\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/SqlViewManager.ts",
"new_path": "src/database/SqlViewManager.ts",
"diff": "import * as fs from \"fs\";\nimport * as vscode from \"vscode\";\nimport { WebviewPanel } from \"vscode\";\n-import { OperateType } from \"../common/Constants\";\n+import { OperateType, MessageType } from \"../common/Constants\";\nimport { Console } from \"../common/OutputChannel\";\nimport { IConnection } from \"../model/Connection\";\nimport { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\nimport { ConnectionManager } from \"./ConnectionManager\";\nimport { DatabaseCache } from \"./DatabaseCache\";\nimport { ColumnNode } from \"../model/table/columnNode\";\n+import { QueryUnit } from \"./QueryUnit\";\n\"use strict\";\nexport class ViewOption {\n@@ -51,6 +52,7 @@ export class SqlViewManager {\nviewOption.extra['database'] = opt.database\nviewOption.extra['table'] = tableName\n}\n+ viewOption.extra['type'] = MessageType.data\nthis.sendData = viewOption.extra\nif (this.creating) return;\n// update result webview\n@@ -79,7 +81,12 @@ export class SqlViewManager {\nwebviewPanel.webview.postMessage(SqlViewManager.sendData)\nbreak;\ncase OperateType.execute:\n- vscode.commands.executeCommand('mysql.runQuery', params.sql)\n+ QueryUnit.runQuery(params.sql).then(isDDL => {\n+ if (isDDL) {\n+ SqlViewManager.sendData['type']=MessageType.opt\n+ webviewPanel.webview.postMessage(SqlViewManager.sendData)\n+ }\n+ })\nbreak;\n}\n})\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
implement delete in page
|
141,908 |
09.04.2020 11:01:40
| -28,800 |
3f9cef17a40ef1c522cc3f0ad09a8b893ceacaf4
|
add show table source
|
[
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "\"title\": \"Add Column\",\n\"category\": \"MySQL\"\n},\n+ {\n+ \"command\": \"mysql.table.source\",\n+ \"title\": \"Show table source\",\n+ \"category\": \"MySQL\"\n+ },\n{\n\"command\": \"mysql.column.update\",\n\"title\": \"Modify Column\",\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n\"group\": \"1_inline@1\"\n},\n-\n{\n\"command\": \"mysql.column.add\",\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n\"group\": \"1_inline@2\"\n},\n+ {\n+ \"command\": \"mysql.table.source\",\n+ \"when\": \"view == github.cweijan.mysql && viewItem == table\",\n+ \"group\": \"1_inline@3\"\n+ },\n{\n\"command\": \"mysql.copy.insert\",\n\"when\": \"view == github.cweijan.mysql && viewItem == table\",\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -77,6 +77,9 @@ export function activate(context: vscode.ExtensionContext) {\nvscode.commands.registerCommand(\"mysql.table.drop\", (tableNode: TableNode) => {\ntableNode.dropTable()\n}),\n+ vscode.commands.registerCommand(\"mysql.table.source\", (tableNode: TableNode) => {\n+ if(tableNode) tableNode.showSource()\n+ }),\nvscode.commands.registerCommand(\"mysql.changeColumnName\", (columnNode: ColumnNode) => {\ncolumnNode.changeColumnName()\n}),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableGroup.ts",
"new_path": "src/model/table/tableGroup.ts",
"diff": "@@ -52,7 +52,7 @@ export class TableGroup implements INode, IConnection {\ncreateTemplate() {\nConnectionManager.getConnection(this, true)\nQueryUnit.createSQLTextDocument(`CREATE TABLE tableName(\n- id long NOT NULL primary key AUTO_INCREMENT,\n+ id int NOT NULL primary key AUTO_INCREMENT,\ncolumn varchar(length)\n);`)\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -15,6 +15,7 @@ import { MySQLTreeDataProvider } from \"../../provider/MysqlTreeDataProvider\";\nexport class TableNode implements INode, IConnection {\n+\nidentify: string;\ntype: string = ModelType.TABLE;\n@@ -67,6 +68,13 @@ ADD\n}\n+ async showSource() {\n+ QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this,true), `SHOW CREATE TABLE \\`${this.database}\\`.\\`${this.table}\\``)\n+ .then((procedDtail) => {\n+ QueryUnit.showSQLTextDocument(procedDtail[0]['Create Table']);\n+ });\n+ }\n+\npublic changeTableName() {\nvscode.window.showInputBox({ value: this.table, placeHolder: 'newTableName', prompt: `You will changed ${this.database}.${this.table} to new table name!` }).then(async newTableName => {\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -15,7 +15,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nprivate defaultComplectionItems: vscode.CompletionItem[] = []\nprivate tableKeywordList: string[] = [\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\"]\nprivate tableKeywordComplectionItems: vscode.CompletionItem[] = []\n- private typeList: string[] = [\"INTEGER\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"long\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"]\n+ private typeList: string[] = [\"INTEGER\",\"char\",\"varchar\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"long\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"]\nprivate typeComplectionItems: vscode.CompletionItem[] = []\nprivate initDefaultComplectionItem() {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
add show table source
|
141,908 |
09.04.2020 11:19:04
| -28,800 |
9fc4c029adb5547b461d62e755e270f307bd4b74
|
template sql format
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -148,11 +148,11 @@ ADD\nthis\n.getChildren()\n.then((children: INode[]) => {\n- const childrenNames = children.map((child: any) => child.column.COLUMN_NAME);\n- let sql = `insert into \\n\\t${this.database}.${this.table} `\n- sql += `(${childrenNames.toString().replace(/,/g, \", \")})\\n`\n- sql += \"values\\n\\t\"\n- sql += `('${childrenNames.toString().replace(/,/g, \", \")}');`\n+ const childrenNames = children.map((child: any) => \"\\n \"+child.column.COLUMN_NAME);\n+ let sql = `insert into \\n \\`${this.database}\\`.${this.table} `\n+ sql += `(${childrenNames.toString().replace(/,/g, \", \")}\\n )\\n`\n+ sql += \"values\\n \"\n+ sql += `(${childrenNames.toString().replace(/,/g, \", \")}\\n );`\nQueryUnit.createSQLTextDocument(sql);\n});\n}\n@@ -165,8 +165,8 @@ ADD\nconst where = keysNames.map((name: string) => `${name} = ${name}`);\n- let sql = `delete from \\n\\t${this.database}.${this.table} \\n`;\n- sql += `where \\n\\t${where.toString().replace(/,/g, \"\\n and \")}`\n+ let sql = `delete from \\n \\`${this.database}\\`.${this.table} \\n`;\n+ sql += `where \\n ${where.toString().replace(/,/g, \"\\n and\")}`\nQueryUnit.createSQLTextDocument(sql)\n});\n}\n@@ -181,8 +181,8 @@ ADD\nconst sets = childrenNames.map((name: string) => `${name} = ${name}`);\nconst where = keysNames.map((name: string) => `${name} = '${name}'`);\n- let sql = `update \\n\\t${this.database}.${this.table} \\nset \\n\\t${sets.toString().replace(/,/g, \",\\n \")}\\n`;\n- sql += `where \\n\\t${where.toString().replace(/,/g, \"\\n and \")}`\n+ let sql = `update \\n \\`${this.database}\\`.${this.table} \\nset \\n ${sets.toString().replace(/,/g, \",\\n \")}\\n`;\n+ sql += `where \\n ${where.toString().replace(/,/g, \"\\n and \")}`\nQueryUnit.createSQLTextDocument(sql)\n});\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
template sql format
|
141,908 |
09.04.2020 12:42:13
| -28,800 |
02679c4b31d3b257144aa625ca4d27fa1d053be8
|
alias inference
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": ":data=\"result.data.filter(data => !search || JSON.stringify(data).toLowerCase().includes(search.toLowerCase()))\"\nborder @cell-click=\"celledit\">\n<!-- tool bar -->\n- <el-table-column fixed=\"left\" label=\"Operations\" width=\"120\">\n+ <el-table-column fixed=\"left\" label=\"Operations\" width=\"120\" v-if=\"result.primaryKey\">\n<template slot-scope=\"scope\">\n- <el-button v-if=\"result.primaryKey&&scope.row[result.primaryKey]\" @click=\"openEdit(scope.row)\"\n+ <el-button @click=\"openEdit(scope.row)\"\ntype=\"text\" size=\"small\">Edit</el-button>\n- <el-button v-if=\"result.primaryKey&&scope.row[result.primaryKey]\"\n+ <el-button\n@click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"text\" size=\"small\">Delete\n</el-button>\n</template>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/common/outputChannel.ts",
"new_path": "src/common/outputChannel.ts",
"diff": "@@ -3,9 +3,13 @@ import * as vscode from \"vscode\";\nexport class Console {\npublic static log(value: Object) {\n- Console.outputChannel.show(true);\n- Console.outputChannel.appendLine(value+\"\");\n+ if(this.outputChannel==null){\n+ this.outputChannel = vscode.window.createOutputChannel(\"MySQL\");\n+ }\n+ this.outputChannel.show(true);\n+ this.outputChannel.appendLine(value+\"\");\n+ this.outputChannel.appendLine(\"-----------------------------------------------------------------------------------------\");\n}\n- private static outputChannel = vscode.window.createOutputChannel(\"MySQL\");\n+ private static outputChannel:vscode.OutputChannel;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -10,12 +10,12 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nconstructor() {\nthis.initDefaultComplectionItem()\n}\n- private keywordList: string[] = [\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n+ private keywordList: string[] = [\"JOIN\",\"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\nprivate functionList: string[] = [\"decimal\", \"char\", \"varchar\", \"CHAR_LENGTH\", \"CONCAT\", \"NOW\", \"DATE_ADD\", \"DATE_SUB\", \"MAX\", \"COUNT\", \"MIN\", \"SUM\", \"AVG\", \"LENGTH\", \"IF\", \"IFNULL\", \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\"]\nprivate defaultComplectionItems: vscode.CompletionItem[] = []\nprivate tableKeywordList: string[] = [\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\"]\nprivate tableKeywordComplectionItems: vscode.CompletionItem[] = []\n- private typeList: string[] = [\"INTEGER\",\"char\",\"varchar\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"long\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"]\n+ private typeList: string[] = [\"INTEGER\", \"char\", \"varchar\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"]\nprivate typeComplectionItems: vscode.CompletionItem[] = []\nprivate initDefaultComplectionItem() {\n@@ -76,11 +76,11 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nif (subComplectionItems.length == 0) {\nsubComplectionItems = await CompletionProvider.generateColumnComplectionItem(inputWord)\nif (subComplectionItems.length == 0) {\n- let tableReg = new RegExp(\"\\\\w+(?=\\\\s*\\\\b\" + inputWord + \"\\\\b)\", 'ig')\n+ let tableReg = new RegExp(\"`{0,1}(\\\\w|-)+`{0,1}(?=\\\\s*\\\\b\" + inputWord + \"\\\\b)\", 'ig')\nlet currentSql = document.getText();\nlet result = tableReg.exec(currentSql)\nfor (; result != null && subComplectionItems.length == 0;) {\n- subComplectionItems = await CompletionProvider.generateColumnComplectionItem(result[0])\n+ subComplectionItems = await CompletionProvider.generateColumnComplectionItem(result[0].replace(/`/ig,\"\"))\nresult = tableReg.exec(currentSql)\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "syntaxes/mysql.tmLanguage.json",
"new_path": "syntaxes/mysql.tmLanguage.json",
"diff": "},\n\"comment\": \"this is faster than the next begin/end rule since sub-pattern will match till end-of-line and SQL files tend to have very long lines.\",\n\"match\": \"(`)[^`\\\\\\\\]*(`)\",\n- \"name\": \"string.quoted.other.backtick.sql\"\n+ \"name\": \"support.function.table.sql\"\n},\n{\n\"begin\": \"`\",\n\"name\": \"punctuation.definition.string.end.sql\"\n}\n},\n- \"name\": \"string.quoted.other.backtick.sql\",\n+ \"name\": \"support.function.table.sql\",\n\"patterns\": [\n{\n\"include\": \"#string_escape\"\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
alias inference
|
141,908 |
09.04.2020 14:01:11
| -28,800 |
3ca1c3c034c5b8073330852f3fcbeaee64613344
|
preparing edit
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": ":data=\"result.data.filter(data => !search || JSON.stringify(data).toLowerCase().includes(search.toLowerCase()))\"\nborder @cell-click=\"celledit\">\n<!-- tool bar -->\n- <el-table-column fixed=\"left\" label=\"Operations\" width=\"120\" v-if=\"result.primaryKey\">\n+ <el-table-column fixed=\"left\" label=\"Operations\" width=\"100\" v-if=\"result.primaryKey\">\n<template slot-scope=\"scope\">\n- <el-button @click=\"openEdit(scope.row)\"\n- type=\"text\" size=\"small\">Edit</el-button>\n- <el-button\n- @click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"text\" size=\"small\">Delete\n+ <el-button @click=\"openEdit(scope.row,scope.$index)\" type=\"text\" size=\"small\">Edit</el-button>\n+ <el-button @click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"text\" size=\"small\">Delete\n</el-button>\n</template>\n</el-table-column>\n</el-table>\n</div>\n- <el-dialog title=\"Tips\" :visible.sync=\"dialogVisible\" width=\"30%\" :before-close=\"handleClose\">\n- <span>This is a message</span>\n+ <el-dialog title=\"Line Date Edit\" :visible.sync=\"dialogVisible\" width=\"30%\" :before-close=\"handleClose\">\n+ <el-form label-width=\"80px\" :model=\"update.currentNew\">\n+ <el-form-item :label=\"column\" :key=\"column\" v-for=\"column in result.columnList\">\n+ <el-input :model=\"update.currentNew[column]\"></el-input>\n+ </el-form-item>\n+ </el-form>\n<span slot=\"footer\" class=\"dialog-footer\">\n<el-button @click=\"dialogVisible = false\">Cancel</el-button>\n- <el-button type=\"primary\" @click=\"dialogVisible = false\">Confirm</el-button>\n+ <el-button type=\"primary\" @click=\"confirmUpdate\">Confirm</el-button>\n</span>\n</el-dialog>\n</div>\nactiveSql: null,\noptSql: null,\nupdate: {\n- sql: null,\n- where: 'w',\n- primary: 'p'\n+ primary: null,\n+ rowNum: -1,\n+ currentNew: {}\n}\n},\nmethods: {\n- openEdit(row) {\n+ confirmUpdate(){\n+ // const updateSql = `update \\`${data.database}\\`.\\`${data.table}\\`\n+ // set #1\n+ // where \\`${data.primaryKey}\\`='#2' `\n+ // this.dialogVisible = false\n+ this.update.currentNew = this.result.row[this.update.rowNum]\n+ },\n+ openEdit(row, index) {\nthis.dialogVisible = true;\n+ this.update.rowNum = index\n+ this.update.primary = row[this.result.primaryKey]\n+ //TODO maybe need clone\n+ this.update.currentNew = this.result.row[this.update.rowNum]\n},\ndeleteConfirm(primaryValue) {\nthis.$confirm('Are you sure you want to delete this data?', 'Warning', {\nfor (const key in this.widthCache) {\nwidth = width + parseInt(this.widthCache[key])\n}\n+ if (this.result.primaryKey) {\n+ width += 60;\n+ }\nthis.tableWidth = width + 60;\n+\n},\ncomputeWidth(key, index) {\n},\ncelledit(row, column, cell, event) {\ncell.contentEditable = true;\n- // cell.focus()\nif (this.result.primaryKey) {\nthis.update.primary = row[this.result.primaryKey]\n- // this.update.sql=row[this.result.primaryKey]\n}\n},\nrefresh() {\ncolumnCount() {\nif (this.result.data == undefined || this.result.data[0] == undefined) return 0;\nreturn Object.keys(this.result.data[0]).length;\n- }, updateSql() {\n- if (this.update.sql && this.update.where) {\n- return this.update.sql.replace('#1', this.update.where).replace('#2', this.update.primary)\n- }\n- return null;\n}\n}\n})\nconst handlerData = (data) => {\n- if (data.primaryKey && data.database && data.table) {\n- vue.update.sql = `update \\`${data.database}\\`.\\`${data.table}\\`\n-set #1\n-where \\`${data.primaryKey}\\`='#2' `\n- }\nif (data.sql) {\nvue.result.sql = data.sql;\nvue.activeSql = data.sql;\n@@ -242,13 +247,12 @@ where \\`${data.primaryKey}\\`='#2' `\nvue.result = data;\nvue.loading = false\n}\n-\n// instead by retainContextWhenHidden=true\n// vscode.setState({ result: vue.result });\n}\nconst optDone = () => {\n- vue.$message({ type: 'success', message: `execute ${vue.optSql} success!` });\n+ vue.$message({ type: 'success', message: `EXECUTE ${vue.optSql} SUCCESS!` });\nvue.refresh()\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
preparing edit
|
141,908 |
09.04.2020 20:51:44
| -28,800 |
6aca5a84f9cb467be40999bb69914f57efc2b937
|
support edit in result page
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<div id=\"app\">\n<div class=\"hint\">\n<el-row style=\"margin-bottom: 10px;\">\n- <el-input type=\"textarea\" autosize v-model=\"activeSql\" style=\"width: 600px;\"></el-input>\n+ <el-input type=\"textarea\" autosize v-model=\"toolbar.sql\" style=\"width: 600px;\"></el-input>\n</el-row>\n<el-row>\n<el-cow>\n- <el-input v-model=\"search\" style=\"width:200px\" placeholder=\"Type to search\" />\n+ <el-input v-model=\"table.search\" style=\"width:200px\" placeholder=\"Type to search\" />\n</el-cow>\n<el-cow>\n<el-button type=\"primary\" @click='execute'>Execute</el-button>\nstyle=\"width: 600px;\"></el-input>\n</el-row> -->\n</div>\n- <div :style=\"'width:' + tableWidth + 'px;overflow:scroll'\">\n- <el-table id=\"dataTable\" v-loading='loading' size='small'\n- :data=\"result.data.filter(data => !search || JSON.stringify(data).toLowerCase().includes(search.toLowerCase()))\"\n+ <div :style=\"'width:' + table.width + 'px;overflow:scroll'\">\n+ <el-table id=\"dataTable\" v-loading='table.loading' size='small'\n+ :data=\"result.data.filter(data => !table.search || JSON.stringify(data).toLowerCase().includes(table.search.toLowerCase()))\"\nborder @cell-click=\"celledit\">\n<!-- tool bar -->\n<el-table-column fixed=\"left\" label=\"Operations\" width=\"100\" v-if=\"result.primaryKey\">\n<template slot-scope=\"scope\">\n- <el-button @click=\"openEdit(scope.row,scope.$index)\" type=\"text\" size=\"small\">Edit</el-button>\n+ <el-button @click=\"openEdit(scope.row)\" type=\"text\" size=\"small\">Edit</el-button>\n<el-button @click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"text\" size=\"small\">Delete\n</el-button>\n</template>\n</el-table>\n</div>\n- <el-dialog title=\"Line Date Edit\" :visible.sync=\"dialogVisible\" width=\"30%\" :before-close=\"handleClose\">\n- <el-form label-width=\"80px\" :model=\"update.currentNew\">\n+ <el-dialog title=\"Line Date Edit\" :visible.sync=\"editor.visible\" width=\"70%\" :before-close=\"handleClose\">\n+ <el-form label-width=\"120px\">\n<el-form-item :label=\"column\" :key=\"column\" v-for=\"column in result.columnList\">\n- <el-input :model=\"update.currentNew[column]\"></el-input>\n+ <el-input v-model=\"update.currentNew[column]\"></el-input>\n</el-form-item>\n</el-form>\n<span slot=\"footer\" class=\"dialog-footer\">\n- <el-button @click=\"dialogVisible = false\">Cancel</el-button>\n+ <el-button @click=\"editor.visible = false\">Cancel</el-button>\n<el-button type=\"primary\" @click=\"confirmUpdate\">Confirm</el-button>\n</span>\n</el-dialog>\nconst vue = new Vue({\nel: '#app',\ndata: {\n- result: previousState ? previousState.result : {\n+ result: {\ndata: [],\nsql: '',\n- costTime: 0\n+ costTime: 0,\n+ primaryKey: null,\n+ columnList: null,\n+ database: null,\n+ table: null\n},\n- tableWidth: null,\n- widthCache: {},\n+ optSql: null,\n+ table: {\nsearch: '',\n- dialogVisible: false,\nloading: true,\n- activeSql: null,\n- optSql: null,\n+ width: null,\n+ widthItem: {}\n+ },\n+ toolbar: {\n+ sql: null,\n+ },\n+ editor: {\n+ visible: false,\n+ },\nupdate: {\n- primary: null,\n- rowNum: -1,\n- currentNew: {}\n+ current: {},\n+ currentNew: {},\n+ primary: null\n}\n-\n},\nmethods: {\nconfirmUpdate() {\n- // const updateSql = `update \\`${data.database}\\`.\\`${data.table}\\`\n- // set #1\n- // where \\`${data.primaryKey}\\`='#2' `\n- // this.dialogVisible = false\n- this.update.currentNew = this.result.row[this.update.rowNum]\n+ let change = \"\";\n+ for (const key in this.update.currentNew) {\n+ const oldEle = this.update.current[key];\n+ const newEle = this.update.currentNew[key];\n+ if (oldEle != newEle) {\n+ change += `${key}='${newEle}',`\n+ }\n+ }\n+ if (change) {\n+ this.optSql = `update ${this.result.table} set ${change.replace(/,$/, \"\")} where ${this.result.primaryKey}=${this.update.primary}`\n+ this.execute(this.optSql)\n+ this.editor.visible=false\n+ } else {\n+ this.$message(\"Not any change, update fail!\")\n+\n+ }\n},\n- openEdit(row, index) {\n- this.dialogVisible = true;\n- this.update.rowNum = index\n- this.update.primary = row[this.result.primaryKey]\n- //TODO maybe need clone\n- this.update.currentNew = this.result.row[this.update.rowNum]\n+ openEdit(row) {\n+ this.editor.visible = true;\n+ this.update = {\n+ current: row,\n+ currentNew: this.deepClone(row),\n+ primary: row[this.result.primaryKey]\n+ }\n},\ndeleteConfirm(primaryValue) {\nthis.$confirm('Are you sure you want to delete this data?', 'Warning', {\n},\nupdateWidth() {\nlet width = 0;\n- for (const key in this.widthCache) {\n- width = width + parseInt(this.widthCache[key])\n+ for (const key in this.table.widthItem) {\n+ width = width + parseInt(this.table.widthItem[key])\n}\nif (this.result.primaryKey) {\nwidth += 60;\n}\n- this.tableWidth = width + 60;\n+ this.table.width = width + 60;\n},\ncomputeWidth(key, index) {\n- if (this.widthCache[key]) return this.widthCache[key];\n+ if (this.table.widthItem[key]) return this.table.widthItem[key];\nif (!index) index = 0\nif (!this.result.data[index] || index > 10) return 60;\nvar value = this.result.data[index][key];\nif (dynamic < 60) dynamic = 60;\nvar nextDynamic = this.computeWidth(key, ++index)\nif (dynamic < nextDynamic) dynamic = nextDynamic;\n- this.widthCache[key] = dynamic;\n+ this.table.widthItem[key] = dynamic;\nthis.updateWidth()\nreturn dynamic;\n},\n}\n},\nexecute(sql) {\n- if (!sql) sql = this.activeSql\n+ if (!sql) sql = this.toolbar.sql\nvscode.postMessage({\ntype: 'execute',\nsql: sql\n});\n- this.loading = true;\n+ this.table.loading = true;\n},\ndeleteTemplate() {\nthis.result.sql = `DELETE FROM [table] WHERE id= `;\nreturn \"<b>(NULL)</b>\";\n}\nreturn origin;\n+ },\n+ deepClone(obj) {\n+ let objClone = Array.isArray(obj) ? [] : {};\n+ if (obj && typeof obj === \"object\") {\n+ for (let key in obj) {\n+ if (obj.hasOwnProperty(key)) {\n+ if (obj[key] && typeof obj[key] === \"object\") {\n+ objClone[key] = this.deepClone(obj[key]);\n+ } else {\n+ objClone[key] = obj[key];\n+ }\n+ }\n+ }\n+ }\n+ return objClone;\n}\n},\ncomputed: {\nconst handlerData = (data) => {\nif (data.sql) {\nvue.result.sql = data.sql;\n- vue.activeSql = data.sql;\n+ vue.toolbar.sql = data.sql;\nvue.result.costTime = 0;\n- vue.loading = true\n+ vue.table.loading = true\n}\nif (data.costTime) {\nvue.result.costTime = data.costTime\n}\nif (data.data != null) {\n- vue.widthCache = {}\n+ vue.table.widthItem = {}\nvue.result = data;\n- vue.loading = false\n+ vue.table.loading = false\n}\n// instead by retainContextWhenHidden=true\n// vscode.setState({ result: vue.result });\nwindow.addEventListener('message', event => {\nlet type = event.data.type\n- vue.loading = false;\n+ vue.table.loading = false;\nswitch (event.data.type) {\ncase \"data\":\nhandlerData(event.data)\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support edit in result page
|
141,908 |
09.04.2020 22:30:07
| -28,800 |
6fac634c9cb7dc3042212b48c33233c75db48e2f
|
refactor query communication
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<el-input v-model=\"table.search\" style=\"width:200px\" placeholder=\"Type to search\" />\n</el-cow>\n<el-cow>\n- <el-button type=\"primary\" @click='execute'>Execute</el-button>\n+ <el-button type=\"primary\" @click='execute(toolbar.sql)'>Execute</el-button>\n</el-cow>\n<el-cow>\n<span>costTime: </span><span v-text=\"result.costTime\"></span>ms,\ndatabase: null,\ntable: null\n},\n- optSql: null,\ntable: {\nsearch: '',\nloading: true,\n}\n}\nif (change) {\n- this.optSql = `update ${this.result.table} set ${change.replace(/,$/, \"\")} where ${this.result.primaryKey}=${this.update.primary}`\n- this.execute(this.optSql)\n+ const updateSql = `update ${this.result.table} set ${change.replace(/,$/, \"\")} where ${this.result.primaryKey}=${this.update.primary}`\n+ this.execute(updateSql)\nthis.editor.visible = false\n} else {\nthis.$message(\"Not any change, update fail!\")\ncancelButtonText: 'Cancel',\ntype: 'warning'\n}).then(() => {\n- this.optSql = `delete from ${this.result.table} where ${this.result.primaryKey}='${primaryValue}'`;\n- this.execute(this.optSql)\n+ const deleteSql = `delete from ${this.result.table} where ${this.result.primaryKey}='${primaryValue}'`;\n+ this.execute(deleteSql)\n}).catch(() => {\n- this.$message({ type: 'info', message: 'Delete canceled' });\n+ this.$message({ type: 'info', message: 'Update canceled' });\n});\n},\nupdateWidth() {\n}\n},\nexecute(sql) {\n- if (!sql) sql = this.toolbar.sql\n+ if (!sql) return;\nvscode.postMessage({\ntype: 'execute',\nsql: sql\n})\nconst handlerData = (data) => {\n- if (data.sql) {\nvue.result.sql = data.sql;\nvue.toolbar.sql = data.sql;\n- vue.result.costTime = 0;\n- vue.table.loading = true\n- }\n- if (data.costTime) {\n- vue.result.costTime = data.costTime\n- }\n- if (data.data != null) {\nvue.table.widthItem = {}\nvue.result = data;\nvue.table.loading = false\n- }\n- // instead by retainContextWhenHidden=true\n- // vscode.setState({ result: vue.result });\n+ // vscode.setState({ result: vue.result }); is instead by retainContextWhenHidden=true\n}\n- const optDone = () => {\n- vue.$message({ type: 'success', message: `EXECUTE ${vue.optSql} SUCCESS!` });\n+ const handlerDML = (res) => {\n+ vue.$message({ type: 'success', message: `EXECUTE ${res.sql} SUCCESS, affectedRows:${res.affectedRows}` });\nvue.refresh()\n}\nwindow.addEventListener('message', event => {\n- let type = event.data.type\nvue.table.loading = false;\n+ let response = event.data.res;\nswitch (event.data.type) {\n- case \"data\":\n- handlerData(event.data)\n+ case \"RUN\":\n+ vue.toolbar.sql = response.sql;\n+ vue.table.loading = true;\n+ break;\n+ case \"DATA\":\n+ handlerData(response)\nbreak;\n- case \"opt\":\n- optDone()\n+ case \"DML\":\n+ handlerDML(response)\nbreak;\ndefault:\nvue.$message({ type: 'success', message: JSON.stringify(event.data) });\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/common/SqlViewManager.ts",
"diff": "+import * as fs from \"fs\";\n+import * as vscode from \"vscode\";\n+import { WebviewPanel } from \"vscode\";\n+import { ConnectionManager } from \"../database/ConnectionManager\";\n+import { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\n+import { Console } from \"./OutputChannel\";\n+\"use strict\";\n+\n+export class ViewOption {\n+ viewPath?: string;\n+ viewTitle?: string;\n+ splitResultView: boolean = false;\n+ /**\n+ * receive webview send message\n+ */\n+ receiveListener?: (message: any) => {}\n+\n+ disposeListener?: (message: any) => {}\n+}\n+\n+export class SqlViewManager {\n+\n+ static extensionPath: string\n+ static initExtesnsionPath(extensionPath: string) {\n+ this.extensionPath = extensionPath\n+ }\n+\n+ static showConnectPage() {\n+\n+ this.createWebviewPanel({\n+ viewPath: \"connect\",\n+ viewTitle: \"connect\",\n+ splitResultView: false\n+ }).then(webviewPanel => {\n+ webviewPanel.webview.onDidReceiveMessage((params) => {\n+ if (params.type === 'CONNECT_TO_SQL_SERVER') {\n+ ConnectionManager.getConnection(params.connectionOption).then(() => {\n+ MySQLTreeDataProvider.instance.addConnection(params.connectionOption);\n+ webviewPanel.dispose();\n+ }).catch((err: Error) => {\n+ webviewPanel.webview.postMessage({\n+ type: 'CONNECTION_ERROR',\n+ err\n+ });\n+ })\n+ }\n+ });\n+ })\n+ }\n+\n+ public static createWebviewPanel(viewOption: ViewOption): Promise<WebviewPanel> {\n+\n+ let columnType = viewOption.splitResultView ? vscode.ViewColumn.Two : vscode.ViewColumn.One\n+\n+ return new Promise((resolve, reject) => {\n+ fs.readFile(`${this.extensionPath}/resources/webview/${viewOption.viewPath}.html`, 'utf8', async (err, data) => {\n+ if (err) {\n+ Console.log(err)\n+ reject(err)\n+ return;\n+ }\n+ const webviewPanel = vscode.window.createWebviewPanel(\n+ \"mysql.sql.result\",\n+ viewOption.viewTitle,\n+ { viewColumn: columnType, preserveFocus: true },\n+ { enableScripts: true, retainContextWhenHidden: true }\n+ );\n+ webviewPanel.webview.html = data.replace(/\\$\\{webviewPath\\}/gi,\n+ vscode.Uri.file(`${this.extensionPath}/resources/webview`)\n+ .with({ scheme: 'vscode-resource' }).toString())\n+ webviewPanel.webview.onDidReceiveMessage(viewOption.receiveListener);\n+ webviewPanel.onDidDispose(viewOption.disposeListener)\n+\n+ resolve(webviewPanel)\n+ })\n+\n+ })\n+\n+ }\n+\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": "@@ -44,14 +44,14 @@ export class ModelType{\n}\n-export class MessageType{\n- static data='data';\n- /**\n- * dml and ddl\n- */\n- static opt='opt';\n+export enum MessageType {\n+ DATA = 'DATA',\n+ DML = 'DML',\n+ ERROR = \"ERROR\",\n+ RUN = \"RUN\"\n}\n+\nexport class OperateType {\nstatic execute = 'execute';\nstatic init = 'init';\n"
},
{
"change_type": "DELETE",
"old_path": "src/database/SqlViewManager.ts",
"new_path": null,
"diff": "-import * as fs from \"fs\";\n-import * as vscode from \"vscode\";\n-import { WebviewPanel } from \"vscode\";\n-import { OperateType, MessageType } from \"../common/Constants\";\n-import { Console } from \"../common/OutputChannel\";\n-import { IConnection } from \"../model/Connection\";\n-import { MySQLTreeDataProvider } from \"../provider/MysqlTreeDataProvider\";\n-import { ConnectionManager } from \"./ConnectionManager\";\n-import { DatabaseCache } from \"./DatabaseCache\";\n-import { ColumnNode } from \"../model/table/columnNode\";\n-import { QueryUnit } from \"./QueryUnit\";\n-\"use strict\";\n-\n-export class ViewOption {\n- viewPath?: string;\n- viewTitle?: string;\n- splitResultView: boolean = false;\n- extra?: any;\n- /**\n- * receive webview send message\n- */\n- receiveListener?: (message: any) => {}\n-\n- disposeListener?: (message: any) => {}\n-}\n-\n-export class SqlViewManager {\n-\n- static extensionPath: string\n- static initExtesnsionPath(extensionPath: string) {\n- this.extensionPath = extensionPath\n- }\n-\n- private static resultWebviewPanel: WebviewPanel\n- private static sendData: any;\n- private static creating = false;\n- public static async showQueryResult(viewOption: ViewOption, opt: IConnection) {\n-\n- let tableName = this.getTable(viewOption.extra)\n- // load table infomation\n- let tableNode = DatabaseCache.getTable(`${opt.host}_${opt.port}_${opt.user}_${opt.database}`, tableName)\n- if (tableNode) {\n- let primaryKey: string;\n- let columnList = (await tableNode.getChildren()).map((columnNode: ColumnNode) => {\n- if (columnNode.column.COLUMN_KEY === \"PRI\") {\n- primaryKey = columnNode.column.COLUMN_NAME\n- }\n- return columnNode.column.COLUMN_NAME\n- })\n- viewOption.extra['primaryKey'] = primaryKey\n- viewOption.extra['columnList'] = columnList\n- viewOption.extra['database'] = opt.database\n- viewOption.extra['table'] = tableName\n- }\n- viewOption.extra['type'] = MessageType.data\n- this.sendData = viewOption.extra\n- if (this.creating) return;\n- // update result webview\n- if (this.resultWebviewPanel) {\n- if (this.resultWebviewPanel.visible) {\n- this.resultWebviewPanel.webview.postMessage(viewOption.extra)\n- this.resultWebviewPanel.reveal(vscode.ViewColumn.Two, true);\n- return;\n- } else {\n- this.resultWebviewPanel.dispose()\n- }\n-\n- }\n-\n- // init result webview\n- viewOption.viewPath = \"result\"\n- viewOption.viewTitle = \"Query\"\n- this.creating = true;\n- this.createWebviewPanel(viewOption).then(async webviewPanel => {\n- this.resultWebviewPanel = webviewPanel\n- this.creating = false;\n- webviewPanel.onDidDispose(() => { this.resultWebviewPanel = undefined; this.creating = false; })\n- webviewPanel.webview.onDidReceiveMessage((params) => {\n- switch (params.type) {\n- case OperateType.init:\n- webviewPanel.webview.postMessage(SqlViewManager.sendData)\n- break;\n- case OperateType.execute:\n- QueryUnit.runQuery(params.sql).then(isDDL => {\n- if (isDDL) {\n- SqlViewManager.sendData['type']=MessageType.opt\n- webviewPanel.webview.postMessage(SqlViewManager.sendData)\n- }\n- })\n- break;\n- }\n- })\n- })\n-\n-\n- }\n-\n- private static getTable(extra: any): string {\n- if (!extra) return null;\n- let sql = extra.sql;\n- let baseMatch;\n- if (sql && (baseMatch = (sql + \" \").match(/select\\s+\\*\\s+from\\s*(.+?)(?=[\\s;])/i)) && !sql.match(/\\bjoin\\b/ig)) {\n- let expectTable: string = baseMatch[1];\n- let temp: string[], table;\n- if (expectTable.includes(\"`\")) {\n- temp = expectTable.split(\"`\");\n- table = temp[temp.length - 2];\n- } else {\n- temp = expectTable.split(\".\")\n- table = temp[temp.length - 1]\n- }\n- return table;\n- }\n- }\n-\n- static showConnectPage() {\n-\n- this.createWebviewPanel({\n- viewPath: \"connect\",\n- viewTitle: \"connect\",\n- splitResultView: false\n- }).then(webviewPanel => {\n- webviewPanel.webview.onDidReceiveMessage((params) => {\n- if (params.type === 'CONNECT_TO_SQL_SERVER') {\n- ConnectionManager.getConnection(params.connectionOption).then(() => {\n- MySQLTreeDataProvider.instance.addConnection(params.connectionOption);\n- webviewPanel.dispose();\n- }).catch((err: Error) => {\n- webviewPanel.webview.postMessage({\n- type: 'CONNECTION_ERROR',\n- err\n- });\n- })\n- }\n- });\n- })\n- }\n-\n- private static createWebviewPanel(viewOption: ViewOption): Promise<WebviewPanel> {\n-\n- let columnType = viewOption.splitResultView ? vscode.ViewColumn.Two : vscode.ViewColumn.One\n-\n- return new Promise((resolve, reject) => {\n- fs.readFile(`${this.extensionPath}/resources/webview/${viewOption.viewPath}.html`, 'utf8', async (err, data) => {\n- if (err) {\n- Console.log(err)\n- reject(err)\n- return;\n- }\n- const webviewPanel = await vscode.window.createWebviewPanel(\n- \"mysql.sql.result\",\n- viewOption.viewTitle,\n- { viewColumn: columnType, preserveFocus: true },\n- { enableScripts: true, retainContextWhenHidden: true }\n- );\n- webviewPanel.webview.html = data.replace(/\\$\\{webviewPath\\}/gi,\n- vscode.Uri.file(`${this.extensionPath}/resources/webview`)\n- .with({ scheme: 'vscode-resource' }).toString())\n- webviewPanel.webview.onDidReceiveMessage(viewOption.receiveListener);\n- webviewPanel.onDidDispose(viewOption.disposeListener)\n-\n- resolve(webviewPanel)\n- })\n-\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": "@@ -8,7 +8,7 @@ import { MySQLTreeDataProvider } from \"./provider/MysqlTreeDataProvider\";\nimport { CompletionProvider } from \"./provider/CompletionProvider\";\nimport { DatabaseCache } from \"./database/DatabaseCache\";\nimport { ColumnNode } from \"./model/table/columnNode\";\n-import { SqlViewManager } from \"./database/SqlViewManager\";\n+import { SqlViewManager } from \"./common/SqlViewManager\";\nimport { ProcedureNode } from \"./model/other/Procedure\";\nimport { FunctionNode } from \"./model/other/function\";\nimport { TriggerNode } from \"./model/other/Trigger\";\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/view/result/query.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { WebviewPanel } from \"vscode\";\n+import { MessageType, OperateType } from \"../../common/Constants\";\n+import { SqlViewManager } from \"../../common/SqlViewManager\";\n+import { DatabaseCache } from \"../../database/DatabaseCache\";\n+import { QueryUnit } from \"../../database/QueryUnit\";\n+import { IConnection } from \"../../model/Connection\";\n+import { ColumnNode } from \"../../model/table/columnNode\";\n+import { DataResponse } from \"./queryResponse\";\n+\n+export class QueryParam<T> {\n+ type: MessageType;\n+ connection?: IConnection;\n+ res: T;\n+}\n+\n+export class QueryPage {\n+ private static resultWebviewPanel: WebviewPanel\n+ /**\n+ * ensure send newest message.\n+ */\n+ private static sendData: any;\n+ private static creating = false;\n+ public static async send(queryParam: QueryParam<any>) {\n+ if(queryParam.type==MessageType.DATA){\n+ await this.loadTableInfo(queryParam)\n+ }\n+ this.sendData = queryParam\n+ if (this.creating) return;\n+\n+ // update result webview\n+ if (this.resultWebviewPanel) {\n+ if (this.resultWebviewPanel.visible) {\n+ this.resultWebviewPanel.webview.postMessage(QueryPage.sendData)\n+ this.resultWebviewPanel.reveal(vscode.ViewColumn.Two, true);\n+ return;\n+ } else {\n+ this.resultWebviewPanel.dispose()\n+ }\n+ }\n+\n+ // init result webview\n+ this.creating = true;\n+ SqlViewManager.createWebviewPanel({\n+ splitResultView: true, viewPath: \"result\", viewTitle: \"Query\"\n+ }).then(async webviewPanel => {\n+ this.resultWebviewPanel = webviewPanel\n+ this.creating = false;\n+ webviewPanel.onDidDispose(() => { this.resultWebviewPanel = undefined; this.creating = false; })\n+ webviewPanel.webview.onDidReceiveMessage((params) => {\n+ switch (params.type) {\n+ case OperateType.init:\n+ webviewPanel.webview.postMessage(QueryPage.sendData)\n+ break;\n+ case OperateType.execute:\n+ QueryUnit.runQuery(params.sql)\n+ break;\n+ }\n+ })\n+ })\n+\n+ }\n+ private static async loadTableInfo(queryParam: QueryParam<DataResponse>) {\n+ let conn = queryParam.connection\n+ let tableName = this.getTable(queryParam.res.sql)\n+ if (tableName == null || conn == null) return;\n+ // load table infomation\n+ let tableNode = DatabaseCache.getTable(`${conn.host}_${conn.port}_${conn.user}_${conn.database}`, tableName)\n+ if (tableNode) {\n+ let primaryKey: string;\n+ let columnList = (await tableNode.getChildren()).map((columnNode: ColumnNode) => {\n+ if (columnNode.column.COLUMN_KEY === \"PRI\") {\n+ primaryKey = columnNode.column.COLUMN_NAME\n+ }\n+ return columnNode.column.COLUMN_NAME\n+ })\n+ queryParam.res.primaryKey = primaryKey\n+ queryParam.res.columnList = columnList\n+ queryParam.res.database = conn.database\n+ queryParam.res.table = tableName\n+ }\n+ }\n+\n+ private static getTable(sql: string): string {\n+ if (!sql) return null;\n+ let baseMatch;\n+ if (sql && (baseMatch = (sql + \" \").match(/select\\s+\\*\\s+from\\s*(.+?)(?=[\\s;])/i)) && !sql.match(/\\bjoin\\b/ig)) {\n+ let expectTable: string = baseMatch[1];\n+ let temp: string[], table;\n+ if (expectTable.includes(\"`\")) {\n+ temp = expectTable.split(\"`\");\n+ table = temp[temp.length - 2];\n+ } else {\n+ temp = expectTable.split(\".\")\n+ table = temp[temp.length - 1]\n+ }\n+ return table;\n+ }\n+ }\n+\n+}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
refactor query communication
|
141,908 |
10.04.2020 00:09:58
| -28,800 |
5fc5021aab9d2809077410b4662eaf18cac4476d
|
support feedback
|
[
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -6,7 +6,7 @@ import { DatabaseCache } from \"../../database/DatabaseCache\";\nimport { QueryUnit } from \"../../database/QueryUnit\";\nimport { IConnection } from \"../../model/Connection\";\nimport { ColumnNode } from \"../../model/table/columnNode\";\n-import { DataResponse } from \"./queryResponse\";\n+import { DataResponse, ErrorResponse, DMLResponse } from \"./queryResponse\";\nexport class QueryParam<T> {\ntype: MessageType;\n@@ -22,9 +22,19 @@ export class QueryPage {\nprivate static sendData: any;\nprivate static creating = false;\npublic static async send(queryParam: QueryParam<any>) {\n- if(queryParam.type==MessageType.DATA){\n+\n+ switch (queryParam.type) {\n+ case MessageType.DATA:\nawait this.loadTableInfo(queryParam)\n+ break;\n+ case MessageType.DML:\n+ queryParam.res.message=`EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}<br><br>AffectedRows : ${queryParam.res.affectedRows}`\n+ break;\n+ case MessageType.ERROR:\n+ queryParam.res.message=`EXECUTE Fail:<br><br> ${queryParam.res.sql}<br><br>message :<br >${queryParam.res.message}`\n+ break;\n}\n+\nthis.sendData = queryParam\nif (this.creating) return;\n// TODO support delimiter : const _sql = sql.toString().replace(/DELIMITER ;?;/gm, '').replace(/;;/gm, ';')\n"
},
{
"change_type": "MODIFY",
"old_path": "src/view/result/queryResponse.ts",
"new_path": "src/view/result/queryResponse.ts",
"diff": "@@ -14,11 +14,13 @@ export class DataResponse {\n}\nexport class ErrorResponse {\nsql:string;\n+ costTime: number;\nmessage: string;\n}\nexport class DMLResponse {\nsql:string;\ncostTime: number;\n+ message?: string;\naffectedRows:number;\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support feedback
|
141,908 |
10.04.2020 00:15:46
| -28,800 |
72184406be572274a813ecf488bdc7c8a3725a0a
|
feedback insert costime
|
[
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -28,10 +28,10 @@ export class QueryPage {\nawait this.loadTableInfo(queryParam)\nbreak;\ncase MessageType.DML:\n- queryParam.res.message=`EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}<br><br>AffectedRows : ${queryParam.res.affectedRows}`\n+ queryParam.res.message=`EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}<br><br>AffectedRows : ${queryParam.res.affectedRows}, CostTime : ${queryParam.res.costTime}`\nbreak;\ncase MessageType.ERROR:\n- queryParam.res.message=`EXECUTE Fail:<br><br> ${queryParam.res.sql}<br><br>message :<br >${queryParam.res.message}`\n+ queryParam.res.message=`EXECUTE Fail:<br><br> ${queryParam.res.sql}<br><br>message :<br> ${queryParam.res.message}`\nbreak;\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
feedback insert costime
|
141,908 |
10.04.2020 11:31:12
| -28,800 |
04a846e0a30c2a9f0678bef3fe265825219c12fb
|
enhance sql assistant
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<el-button type=\"primary\" @click='execute(toolbar.sql);info.visible = false;'>Execute</el-button>\n</el-cow>\n<el-cow>\n- <span>costTime: </span><span v-text=\"toolbar.costTime\"></span>ms\n- <span v-if=\"result.table\">,row: {{result.data.length}}, Col: {{columnCount}}</span>\n+ <span>CostTime: </span><span v-text=\"toolbar.costTime\"></span>ms\n+ <span v-if=\"result.table\">, Row: {{result.data.length}}, Col: {{columnCount}}</span>\n</el-cow>\n</el-row>\n</div>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -100,8 +100,14 @@ export class QueryUnit {\nvar content = activeTextEditor.document.getText()\nif (content.match(this.batchPattern)) return content;\n+ return this.obtainCursorSql(activeTextEditor.document, activeTextEditor.selection.active,content)\n+\n+ }\n+\n+ static obtainCursorSql(document: vscode.TextDocument, current: vscode.Position, content?: string) {\n+ if (!content) content = document.getText(new vscode.Range(new vscode.Position(0,0),current))\nvar sqlList = content.split(\";\");\n- var doc_cursor = activeTextEditor.document.getText(Cursor.getRangeStartTo(activeTextEditor.selection.active)).length;\n+ var doc_cursor = document.getText(Cursor.getRangeStartTo(current)).length;\nvar index = 0;\nfor (let sql of sqlList) {\nindex += (sql.length + 1)\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": "src/provider/CompletionProvider.ts",
"diff": "@@ -71,6 +71,16 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nlet wordRange = document.getWordRangeAtPosition(prePostion)\nconst inputWord = document.getText(wordRange)\n+\n+ let currentSql = QueryUnit.obtainCursorSql(document, position)\n+ let wordMatch = currentSql.match(/\\w+/ig)\n+ let preWord: string;\n+ if (wordRange == null || preChart.trim() == \"\") {\n+ preWord = wordMatch[wordMatch.length - 1]\n+ } else if (wordMatch.length > 1) {\n+ preWord = wordMatch[wordMatch.length - 2]\n+ }\n+\nif (inputWord && preChart == '.') {\nlet subComplectionItems = this.generateTableComplectionItem(inputWord)\nif (subComplectionItems.length == 0) {\n@@ -86,7 +96,7 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\n}\n}\ncompletionItems = completionItems.concat(subComplectionItems)\n- } else {\n+ } else if (preWord && preWord.match(/into|from|update|table|join/ig)) {\ncompletionItems = completionItems.concat(this.generateDatabaseComplectionItem(), this.generateTableComplectionItem())\n}\n@@ -101,12 +111,23 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nlet databaseNodes = DatabaseCache.getDatabaseNodeList()\nreturn databaseNodes.map<vscode.CompletionItem>(databaseNode => {\n- let completionItem = new vscode.CompletionItem(databaseNode.getTreeItem().label)\n+ const label = databaseNode.getTreeItem().label;\n+ let completionItem = new vscode.CompletionItem(label)\ncompletionItem.kind = vscode.CompletionItemKind.Struct\n+ completionItem.insertText = this.wrap(label)\nreturn completionItem\n})\n}\n+ private wrap(origin: string): string {\n+\n+ if (origin != null && origin.match(/\\b(-)\\b/ig)) {\n+ return `\\`${origin}\\``\n+ }\n+\n+ return origin;\n+ }\n+\nprivate blockDbReg = /(mysql|performance_schema|information_schema)/ig\nprivate generateTableComplectionItem(inputWord?: string): vscode.CompletionItem[] {\n@@ -123,7 +144,9 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nreturn tableNodes.map<vscode.CompletionItem>((tableNode: TableNode) => {\nlet treeItem = tableNode.getTreeItem();\n- let completionItem = new vscode.CompletionItem(treeItem.label)\n+ const label = treeItem.label;\n+ let completionItem = new vscode.CompletionItem(label)\n+ completionItem.insertText = this.wrap(label)\nswitch (tableNode.type) {\ncase ModelType.TABLE:\ncompletionItem.kind = vscode.CompletionItemKind.Function;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -28,7 +28,7 @@ export class QueryPage {\nawait this.loadTableInfo(queryParam)\nbreak;\ncase MessageType.DML:\n- queryParam.res.message=`EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}<br><br>AffectedRows : ${queryParam.res.affectedRows}, CostTime : ${queryParam.res.costTime}`\n+ queryParam.res.message=`EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}<br><br>AffectedRows : ${queryParam.res.affectedRows}, CostTime : ${queryParam.res.costTime}ms`\nbreak;\ncase MessageType.ERROR:\nqueryParam.res.message=`EXECUTE Fail:<br><br> ${queryParam.res.sql}<br><br>message :<br> ${queryParam.res.message}`\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
enhance sql assistant
|
141,908 |
10.04.2020 15:55:35
| -28,800 |
783eb3eb04d98c806cf051c5abefcf04d6f90be8
|
create responsibility chain for complection
|
[
{
"change_type": "MODIFY",
"old_path": ".gitignore",
"new_path": ".gitignore",
"diff": "out\nnode_modules\n+.idea/\n.vscode-test/\n*.vsix\npackage-lock.json\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -5,7 +5,7 @@ import { ConnectionNode } from \"./model/ConnectionNode\";\nimport { DatabaseNode } from \"./model/database/databaseNode\";\nimport { TableNode } from \"./model/table/tableNode\";\nimport { MySQLTreeDataProvider } from \"./provider/MysqlTreeDataProvider\";\n-import { CompletionProvider } from \"./provider/CompletionProvider\";\n+import { CompletionProvider } from \"./provider/Complection/CompletionProvider\";\nimport { DatabaseCache } from \"./database/DatabaseCache\";\nimport { ColumnNode } from \"./model/table/columnNode\";\nimport { SqlViewManager } from \"./common/SqlViewManager\";\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension/HistoryManager.ts",
"new_path": "src/extension/HistoryManager.ts",
"diff": "@@ -6,7 +6,7 @@ export class HistoryManager {\n}\nshowHistory() {\n- var historyPath = this.context.globalStoragePath + '/history.sql'\n+ var historyPath = this.context['globalStoragePath'] + '/history.sql'\nvar openPath = vscode.Uri.file(historyPath);\nvscode.workspace.openTextDocument(openPath).then(doc => {\nvscode.window.showTextDocument(doc);\n@@ -16,7 +16,7 @@ export class HistoryManager {\nrecordHistory(sql: string, costTime: number) {\nif (!sql) return;\nreturn new Promise(() => {\n- var gsPath = this.context.globalStoragePath\n+ var gsPath = this.context['globalStoragePath']\nif (!fs.existsSync(gsPath)) {\nfs.mkdirSync(gsPath)\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/CompletionProvider.ts",
"diff": "+import * as vscode from \"vscode\";\n+import {ColumnChain} from \"./chain/columnChain\";\n+import {DatabaseChain} from \"./chain/databaseChain\";\n+import {KeywordChain} from \"./chain/keywordChain\";\n+import {TableChain} from \"./chain/tableChain\";\n+import {TableCreateChain} from \"./chain/TableCreateChain\";\n+import {TypeKeywordChain} from \"./chain/typeKeywordChain\";\n+import {ComplectionChain, ComplectionContext} from \"./complectionContext\";\n+\n+export class CompletionProvider implements vscode.CompletionItemProvider {\n+ constructor() {\n+ this.initDefaultComplectionItem();\n+ }\n+\n+ private fullChain: ComplectionChain[];\n+\n+ private initDefaultComplectionItem() {\n+ // The chain is orderly\n+ this.fullChain = [\n+ new TableCreateChain(),\n+ new TypeKeywordChain(),\n+ new DatabaseChain(),\n+ new TableChain(),\n+ new ColumnChain(),\n+ new KeywordChain(),\n+ ];\n+ }\n+\n+ /**\n+ * Main function\n+ * @param document\n+ * @param position\n+ */\n+ public async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): Promise<vscode.CompletionItem[]> {\n+\n+ const context = ComplectionContext.build(document, position);\n+ const completionItemList = [];\n+ for (const chain of this.fullChain) {\n+ const tempComplection = chain.getComplection(context);\n+ if (tempComplection != null) {\n+ completionItemList.concat(tempComplection);\n+ if (chain.stop()) {\n+ break;\n+ }\n+ }\n+ }\n+\n+ return completionItemList;\n+ }\n+\n+ public resolveCompletionItem?(item: vscode.CompletionItem): vscode.ProviderResult<vscode.CompletionItem> {\n+\n+ return item;\n+ }\n+\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/columnChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { DatabaseCache } from \"../../../database/DatabaseCache\";\n+import { ColumnNode } from \"../../../model/table/columnNode\";\n+import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n+\n+export class ColumnChain implements ComplectionChain {\n+ public async getComplection(complectionContext: ComplectionContext): Promise<vscode.CompletionItem[]> {\n+ if (complectionContext.preChart === \".\") {\n+ let subComplectionItems = await this.generateColumnComplectionItem(complectionContext.preWord);\n+ const tableReg = new RegExp(\"`{0,1}(\\\\w|-)+`{0,1}(?=\\\\s*\\\\b\" + complectionContext.preWord + \"\\\\b)\", \"ig\");\n+ let result = tableReg.exec(complectionContext.currentSql);\n+ for (; result != null && subComplectionItems.length === 0;) {\n+ subComplectionItems = await this.generateColumnComplectionItem(result[0].replace(/`/ig, \"\"));\n+ result = tableReg.exec(complectionContext.currentSql);\n+ }\n+ return subComplectionItems;\n+ }\n+ return null;\n+ }\n+\n+ public stop(): boolean {\n+ return true;\n+ }\n+\n+ private async generateColumnComplectionItem(inputWord: string): Promise<vscode.CompletionItem[]> {\n+\n+ if (!inputWord) {\n+ return [];\n+ }\n+ let columnNodes: ColumnNode[] = [];\n+\n+ for (const tableNode of DatabaseCache.getTableNodeList()) {\n+ if (tableNode.table === inputWord) {\n+ columnNodes = (await tableNode.getChildren()) as ColumnNode[];\n+ break;\n+ }\n+ }\n+\n+ return columnNodes.map<vscode.CompletionItem>((columnNode) => {\n+ const completionItem = new vscode.CompletionItem(columnNode.getTreeItem().columnName);\n+ completionItem.detail = columnNode.getTreeItem().detail;\n+ completionItem.documentation = columnNode.getTreeItem().document;\n+ completionItem.kind = vscode.CompletionItemKind.Function;\n+ return completionItem;\n+ });\n+ }\n+\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/databaseChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import {DatabaseCache} from \"../../../database/DatabaseCache\";\n+import {ComplectionChain, ComplectionContext} from \"../complectionContext\";\n+\n+function wrap(origin: string): string {\n+ if (origin != null && origin.match(/\\b(-)\\b/ig)) {\n+ return `\\`${origin}\\``;\n+ }\n+ return origin;\n+}\n+\n+export class DatabaseChain implements ComplectionChain {\n+ public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n+ if (complectionContext.preWord && complectionContext.preWord.match(/into|from|update|table|join/ig)) {\n+ return this.generateDatabaseComplectionItem();\n+ }\n+ return null;\n+ }\n+\n+ public stop(): boolean {\n+ return false;\n+ }\n+\n+ private generateDatabaseComplectionItem(): vscode.CompletionItem[] {\n+\n+ const databaseNodes = DatabaseCache.getDatabaseNodeList();\n+ return databaseNodes.map<vscode.CompletionItem>((databaseNode) => {\n+ const label = databaseNode.getTreeItem().label;\n+ const completionItem = new vscode.CompletionItem(label);\n+ completionItem.kind = vscode.CompletionItemKind.Struct;\n+ completionItem.insertText = wrap(label);\n+ return completionItem;\n+ });\n+ }\n+}\n+\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/keywordChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n+\n+export class KeywordChain implements ComplectionChain {\n+ private keywordList: string[] = [\"JOIN\", \"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"];\n+ private functionList: string[] = [\"decimal\", \"char\", \"varchar\", \"CHAR_LENGTH\", \"CONCAT\", \"NOW\", \"DATE_ADD\", \"DATE_SUB\", \"MAX\", \"COUNT\", \"MIN\", \"SUM\", \"AVG\", \"LENGTH\", \"IF\", \"IFNULL\", \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\"];\n+ private defaultComplectionItems: vscode.CompletionItem[] = [];\n+\n+ constructor() {\n+ this.keywordList.forEach((keyword) => {\n+ const keywordComplectionItem = new vscode.CompletionItem(keyword + \" \");\n+ keywordComplectionItem.kind = vscode.CompletionItemKind.Property;\n+ this.defaultComplectionItems.push(keywordComplectionItem);\n+ });\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.defaultComplectionItems.push(functionComplectionItem);\n+ });\n+ }\n+\n+ public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n+ return this.defaultComplectionItems;\n+ }\n+\n+ public stop(): boolean {\n+ return true;\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/tableChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import {ModelType} from \"../../../common/Constants\";\n+import {DatabaseCache} from \"../../../database/DatabaseCache\";\n+import {INode} from \"../../../model/INode\";\n+import {TableNode} from \"../../../model/table/tableNode\";\n+import {ComplectionChain, ComplectionContext} from \"../complectionContext\";\n+\n+function wrap(origin: string): string {\n+ if (origin != null && origin.match(/\\b(-)\\b/ig)) {\n+ return `\\`${origin}\\``;\n+ }\n+ return origin;\n+}\n+\n+export class TableChain implements ComplectionChain {\n+ public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n+ if (complectionContext.preChart == \".\") {\n+ return this.generateTableComplectionItem(complectionContext.preWord);\n+ }\n+ if (complectionContext.preWord && complectionContext.preWord.match(/\\b(into|from|update|table|join)\\b/ig)) {\n+ return this.generateTableComplectionItem();\n+ }\n+ return null;\n+ }\n+\n+ public stop(): boolean {\n+ return true;\n+ }\n+\n+ private generateTableComplectionItem(inputWord?: string): vscode.CompletionItem[] {\n+\n+ let tableNodes: INode[] = [];\n+ const tableNames: string[] = [];\n+ if (inputWord) {\n+ DatabaseCache.getDatabaseNodeList().forEach((databaseNode) => {\n+ if (databaseNode.database === inputWord) {\n+ tableNodes = DatabaseCache.getTableListOfDatabase(databaseNode.identify);\n+ }\n+ });\n+ } else {\n+ tableNodes = DatabaseCache.getTableNodeList().filter((tableNode) => {\n+ const included = tableNames.includes(tableNode.table);\n+ tableNames.push(tableNode.table);\n+ return !included && !tableNode.database.match(/(mysql|performance_schema|information_schema|sys)/ig);\n+ });\n+ }\n+\n+ return tableNodes.map<vscode.CompletionItem>((tableNode: TableNode) => {\n+ const treeItem = tableNode.getTreeItem();\n+ const label = treeItem.label;\n+ const completionItem = new vscode.CompletionItem(label);\n+ completionItem.insertText = wrap(label);\n+ switch (tableNode.type) {\n+ case ModelType.TABLE:\n+ completionItem.kind = vscode.CompletionItemKind.Function;\n+ break;\n+ case ModelType.VIEW:\n+ completionItem.kind = vscode.CompletionItemKind.Module;\n+ break;\n+ case ModelType.PROCEDURE:\n+ completionItem.kind = vscode.CompletionItemKind.Reference;\n+ break;\n+ case ModelType.FUNCTION:\n+ completionItem.kind = vscode.CompletionItemKind.Method;\n+ break;\n+ case ModelType.TRIGGER:\n+ completionItem.kind = vscode.CompletionItemKind.Event;\n+ break;\n+ }\n+\n+ return completionItem;\n+ });\n+ }\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/tableCreateChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n+\n+export class TableCreateChain implements ComplectionChain {\n+ private tableKeywordList: string[] = [\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\"];\n+ private tableKeywordComplectionItems: vscode.CompletionItem[] = [];\n+\n+ constructor() {\n+ this.tableKeywordList.forEach((keyword) => {\n+ const keywordComplectionItem = new vscode.CompletionItem(keyword + \" \");\n+ keywordComplectionItem.kind = vscode.CompletionItemKind.Property;\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 true;\n+ }\n+\n+}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/typeKeywordChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import {ComplectionChain, ComplectionContext} from \"../complectionContext\";\n+\n+export class TypeKeywordChain implements ComplectionChain {\n+ private typeList: string[] = [\"INTEGER\", \"char\", \"varchar\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"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.TypeParameter;\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(/(FUNCTION|PROCEDURE)/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": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/complectionContext.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { QueryUnit } from \"../../database/QueryUnit\";\n+\n+export interface ComplectionChain {\n+ getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]>;\n+\n+ stop(): boolean;\n+}\n+\n+export class ComplectionContext {\n+\n+ public preWord: string;\n+ public preChart: string;\n+ public currentWord: string;\n+ public currentSql: string;\n+\n+ public static build(document: vscode.TextDocument, position: vscode.Position): ComplectionContext {\n+ // TODO\n+ const prePostion = position.character === 0 ? position : new vscode.Position(position.line, position.character - 1);\n+ const preChart = document.getText(new vscode.Range(prePostion, position));\n+ const wordRange = document.getWordRangeAtPosition(prePostion);\n+ let inputWord = document.getText(wordRange);\n+\n+ const currentSql = QueryUnit.obtainCursorSql(document, position);\n+ const wordMatch = currentSql.match(/(\\w|-)+/ig);\n+ let preWord: string;\n+ if (wordRange == null || preChart.trim() == \"\") {\n+ preWord = wordMatch[wordMatch.length - 1];\n+ } else if (wordMatch.length > 1) {\n+ preWord = wordMatch[wordMatch.length - 2];\n+ }\n+\n+ if (wordRange == null && preWord != null) {\n+ inputWord = preWord;\n+ }\n+ const context = new ComplectionContext();\n+ context.preChart = preChart;\n+ context.preWord = preWord;\n+ context.currentWord = inputWord;\n+ context.currentSql = currentSql.trim();\n+ return context;\n+ }\n+\n+}\n"
},
{
"change_type": "DELETE",
"old_path": "src/provider/CompletionProvider.ts",
"new_path": null,
"diff": "-import * as vscode from \"vscode\";\n-import { ModelType } from \"../common/Constants\";\n-import { DatabaseCache } from \"../database/DatabaseCache\";\n-import { INode } from \"../model/INode\";\n-import { ColumnNode } from \"../model/table/columnNode\";\n-import { TableNode } from \"../model/table/tableNode\";\n-import { QueryUnit } from \"../database/QueryUnit\";\n-\n-export class CompletionProvider implements vscode.CompletionItemProvider {\n- constructor() {\n- this.initDefaultComplectionItem()\n- }\n- private keywordList: string[] = [\"JOIN\", \"SELECT\", \"UPDATE\", \"DELETE\", \"TABLE\", \"INSERT\", \"INTO\", \"VALUES\", \"FROM\", \"WHERE\", \"GROUP BY\", \"ORDER BY\", \"HAVING\", \"LIMIT\", \"ALTER\", \"CREATE\", \"DROP\", \"FUNCTION\", \"CASE\", \"PROCEDURE\", \"TRIGGER\", \"INDEX\", \"CHANGE\", \"COLUMN\", \"ADD\", 'SHOW', \"PRIVILEGES\", \"IDENTIFIED\", \"VIEW\", \"CURSOR\", \"EXPLAIN\"]\n- private functionList: string[] = [\"decimal\", \"char\", \"varchar\", \"CHAR_LENGTH\", \"CONCAT\", \"NOW\", \"DATE_ADD\", \"DATE_SUB\", \"MAX\", \"COUNT\", \"MIN\", \"SUM\", \"AVG\", \"LENGTH\", \"IF\", \"IFNULL\", \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\"]\n- private defaultComplectionItems: vscode.CompletionItem[] = []\n- private tableKeywordList: string[] = [\"AUTO_INCREMENT\", \"NULL\", \"NOT\", \"PRIMARY\", \"CURRENT_TIME\", \"DEFAULT\", \"COMMENT\", \"UNIQUE\", \"KEY\"]\n- private tableKeywordComplectionItems: vscode.CompletionItem[] = []\n- private typeList: string[] = [\"INTEGER\", \"char\", \"varchar\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"]\n- private typeComplectionItems: vscode.CompletionItem[] = []\n-\n- private initDefaultComplectionItem() {\n- this.keywordList.forEach(keyword => {\n- let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n- keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n- this.defaultComplectionItems.push(keywordComplectionItem)\n- })\n- this.functionList.forEach(keyword => {\n- let functionComplectionItem = new vscode.CompletionItem(keyword + \" \")\n- functionComplectionItem.kind = vscode.CompletionItemKind.Function\n- functionComplectionItem.insertText = new vscode.SnippetString(keyword + \"($1)\")\n- this.defaultComplectionItems.push(functionComplectionItem)\n- })\n- this.tableKeywordList.forEach(keyword => {\n- let keywordComplectionItem = new vscode.CompletionItem(keyword + \" \")\n- keywordComplectionItem.kind = vscode.CompletionItemKind.Property\n- this.tableKeywordComplectionItems.push(keywordComplectionItem)\n- })\n- this.typeList.forEach(columnType => {\n- let columnTypeComplectionItem = new vscode.CompletionItem(columnType + \" \")\n- columnTypeComplectionItem.kind = vscode.CompletionItemKind.TypeParameter\n- this.typeComplectionItems.push(columnTypeComplectionItem)\n- })\n- }\n-\n- private createReg = /CREATE TABLE/ig;\n- private programReg = /(FUNCTION|PROCEDURE)/ig;\n- /**\n- * Main function\n- * @param document\n- * @param position\n- */\n- async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position): Promise<vscode.CompletionItem[]> {\n-\n- var sql = QueryUnit.obtainSql(vscode.window.activeTextEditor)\n- if (sql && sql.match(this.createReg)) {\n- return this.typeComplectionItems.concat(this.tableKeywordComplectionItems);\n- }\n-\n- let completionItems = [];\n-\n- const prePostion = position.character == 0 ? position : new vscode.Position(position.line, position.character - 1);\n- const preChart = document.getText(new vscode.Range(prePostion, position))\n-\n- if (preChart != \".\" && sql && sql.match(this.programReg)) {\n- completionItems = this.typeComplectionItems\n- }\n- if (preChart != \".\" && preChart != \" \") {\n- completionItems = completionItems.concat(this.defaultComplectionItems)\n- }\n- if ((position.character == 0)) return completionItems\n-\n- let wordRange = document.getWordRangeAtPosition(prePostion)\n- const inputWord = document.getText(wordRange)\n-\n- let currentSql = QueryUnit.obtainCursorSql(document, position)\n- let wordMatch = currentSql.match(/\\w+/ig)\n- let preWord: string;\n- if (wordRange == null || preChart.trim() == \"\") {\n- preWord = wordMatch[wordMatch.length - 1]\n- } else if (wordMatch.length > 1) {\n- preWord = wordMatch[wordMatch.length - 2]\n- }\n-\n- if (inputWord && preChart == '.') {\n- let subComplectionItems = this.generateTableComplectionItem(inputWord)\n- if (subComplectionItems.length == 0) {\n- subComplectionItems = await CompletionProvider.generateColumnComplectionItem(inputWord)\n- if (subComplectionItems.length == 0) {\n- let tableReg = new RegExp(\"`{0,1}(\\\\w|-)+`{0,1}(?=\\\\s*\\\\b\" + inputWord + \"\\\\b)\", 'ig')\n- let currentSql = document.getText();\n- let result = tableReg.exec(currentSql)\n- for (; result != null && subComplectionItems.length == 0;) {\n- subComplectionItems = await CompletionProvider.generateColumnComplectionItem(result[0].replace(/`/ig, \"\"))\n- result = tableReg.exec(currentSql)\n- }\n- }\n- }\n- completionItems = completionItems.concat(subComplectionItems)\n- } else if (preWord && preWord.match(/into|from|update|table|join/ig)) {\n- completionItems = completionItems.concat(this.generateDatabaseComplectionItem(), this.generateTableComplectionItem())\n- }\n-\n- return completionItems\n- }\n- resolveCompletionItem?(item: vscode.CompletionItem): vscode.ProviderResult<vscode.CompletionItem> {\n-\n- return item;\n- }\n-\n- private generateDatabaseComplectionItem(): vscode.CompletionItem[] {\n-\n- let databaseNodes = DatabaseCache.getDatabaseNodeList()\n- return databaseNodes.map<vscode.CompletionItem>(databaseNode => {\n- const label = databaseNode.getTreeItem().label;\n- let completionItem = new vscode.CompletionItem(label)\n- completionItem.kind = vscode.CompletionItemKind.Struct\n- completionItem.insertText = this.wrap(label)\n- return completionItem\n- })\n- }\n-\n- private wrap(origin: string): string {\n-\n- if (origin != null && origin.match(/\\b(-)\\b/ig)) {\n- return `\\`${origin}\\``\n- }\n-\n- return origin;\n- }\n-\n- private blockDbReg = /(mysql|performance_schema|information_schema)/ig\n- private generateTableComplectionItem(inputWord?: string): vscode.CompletionItem[] {\n-\n- let tableNodes: INode[] = []\n- if (inputWord) {\n- DatabaseCache.getDatabaseNodeList().forEach(databaseNode => {\n- if (databaseNode.database == inputWord) tableNodes = DatabaseCache.getTableListOfDatabase(databaseNode.identify)\n- })\n- } else {\n- tableNodes = DatabaseCache.getTableNodeList().filter(databaseNode => {\n- return !databaseNode.database.match(this.blockDbReg)\n- })\n- }\n-\n- return tableNodes.map<vscode.CompletionItem>((tableNode: TableNode) => {\n- let treeItem = tableNode.getTreeItem();\n- const label = treeItem.label;\n- let completionItem = new vscode.CompletionItem(label)\n- completionItem.insertText = this.wrap(label)\n- switch (tableNode.type) {\n- case ModelType.TABLE:\n- completionItem.kind = vscode.CompletionItemKind.Function;\n- break;\n- case ModelType.VIEW:\n- completionItem.kind = vscode.CompletionItemKind.Module;\n- break;\n- case ModelType.PROCEDURE:\n- completionItem.kind = vscode.CompletionItemKind.Reference;\n- break;\n- case ModelType.FUNCTION:\n- completionItem.kind = vscode.CompletionItemKind.Method;\n- break;\n- case ModelType.TRIGGER:\n- completionItem.kind = vscode.CompletionItemKind.Event;\n- break;\n- }\n-\n- return completionItem\n- })\n- }\n-\n- static async generateColumnComplectionItem(inputWord: string): Promise<vscode.CompletionItem[]> {\n-\n- if (!inputWord) return []\n- let columnNodes: ColumnNode[] = []\n-\n- for (const tableNode of DatabaseCache.getTableNodeList()) {\n- if (tableNode.table == inputWord) {\n- columnNodes = (await tableNode.getChildren()) as ColumnNode[]\n- break;\n- }\n- }\n-\n- return columnNodes.map<vscode.CompletionItem>(columnNode => {\n- let completionItem = new vscode.CompletionItem(columnNode.getTreeItem().columnName)\n- completionItem.detail = columnNode.getTreeItem().detail\n- completionItem.documentation = columnNode.getTreeItem().document\n- completionItem.kind = vscode.CompletionItemKind.Function\n- return completionItem\n- })\n- }\n-\n-\n-}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/TableHoverProvider.ts",
"new_path": "src/provider/TableHoverProvider.ts",
"diff": "-import * as vscode from 'vscode';\n+import * as vscode from \"vscode\";\nimport {HoverProvider} from \"vscode\";\nimport {DatabaseCache} from \"../database/DatabaseCache\";\nimport {ColumnNode} from \"../model/table/columnNode\";\n-\nexport class TableHoverProvider implements HoverProvider {\n- async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Hover> {\n+ public async provideHover(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken): Promise<vscode.Hover> {\nconst tableName = document.getText(document.getWordRangeAtPosition(position));\nfor (const tableNode of DatabaseCache.getTableNodeList()) {\n- if (tableNode.table == tableName) {\n- let columnNodes = (await tableNode.getChildren()) as ColumnNode[]\n+ if (tableNode.table === tableName) {\n+ const columnNodes = (await tableNode.getChildren()) as ColumnNode[];\nlet hoverContent = `${tableNode.database}.${tableName}:`;\nfor (const columnNode of columnNodes) {\nhoverContent += `\n-${columnNode.column.COLUMN_NAME} ${columnNode.column.COLUMN_TYPE} ${columnNode.column.COLUMN_COMMENT?'comment '+columnNode.column.COLUMN_COMMENT:''} `\n+${columnNode.column.COLUMN_NAME} ${columnNode.column.COLUMN_TYPE} ${columnNode.column.COLUMN_COMMENT ? \"comment \" + columnNode.column.COLUMN_COMMENT : \"\"} `;\n}\n- let markdownStr=new vscode.MarkdownString()\n- markdownStr.appendCodeblock(hoverContent,'sql')\n- return new vscode.Hover(markdownStr)\n+ const markdownStr = new vscode.MarkdownString();\n+ markdownStr.appendCodeblock(hoverContent, \"sql\");\n+ return new vscode.Hover(markdownStr);\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -87,9 +87,9 @@ export class QueryPage {\n})\nqueryParam.res.primaryKey = primaryKey\nqueryParam.res.columnList = columnList\n- queryParam.res.database = conn.database\n- queryParam.res.table = tableName\n}\n+ queryParam.res.table = tableName\n+ queryParam.res.database = conn.database\n}\nprivate static getTable(sql: string): string {\n"
},
{
"change_type": "MODIFY",
"old_path": "tslint.json",
"new_path": "tslint.json",
"diff": "200\n],\n\"no-empty\": false,\n- \"object-literal-sort-keys\": false\n+ \"object-literal-sort-keys\": false,\n+ \"interface-name\": false,\n+ \"triple-equals\": false,\n+ \"member-ordering\": false,\n+ \"no-trailing-whitespace\": false,\n+ \"quotemark\": false,\n+ \"no-consecutive-blank-lines\": false\n}\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
create responsibility chain for complection
|
141,908 |
10.04.2020 19:13:34
| -28,800 |
08ca30a0458a3ff7ac326dedd247c095c4ad2569
|
add table detecher chain
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "white-space: nowrap !important;\nuser-select: text !important;\n}\n+\n.info-panel {\ncolor: #444;\nfont-size: 16px;\n<el-row>\n<el-cow>\n<el-button type=\"info\" icon=\"el-icon-circle-plus-outline\" size=\"mini\" circle @click=\"insertRequest\"\n- v-if=\"result.table\">\n+ v-if=\"result.primaryKey\">\n</el-button>\n</el-cow>\n<el-cow>\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/CompletionProvider.ts",
"new_path": "src/provider/Complection/CompletionProvider.ts",
"diff": "@@ -6,6 +6,8 @@ import { TableChain } from \"./chain/tableChain\";\nimport { TableCreateChain } from \"./chain/TableCreateChain\";\nimport { TypeKeywordChain } from \"./chain/typeKeywordChain\";\nimport { ComplectionChain, ComplectionContext } from \"./complectionContext\";\n+import { TableDetecherChain } from \"./chain/tableDetecherChain\";\n+import { FunctionChain } from \"./chain/functionChain\";\nexport class CompletionProvider implements vscode.CompletionItemProvider {\nconstructor() {\n@@ -23,6 +25,8 @@ export class CompletionProvider implements vscode.CompletionItemProvider {\nnew DatabaseChain(),\nnew TableChain(),\nnew ColumnChain(),\n+ new FunctionChain(),\n+ new TableDetecherChain(),\nnew KeywordChain(),\n];\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/functionChain.ts",
"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\", \"MD5\", \"SHA\", \"CURRENT_DATE\", \"DATE_FORMAT\", \"CAST\"];\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+ return this.functionComplectionItems;\n+ }\n+\n+ public stop(): boolean {\n+ return false;\n+ }\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/tableCreateChain.ts",
"new_path": "src/provider/Complection/chain/tableCreateChain.ts",
"diff": "@@ -23,7 +23,7 @@ export class TableCreateChain implements ComplectionChain {\n}\npublic stop(): boolean {\n- return true;\n+ return false;\n}\n}\n"
},
{
"change_type": "ADD",
"old_path": null,
"new_path": "src/provider/Complection/chain/tableDetecherChain.ts",
"diff": "+import * as vscode from \"vscode\";\n+import { ComplectionChain, ComplectionContext } from \"../complectionContext\";\n+\n+export class TableDetecherChain implements ComplectionChain {\n+\n+ public getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]> {\n+\n+ if (complectionContext.preWord && complectionContext.preWord.match(/\\b(select|on|where)\\b/ig)) {\n+\n+ let tableMatch = /(from|join)\\s*(\\w+)/ig\n+\n+ return [new vscode.CompletionItem(\"test\", vscode.CompletionItemKind.Class)];\n+ }\n+\n+ return null;\n+ }\n+\n+ public stop(): boolean {\n+ return true;\n+ }\n+\n+\n+\n+}\n\\ No newline at end of file\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/typeKeywordChain.ts",
"new_path": "src/provider/Complection/chain/typeKeywordChain.ts",
"diff": "@@ -3,7 +3,7 @@ import {ComplectionChain, ComplectionContext} from \"../complectionContext\";\nexport class TypeKeywordChain implements ComplectionChain {\n- private typeList: string[] = [\"INTEGER\", \"char\", \"varchar\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"];\n+ private typeList: string[] = [\"INTEGER\", \"char\", \"varchar\", \"decimal\", \"smallint\", \"tinyint\", \"MEDIUMINT\", \"bigint\", \"numeric\", \"bit\", \"int\", \"float\", \"double\", \"TEXT\", \"SET\", \"blob\", \"timestamp\", \"date\", \"time\", \"YEAR\", \"datetime\"];\nprivate typeComplectionItems: vscode.CompletionItem[] = [];\nprivate needStop = false;\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
add table detecher chain
|
141,908 |
10.04.2020 21:57:20
| -28,800 |
27ad4324c3b6177201106ec85dd4a6425cb072c2
|
implment complection fully
|
[
{
"change_type": "MODIFY",
"old_path": "src/database/QueryUnit.ts",
"new_path": "src/database/QueryUnit.ts",
"diff": "@@ -112,7 +112,7 @@ export class QueryUnit {\nfor (let sql of sqlList) {\nindex += (sql.length + 1)\nif (doc_cursor < index) {\n- return sql.trim() + \";\";\n+ return sql.trim();\n}\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/extension.ts",
"new_path": "src/extension.ts",
"diff": "@@ -46,7 +46,7 @@ export function activate(context: vscode.ExtensionContext) {\ncontext.subscriptions.push(\nvscode.languages.registerDocumentRangeFormattingEditProvider('sql', new SqlFormatProvider()),\nvscode.languages.registerHoverProvider('sql', new TableHoverProvider()),\n- vscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.'),\n+ vscode.languages.registerCompletionItemProvider('sql', new CompletionProvider(), ' ', '.',\">\",\"<\",\"=\",\"(\"),\nvscode.commands.registerCommand(CommandKey.Refresh, () => {\nmysqlTreeDataProvider.init()\n}),\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/columnChain.ts",
"new_path": "src/provider/Complection/chain/columnChain.ts",
"diff": "@@ -9,11 +9,16 @@ export class ColumnChain implements ComplectionChain {\nif (complectionContext.preChart === \".\") {\nlet subComplectionItems = await this.generateColumnComplectionItem(complectionContext.preWord);\n- const tableReg = new RegExp(\"`{0,1}(\\\\w|-)+`{0,1}(?=\\\\s*\\\\b\" + complectionContext.preWord + \"\\\\b)\", \"ig\");\n- let result = tableReg.exec(complectionContext.currentSql);\n+ const tableReg = new RegExp(\"\\\\b(from|join)\\\\b\\\\s*`{0,1}(\\\\w|\\.|-)+`{0,1}(?=\\\\s*\\\\b\" + complectionContext.preWord + \"\\\\b)\", \"ig\");\n+ let result = tableReg.exec(complectionContext.currentSqlFull);\nfor (; result != null && subComplectionItems.length === 0;) {\n- subComplectionItems = await this.generateColumnComplectionItem(result[0].replace(/`/ig, \"\"));\n- result = tableReg.exec(complectionContext.currentSql);\n+ subComplectionItems = await this.generateColumnComplectionItem(\n+ result[0].trim().replace(/(\\w|\\s)*\\./, \"\").replace(/`/ig, \"\")\n+ );\n+ if (subComplectionItems.length > 0) {\n+ break;\n+ }\n+ result = tableReg.exec(complectionContext.currentSqlFull);\n}\nreturn subComplectionItems;\n}\n@@ -43,7 +48,7 @@ export class ColumnChain implements ComplectionChain {\nconst completionItem = new vscode.CompletionItem(columnNode.getTreeItem().columnName);\ncompletionItem.detail = columnNode.getTreeItem().detail;\ncompletionItem.documentation = columnNode.getTreeItem().document;\n- completionItem.kind = vscode.CompletionItemKind.Function;\n+ completionItem.kind = vscode.CompletionItemKind.Field;\nreturn completionItem;\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/databaseChain.ts",
"new_path": "src/provider/Complection/chain/databaseChain.ts",
"diff": "@@ -3,7 +3,7 @@ import {DatabaseCache} from \"../../../database/DatabaseCache\";\nimport {ComplectionChain, ComplectionContext} from \"../complectionContext\";\nfunction wrap(origin: string): string {\n- if (origin != null && origin.match(/\\b(-)\\b/ig)) {\n+ if (origin != null && origin.match(/\\b(-|\\.)\\b/ig)) {\nreturn `\\`${origin}\\``;\n}\nreturn origin;\n@@ -28,7 +28,7 @@ export class DatabaseChain implements ComplectionChain {\nreturn databaseNodes.map<vscode.CompletionItem>((databaseNode) => {\nconst label = databaseNode.getTreeItem().label;\nconst completionItem = new vscode.CompletionItem(label);\n- completionItem.kind = vscode.CompletionItemKind.Struct;\n+ completionItem.kind = vscode.CompletionItemKind.Folder;\ncompletionItem.insertText = wrap(label);\nreturn completionItem;\n});\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/functionChain.ts",
"new_path": "src/provider/Complection/chain/functionChain.ts",
"diff": "@@ -13,9 +13,20 @@ export class FunctionChain implements ComplectionChain {\n});\n}\npublic getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] {\n+ if (\n+ (complectionContext.preWord && complectionContext.preWord.match(/\\b(select|HAVING|where|and|,|=|<|>)\\b/ig))\n+ ||\n+ (complectionContext.currentWord && complectionContext.currentWord.match(/(<|>|,|=)$/))\n+ ) {\n+\n+ let tableMatch = /(from|join)\\s*(\\w+)/ig\n+\nreturn this.functionComplectionItems;\n}\n+ return null;\n+ }\n+\npublic stop(): boolean {\nreturn false;\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/tableDetecherChain.ts",
"new_path": "src/provider/Complection/chain/tableDetecherChain.ts",
"diff": "@@ -5,11 +5,26 @@ export class TableDetecherChain implements ComplectionChain {\npublic getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]> {\n- if (complectionContext.preWord && complectionContext.preWord.match(/\\b(select|on|where)\\b/ig)) {\n-\n- let tableMatch = /(from|join)\\s*(\\w+)/ig\n+ const tableMatch = new RegExp('(from|join)\\\\s*((\\\\w|\\\\.)+)( *)?(\\\\w+)?', 'ig');\n+ if (\n+ (complectionContext.preWord && complectionContext.preWord.match(/\\b(select|HAVING|\\(|on|where|and|,|=|<|>)\\b/ig))\n+ ||\n+ (complectionContext.currentWord && complectionContext.currentWord.match(/(<|>|,|=)$/))\n+ ) {\n+ let completionItem = []\n+ let result = tableMatch.exec(complectionContext.currentSqlFull)\n+ while (result != null) {\n+ const alias = result[5];\n+ if (alias) {\n+ completionItem.push(new vscode.CompletionItem(alias, vscode.CompletionItemKind.Interface))\n+ } else {\n+ const tableName = result[2].replace(/\\w*?\\./, \"\")\n+ completionItem.push(new vscode.CompletionItem(tableName, vscode.CompletionItemKind.Interface))\n+ }\n+ result = tableMatch.exec(complectionContext.currentSqlFull)\n+ }\n- return [new vscode.CompletionItem(\"test\", vscode.CompletionItemKind.Class)];\n+ return completionItem;\n}\nreturn null;\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/complectionContext.ts",
"new_path": "src/provider/Complection/complectionContext.ts",
"diff": "@@ -9,21 +9,23 @@ export interface ComplectionChain {\nexport class ComplectionContext {\n- public preWord: string;\npublic preChart: string;\n+ public preWord: string;\npublic currentWord: string;\npublic currentSql: string;\n+ public currentSqlFull: string;\npublic static build(document: vscode.TextDocument, position: vscode.Position): ComplectionContext {\nconst context = new ComplectionContext();\nconst currentSql = QueryUnit.obtainCursorSql(document, position).trim();\nif (!currentSql) return context;\n+ context.currentSqlFull = QueryUnit.obtainCursorSql(document, position, document.getText()).trim();\nconst prePostion = position.character === 0 ? position : new vscode.Position(position.line, position.character - 1);\nconst preChart = position.character === 0 ? null : document.getText(new vscode.Range(prePostion, position));\n- const wordMatch = currentSql.match(/(\\w|-)+/ig);\n+ const wordMatch = currentSql.match(/(\\w|-|\\_)+/g);\nif (wordMatch) {\nif ((preChart == null || preChart == \" \" || preChart == \".\") && wordMatch.length >= 1) {\ncontext.preWord = wordMatch[wordMatch.length - 1]\n@@ -31,6 +33,9 @@ export class ComplectionContext {\ncontext.preWord = wordMatch[wordMatch.length - 2]\n}\n}\n+ const codeMatch = currentSql.match(/(\\w|=|<|>|\\()+$/)\n+ if (codeMatch)\n+ context.currentWord = codeMatch[0]\ncontext.preChart = preChart;\ncontext.currentSql = currentSql.trim();\n"
},
{
"change_type": "MODIFY",
"old_path": "tsconfig.json",
"new_path": "tsconfig.json",
"diff": "\"target\": \"es6\",\n\"outDir\": \"out\",\n\"lib\": [\n- \"es6\"\n+ \"es6\",\n+ \"es2017\"\n],\n\"sourceMap\": true,\n\"rootDir\": \"src\"\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
implment complection fully
|
141,908 |
10.04.2020 22:39:25
| -28,800 |
bfeef8b2579a3bc5c1102e8b0baebb3b05b9550f
|
support sort and change logo
|
[
{
"change_type": "MODIFY",
"old_path": "README.md",
"new_path": "README.md",
"diff": "# MySQL\n-[](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-mysql-manager) [](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-mysql-manager) [](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-mysql-manager) [](https://travis-ci.org/formulahendry/vscode-mysql)\n+[](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-mysql-manager) [](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-mysql-manager) [](https://marketplace.visualstudio.com/items?itemName=cweijan.vscode-mysql-manager) [](https://travis-ci.org/cweijan/vscode-mysql)\nMySQL management tool Plus\n-> This plugin forked from [MySQL](https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-mysql)\n+> This plugin base of [MySQL](https://marketplace.visualstudio.com/items?itemName=formulahendry.vscode-mysql)\n>\n> Many amazing improvements have been made\n>\n> Welcome to contribute in [repository](https://github.com/cweijan/vscode-mysql)\n->\n-> You can see changes in the [changelog](/CHANGELOG.md)\n## Features\n"
},
{
"change_type": "MODIFY",
"old_path": "logo.png",
"new_path": "logo.png",
"diff": "Binary files a/logo.png and b/logo.png differ\n"
},
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -6,7 +6,7 @@ import { DatabaseCache } from \"../../database/DatabaseCache\";\nimport { QueryUnit } from \"../../database/QueryUnit\";\nimport { IConnection } from \"../../model/Connection\";\nimport { ColumnNode } from \"../../model/table/columnNode\";\n-import { DataResponse, ErrorResponse, DMLResponse } from \"./queryResponse\";\n+import { DataResponse } from \"./queryResponse\";\nexport class QueryParam<T> {\ntype: MessageType;\n@@ -31,13 +31,12 @@ export class QueryPage {\nqueryParam.res.message=`EXECUTE SUCCESS:<br><br> ${queryParam.res.sql}<br><br>AffectedRows : ${queryParam.res.affectedRows}, CostTime : ${queryParam.res.costTime}ms`\nbreak;\ncase MessageType.ERROR:\n- queryParam.res.message=`EXECUTE Fail:<br><br> ${queryParam.res.sql}<br><br>message :<br> ${queryParam.res.message}`\n+ queryParam.res.message=`EXECUTE FAIL:<br><br> ${queryParam.res.sql}<br><br>Message :<br><br> ${queryParam.res.message}`\nbreak;\n}\nthis.sendData = queryParam\nif (this.creating) return;\n- // TODO support delimiter : const _sql = sql.toString().replace(/DELIMITER ;?;/gm, '').replace(/;;/gm, ';')\n// update result webview\nif (this.resultWebviewPanel) {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support sort and change logo
|
141,908 |
11.04.2020 01:21:47
| -28,800 |
227704189e0e932825a83923a46a70ec3eff943b
|
support filter in page
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "<!-- tool bar -->\n<el-table-column fixed=\"left\" label=\"Operations\" width=\"100\" v-if=\"result.primaryKey\">\n<template slot-scope=\"scope\">\n- <el-button @click=\"openEdit(scope.row)\" type=\"primary\" size=\"small\" icon=\"el-icon-edit\" circle>\n+ <div v-if=\"scope.row.isFilter\" style=\"text-align: center;\">\n+ Filter\n+ </div>\n+ <div v-if=\"scope.row[result.primaryKey]\">\n+ <el-button @click=\"openEdit(scope.row)\" type=\"primary\" size=\"small\" icon=\"el-icon-edit\"\n+ circle>\n</el-button>\n<el-button @click=\"deleteConfirm(scope.row[result.primaryKey])\" type=\"danger\" size=\"small\"\nicon=\"el-icon-delete\" circle>\n</el-button>\n+ </div>\n</template>\n</el-table-column>\n<!-- table view -->\n- <el-table-column :label=\"column\" v-for=\"(column) in result.columnList\" :key=\"column\" align=\"center\"\n+ <el-table-column :label=\"column\" v-for=\"column in result.columnList\" :key=\"column\" align=\"center\"\nsortable v-if=\"result.columnList\" :width=\"computeWidth(column)\">\n<template slot-scope=\"scope\">\n- <span v-html='dataformat(scope.row[column])'></span>\n+ <el-input v-if=\"scope.row.isFilter\" v-model=\"toolbar.filter[column]\"\n+ @blur=\"filter($event,column)\"></el-input>\n+ <span v-if=\"!scope.row.isFilter\" v-html='dataformat(scope.row[column])'></span>\n</template>\n</el-table-column>\n<!-- sql view -->\ntoolbar: {\nsql: null,\ncostTime: 0,\n- isRefrsh: false\n+ isRefrsh: false,\n+ filter: {}\n},\neditor: {\nvisible: false,\n}\n},\nmethods: {\n+ filter(event, column) {\n+\n+ let inputvalue = \"\" + event.target.value\n+\n+ let filterSql = this.result.sql.replace(/\\n/, \" \").replace(\";\", \"\")\n+\n+ let existsCheck = new RegExp(`(WHERE|AND)?\\\\s*${column}\\\\s*=\\\\s*.+?\\\\s`, 'igm');\n+\n+ if (inputvalue) {\n+ inputValue = \"\" + inputvalue\n+ if (existsCheck.exec(filterSql)) {\n+ // condition present\n+ filterSql = filterSql.replace(existsCheck, `$1 ${column}='${inputValue}' `)\n+ } else if (filterSql.match(/\\bwhere\\b/ig) && inputvalue) {\n+ //have where\n+ filterSql = filterSql.replace(/\\b(where)\\b/ig, `\\$1 ${column}='${inputvalue}' AND `)\n+ } else if (inputvalue) {\n+ //have not where\n+ filterSql = filterSql.replace(new RegExp(`(from\\\\s*.+?)\\\\s`, 'ig'), `\\$1 WHERE ${column}='${inputvalue}' `)\n+ }\n+ } else {\n+ // empty value, clear filter\n+ let beforeAndCheck = new RegExp(`${column}\\\\s*=\\\\s*.+?\\\\s*AND`, 'igm');\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+ },\nsort(row) {\nlet order = row.order == 'ascending' ? \"asc\" : \"desc\"\nlet sortSql = this.result.sql\n- .replace(\";\",\"\")\n+ .replace(/\\n/, \" \").replace(\";\", \"\")\n.replace(/order by .+? (desc|asc)?/ig, \"\")\n.replace(/\\s?(limit.+)?$/i, ` ORDER BY ${row.column.label} ${order} \\$1 `)\n- this.execute(sortSql)\n+ this.execute(sortSql + \";\")\n},\ninsertRequest() {\nthis.editor.visible = true;\nreturn dynamic;\n},\ncelledit(row, column, cell, event) {\n+ if (row.isFilter) {\n+ return;\n+ }\ncell.contentEditable = true;\nif (this.result.primaryKey) {\nthis.update.primary = row[this.result.primaryKey]\nvue.table.widthItem = {}\nvue.result = data;\nvue.table.loading = false\n+ if (!data.sql.match(/\\bwhere\\b/ig)) {\n+ // clear filter\n+ vue.toolbar.filter = {}\n+ }\n+ if (vue.result.columnList) {\n+ // add filter row\n+ vue.result.data.unshift({ isFilter: true, content: '' })\n+ }\nif (vue.toolbar.isRefrsh) {\nvue.toolbar.isRefrsh = false;\n} else {\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
support filter in page
|
141,908 |
11.04.2020 01:43:31
| -28,800 |
f4d025491c55dcaee86f150ab0b13f7513c9cd6f
|
regex add edge check
|
[
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/tableChain.ts",
"new_path": "src/provider/Complection/chain/tableChain.ts",
"diff": "@@ -48,7 +48,7 @@ export class TableChain implements ComplectionChain {\ntableNodes = DatabaseCache.getTableNodeList().filter((tableNode) => {\nconst included = tableNames.includes(tableNode.table);\ntableNames.push(tableNode.table);\n- return !included && !tableNode.database.match(/(mysql|performance_schema|information_schema|sys)/ig);\n+ return !included && !tableNode.database.match(/\\b(mysql|performance_schema|information_schema|sys)\\b/ig);\n});\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/tableDetecherChain.ts",
"new_path": "src/provider/Complection/chain/tableDetecherChain.ts",
"diff": "@@ -5,7 +5,7 @@ export class TableDetecherChain implements ComplectionChain {\npublic getComplection(complectionContext: ComplectionContext): vscode.CompletionItem[] | Promise<vscode.CompletionItem[]> {\n- const tableMatch = new RegExp('(from|join)\\\\s*((\\\\w|\\\\.)+)( *)?(\\\\w+)?', 'ig');\n+ const tableMatch = new RegExp('\\b(from|join)\\b\\\\s*((\\\\w|\\\\.)+)( *)?(\\\\w+)?', 'ig');\nif (\n(complectionContext.preWord && complectionContext.preWord.match(/\\b(select|HAVING|\\(|on|where|and|,|=|<|>)\\b/ig))\n||\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/Complection/chain/typeKeywordChain.ts",
"new_path": "src/provider/Complection/chain/typeKeywordChain.ts",
"diff": "@@ -21,7 +21,7 @@ export class TypeKeywordChain implements ComplectionChain {\nthis.needStop = true;\nreturn this.typeComplectionItems;\n}\n- if (sql && sql.match(/(FUNCTION|PROCEDURE)/ig)) {\n+ if (sql && sql.match(/\\b(FUNCTION|PROCEDURE)\\b/ig)) {\nthis.needStop = false;\nreturn this.typeComplectionItems;\n}\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
regex add edge check
|
141,908 |
11.04.2020 01:57:37
| -28,800 |
b73030a3a3de7011f8c4ff2c2fe0f811e2548adf
|
load table info when execute sql
|
[
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -72,10 +72,12 @@ export class QueryPage {\n}\nprivate static async loadTableInfo(queryParam: QueryParam<DataResponse>) {\nlet conn = queryParam.connection\n- let tableName = this.getTable(queryParam.res.sql)\n+ let info = this.getTable(queryParam.res.sql)\n+ const tableName = info.table\n+ const database = info.database\nif (tableName == null || conn == null) return;\n// load table infomation\n- let tableNode = DatabaseCache.getTable(`${conn.host}_${conn.port}_${conn.user}_${conn.database}`, tableName)\n+ let tableNode = DatabaseCache.getTable(`${conn.host}_${conn.port}_${conn.user}_${database ? database : conn.database}`, tableName)\nif (tableNode) {\nlet primaryKey: string;\nlet columnList = (await tableNode.getChildren()).map((columnNode: ColumnNode) => {\n@@ -91,21 +93,24 @@ export class QueryPage {\nqueryParam.res.database = conn.database\n}\n- private static getTable(sql: string): string {\n+ private static getTable(sql: string): TableInfo {\nif (!sql) return null;\n- let baseMatch;\n+ let tableInfo = new TableInfo()\n+ let baseMatch: string[];\nif (sql && (baseMatch = (sql + \" \").match(/select\\s+\\*\\s+from\\s*(.+?)(?=[\\s;])/i)) && !sql.match(/\\bjoin\\b/ig)) {\n- let expectTable: string = baseMatch[1];\n- let temp: string[], table;\n- if (expectTable.includes(\"`\")) {\n- temp = expectTable.split(\"`\");\n- table = temp[temp.length - 2];\n- } else {\n- temp = expectTable.split(\".\")\n- table = temp[temp.length - 1]\n+ let expectTable: string = baseMatch[1].replace(/`/g, \"\");\n+ let temp: string[] = expectTable.split(\".\")\n+ if (temp.length == 2) {\n+ tableInfo.database = temp[0]\n+ tableInfo.table = temp[1]\n+ }\n+ return tableInfo;\n}\n- return table;\n}\n+\n}\n+class TableInfo {\n+ public database: string;\n+ public table: string;\n}\n\\ No newline at end of file\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
load table info when execute sql
|
141,908 |
11.04.2020 02:57:51
| -28,800 |
69fd52a2b6f3425605fd5043607c61e38304edba
|
load column info in page
|
[
{
"change_type": "MODIFY",
"old_path": "src/model/table/columnNode.ts",
"new_path": "src/model/table/columnNode.ts",
"diff": "@@ -33,13 +33,13 @@ export class ColumnNode implements INode, IConnection {\npublic getTreeItem(): ColumnTreeItem {\nreturn {\n- columnName: `${this.column.COLUMN_NAME}`,\n- detail: `${this.column.COLUMN_TYPE}`,\n- document: `${this.column.COLUMN_COMMENT}`,\n- label: `${this.column.COLUMN_NAME} : ${this.column.COLUMN_TYPE} ${this.getIndex(this.column.COLUMN_KEY)} ${this.column.COLUMN_COMMENT}`,\n+ columnName: `${this.column.name}`,\n+ detail: `${this.column.type}`,\n+ document: `${this.column.comment}`,\n+ label: `${this.column.name} : ${this.column.type} ${this.getIndex(this.column.key)} ${this.column.comment}`,\ncollapsibleState: vscode.TreeItemCollapsibleState.None,\ncontextValue: ModelType.COLUMN,\n- iconPath: path.join(Constants.RES_PATH, this.column.COLUMN_KEY === \"PRI\" ? \"b_primary.png\" : \"b_props.png\"),\n+ iconPath: path.join(Constants.RES_PATH, this.column.key === \"PRI\" ? \"b_primary.png\" : \"b_props.png\"),\ncommand: {\ncommand: \"mysql.column.update\",\ntitle: \"Update Column Statement\",\n@@ -54,10 +54,10 @@ export class ColumnNode implements INode, IConnection {\npublic async changeColumnName() {\n- const columnName = this.column.COLUMN_NAME\n+ const columnName = this.column.name\nvscode.window.showInputBox({ value: columnName, placeHolder: 'newColumnName', prompt: `You will changed ${this.table}.${columnName} to new column name!` }).then(async newColumnName => {\nif (!newColumnName) return\n- const sql = `alter table \\`${this.database}\\`.\\`${this.table}\\` change column \\`${columnName}\\` \\`${newColumnName}\\` ${this.column.COLUMN_TYPE} comment '${this.column.COLUMN_COMMENT}'`\n+ const sql = `alter table \\`${this.database}\\`.\\`${this.table}\\` change column \\`${columnName}\\` \\`${newColumnName}\\` ${this.column.type} comment '${this.column.comment}'`\nQueryUnit.queryPromise(await ConnectionManager.getConnection(this), sql).then((rows) => {\nDatabaseCache.clearColumnCache(`${this.host}_${this.port}_${this.user}_${this.database}_${this.table}`)\nMySQLTreeDataProvider.refresh()\n@@ -68,11 +68,11 @@ export class ColumnNode implements INode, IConnection {\nupdateColumnTemplate() {\nConnectionManager.getConnection(this, true)\n- QueryUnit.showSQLTextDocument(`ALTER TABLE \\n\\t\\`${this.database}\\`.\\`${this.table}\\` CHANGE \\`${this.column.COLUMN_NAME}\\` \\`${this.column.COLUMN_NAME}\\` ${this.column.COLUMN_TYPE} NOT NULL comment '${this.column.COLUMN_COMMENT}';`);\n+ QueryUnit.showSQLTextDocument(`ALTER TABLE \\n\\t\\`${this.database}\\`.\\`${this.table}\\` CHANGE \\`${this.column.name}\\` \\`${this.column.name}\\` ${this.column.type} NOT NULL comment '${this.column.comment}';`);\n}\ndropColumnTemplate() {\nConnectionManager.getConnection(this, true)\n- QueryUnit.createSQLTextDocument(`ALTER TABLE \\n\\t\\`${this.database}\\`.\\`${this.table}\\` DROP COLUMN \\`${this.column.COLUMN_NAME}\\`;`);\n+ QueryUnit.createSQLTextDocument(`ALTER TABLE \\n\\t\\`${this.database}\\`.\\`${this.table}\\` DROP COLUMN \\`${this.column.name}\\`;`);\n}\n"
},
{
"change_type": "MODIFY",
"old_path": "src/model/table/tableNode.ts",
"new_path": "src/model/table/tableNode.ts",
"diff": "@@ -45,7 +45,7 @@ export class TableNode implements INode, IConnection {\nif (columnNodes && !isRresh) {\nreturn columnNodes;\n}\n- return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT COLUMN_NAME,COLUMN_TYPE,COLUMN_COMMENT,COLUMN_TYPE,COLUMN_KEY FROM information_schema.columns WHERE table_schema = '${this.database}' AND table_name = '${this.table}';`)\n+ return QueryUnit.queryPromise<any[]>(await ConnectionManager.getConnection(this), `SELECT COLUMN_NAME name,COLUMN_TYPE type,COLUMN_COMMENT comment,COLUMN_KEY \\`key\\`,IS_NULLABLE nullable,CHARACTER_MAXIMUM_LENGTH maxLength FROM information_schema.columns WHERE table_schema = '${this.database}' AND table_name = '${this.table}';`)\n.then((columns) => {\ncolumnNodes = columns.map<ColumnNode>((column) => {\nreturn new ColumnNode(this.host, this.user, this.password, this.port, this.database, this.table, this.certPath, column);\n@@ -126,7 +126,7 @@ ADD\nQueryUnit.showSQLTextDocument(`-- ALTER TABLE \\`${this.database}\\`.\\`${this.table}\\` DROP INDEX [indexName];\n-- ALTER TABLE \\`${this.database}\\`.\\`${this.table}\\` ADD [UNIQUE|KEY|PRIMARY KEY] INDEX ([column]);`)\nsetTimeout(() => {\n- QueryUnit.runQuery(`SELECT column_name,table_schema,index_name,non_unique FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema='${this.database}' and table_name='${this.table}';`, this)\n+ QueryUnit.runQuery(`SELECT name,table_schema,index_name,non_unique FROM INFORMATION_SCHEMA.STATISTICS WHERE table_schema='${this.database}' and table_name='${this.table}';`, this)\n}, 10);\n}\n@@ -148,7 +148,7 @@ ADD\nthis\n.getChildren()\n.then((children: INode[]) => {\n- const childrenNames = children.map((child: any) => \"\\n \"+child.column.COLUMN_NAME);\n+ const childrenNames = children.map((child: any) => \"\\n \"+child.column.name);\nlet sql = `insert into \\n \\`${this.database}\\`.${this.table} `\nsql += `(${childrenNames.toString().replace(/,/g, \", \")}\\n )\\n`\nsql += \"values\\n \"\n@@ -161,7 +161,7 @@ ADD\nthis\n.getChildren()\n.then((children: INode[]) => {\n- const keysNames = children.filter((child: any) => child.column.COLUMN_KEY).map((child: any) => child.column.COLUMN_NAME);\n+ const keysNames = children.filter((child: any) => child.column.key).map((child: any) => child.column.name);\nconst where = keysNames.map((name: string) => `${name} = ${name}`);\n@@ -175,8 +175,8 @@ ADD\nthis\n.getChildren()\n.then((children: INode[]) => {\n- const keysNames = children.filter((child: any) => child.column.COLUMN_KEY).map((child: any) => child.column.COLUMN_NAME);\n- const childrenNames = children.filter((child: any) => !child.column.COLUMN_KEY).map((child: any) => child.column.COLUMN_NAME);\n+ const keysNames = children.filter((child: any) => child.column.key).map((child: any) => child.column.name);\n+ const childrenNames = children.filter((child: any) => !child.column.key).map((child: any) => child.column.name);\nconst sets = childrenNames.map((name: string) => `${name} = ${name}`);\nconst where = keysNames.map((name: string) => `${name} = '${name}'`);\n"
},
{
"change_type": "MODIFY",
"old_path": "src/provider/TableHoverProvider.ts",
"new_path": "src/provider/TableHoverProvider.ts",
"diff": "@@ -14,7 +14,7 @@ export class TableHoverProvider implements HoverProvider {\nlet hoverContent = `${tableNode.database}.${tableName}:`;\nfor (const columnNode of columnNodes) {\nhoverContent += `\n-${columnNode.column.COLUMN_NAME} ${columnNode.column.COLUMN_TYPE} ${columnNode.column.COLUMN_COMMENT ? \"comment \" + columnNode.column.COLUMN_COMMENT : \"\"} `;\n+${columnNode.column.name} ${columnNode.column.type} ${columnNode.column.comment ? \"comment \" + columnNode.column.comment : \"\"} `;\n}\nconst markdownStr = new vscode.MarkdownString();\nmarkdownStr.appendCodeblock(hoverContent, \"sql\");\n"
},
{
"change_type": "MODIFY",
"old_path": "src/view/result/query.ts",
"new_path": "src/view/result/query.ts",
"diff": "@@ -81,10 +81,10 @@ export class QueryPage {\nif (tableNode) {\nlet primaryKey: string;\nlet columnList = (await tableNode.getChildren()).map((columnNode: ColumnNode) => {\n- if (columnNode.column.COLUMN_KEY === \"PRI\") {\n- primaryKey = columnNode.column.COLUMN_NAME\n+ if (columnNode.column.key === \"PRI\") {\n+ primaryKey = columnNode.column.name\n}\n- return columnNode.column.COLUMN_NAME\n+ return columnNode.column\n})\nqueryParam.res.primaryKey = primaryKey\nqueryParam.res.columnList = columnList\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
load column info in page
|
141,908 |
11.04.2020 14:17:20
| -28,800 |
236399e2652501488fe7e39a6354d5e0971db1e4
|
hight edit column
|
[
{
"change_type": "MODIFY",
"old_path": "resources/webview/result.html",
"new_path": "resources/webview/result.html",
"diff": "height: 100px;\nbackground-color: #ccc; */\n}\n+\n+ .el-table .edit-row{\n+ background: oldlace;\n+ }\n+\n</style>\n</head>\n<body>\n<div id=\"app\">\n<div class=\"hint\">\n+ <!-- sql input -->\n<el-row style=\"margin-bottom: 10px;\">\n<el-input type=\"textarea\" autosize v-model=\"toolbar.sql\" style=\"width: 600px;\"></el-input>\n</el-row>\n+ <!-- tool panel -->\n<el-row>\n<el-cow>\n<el-button type=\"info\" icon=\"el-icon-circle-plus-outline\" size=\"mini\" circle @click=\"insertRequest\"\n<span v-if=\"result.table\">, Row: {{result.data.length}}, Col: {{columnCount}}</span>\n</el-cow>\n</el-row>\n- </div>\n+ <!-- info panel -->\n<div v-if=\"info.visible \">\n<div v-if=\"info.error\" class=\"info-panel\" style=\"color:red\" v-html=\"info.message\"></div>\n<div v-if=\"!info.error\" class=\"info-panel\" style=\"color: green;\" v-html=\"info.message\"></div>\n</div>\n+ </div>\n+ <!-- talbe result -->\n<div :style=\"'width:' + table.width + 'px;overflow:scroll'\" v-if=\"result.data\">\n<el-table id=\"dataTable\" v-loading='table.loading' size='small' @sort-change=\"sort\"\n+ :row-class-name=\"tableRowClassName\"\n:data=\"result.data.filter(data => !table.search || JSON.stringify(data).toLowerCase().includes(table.search.toLowerCase()))\"\nborder @cell-click=\"celledit\">\n<!-- tool bar -->\n</div>\n</template>\n</el-table-column>\n- <!-- table view -->\n+ <!-- table view with table column -->\n<el-table-column :label=\"column.name\" v-for=\"column in result.columnList\" :key=\"column.name\"\n- align=\"center\" sortable v-if=\"result.columnList\" :width=\"computeWidth(column.name,0,toolbar.filter[column.name])\">\n+ align=\"center\" sortable v-if=\"result.columnList\"\n+ :width=\"computeWidth(column.name,0,toolbar.filter[column.name])\">\n<template slot-scope=\"scope\">\n<el-input v-if=\"scope.row.isFilter\" v-model=\"toolbar.filter[column.name]\"\n- @blur=\"filter($event,column.name)\" v-on:keyup.enter.native=\"filter($event,column.name)\" ></el-input>\n+ @blur=\"filter($event,column.name)\" v-on:keyup.enter.native=\"filter($event,column.name)\">\n+ </el-input>\n<span v-if=\"!scope.row.isFilter\" v-html='dataformat(scope.row[column.name])'></span>\n</template>\n</el-table-column>\n- <!-- sql view -->\n+ <!-- table view without tale column -->\n<el-table-column :label=\"key\" v-for=\"(value,key) in result.data[0]\" :key=\"key\" align=\"center\"\nv-if=\"!result.columnList\" :width=\"computeWidth(key,0,toolbar.filter[column.name])\">\n<template slot-scope=\"scope\">\nthis.$message({ type: 'info', message: 'Update canceled' });\n});\n},\n+ tableRowClassName({ row, rowIndex }) {\n+ if (!this.result.primaryKey || !this.update.primary) return ''\n+ if (row[this.result.primaryKey]==this.update.primary){\n+ return 'edit-row';\n+ }\n+ return '';\n+ },\nupdateWidth() {\nlet width = 0;\nfor (const key in this.table.widthItem) {\nif (this.update.primary == null) {\nreturn 'Insert To ' + this.result.table\n}\n- return 'Edit ' + this.result.table + ' : ' + this.result.primaryKey + '=' + this.update.primary\n+ return 'Edit For ' + this.result.table + ' : ' + this.result.primaryKey + '=' + this.update.primary\n},\n}\n})\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
hight edit column
|
141,908 |
11.04.2020 16:27:45
| -28,800 |
7104482e87da0499e840f681d2282402ae06d253
|
update logo and name
|
[
{
"change_type": "MODIFY",
"old_path": "logo.png",
"new_path": "logo.png",
"diff": "Binary files a/logo.png and b/logo.png differ\n"
},
{
"change_type": "MODIFY",
"old_path": "package.json",
"new_path": "package.json",
"diff": "{\n- \"name\": \"vscode-mysql-manager\",\n+ \"name\": \"vscode-mysql-client\",\n\"displayName\": \"MySQL\",\n- \"description\": \"MySQL management tool\",\n+ \"description\": \"MySQL Client\",\n\"version\": \"1.7.1\",\n\"publisher\": \"cweijan\",\n\"icon\": \"logo.png\",\n"
}
] |
TypeScript
|
MIT License
|
cweijan/vscode-database-client
|
update logo and name
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.