knex 2.4.2 → 2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -21
- package/CONTRIBUTING.md +1 -1
- package/LICENSE +22 -22
- package/README.md +32 -31
- package/UPGRADING.md +94 -82
- package/bin/cli.js +4 -2
- package/bin/utils/cli-config-utils.js +3 -1
- package/knex.mjs +11 -0
- package/lib/client.js +20 -0
- package/lib/dialects/better-sqlite3/index.js +6 -1
- package/lib/dialects/index.js +34 -34
- package/lib/dialects/mssql/index.js +5 -0
- package/lib/dialects/mssql/query/mssql-querycompiler.js +1 -0
- package/lib/dialects/mysql2/index.js +20 -0
- package/lib/dialects/oracle/DEAD_CODE.md +3 -3
- package/lib/dialects/oracle/query/oracle-querycompiler.js +1 -0
- package/lib/dialects/oracledb/index.js +5 -5
- package/lib/dialects/oracledb/schema/oracledb-columncompiler.js +10 -4
- package/lib/dialects/postgres/execution/pg-transaction.js +10 -3
- package/lib/dialects/postgres/index.js +8 -8
- package/lib/dialects/postgres/query/pg-querybuilder.js +5 -0
- package/lib/dialects/postgres/query/pg-querycompiler.js +6 -1
- package/lib/dialects/postgres/schema/pg-tablecompiler.js +9 -4
- package/lib/dialects/redshift/transaction.js +10 -3
- package/lib/dialects/sqlite3/execution/sqlite-transaction.js +7 -0
- package/lib/dialects/sqlite3/schema/internal/sqlite-ddl-operations.js +1 -1
- package/lib/execution/runner.js +18 -0
- package/lib/execution/transaction.js +15 -7
- package/lib/knex-builder/FunctionHelper.js +26 -0
- package/lib/knex-builder/make-knex.js +5 -0
- package/lib/migrations/migrate/stub/cjs.stub +15 -15
- package/lib/migrations/migrate/stub/coffee.stub +13 -13
- package/lib/migrations/migrate/stub/eg.stub +14 -14
- package/lib/migrations/migrate/stub/js-schema.stub +22 -22
- package/lib/migrations/migrate/stub/js.stub +22 -22
- package/lib/migrations/migrate/stub/knexfile-coffee.stub +34 -34
- package/lib/migrations/migrate/stub/knexfile-eg.stub +43 -43
- package/lib/migrations/migrate/stub/knexfile-js.stub +47 -47
- package/lib/migrations/migrate/stub/knexfile-ls.stub +35 -35
- package/lib/migrations/migrate/stub/knexfile-ts.stub +47 -47
- package/lib/migrations/migrate/stub/ls.stub +14 -14
- package/lib/migrations/migrate/stub/mjs.stub +23 -23
- package/lib/migrations/migrate/stub/ts-schema.stub +21 -21
- package/lib/migrations/migrate/stub/ts.stub +21 -21
- package/lib/migrations/seed/stub/coffee.stub +9 -9
- package/lib/migrations/seed/stub/eg.stub +11 -11
- package/lib/migrations/seed/stub/js.stub +13 -13
- package/lib/migrations/seed/stub/ls.stub +11 -11
- package/lib/migrations/seed/stub/mjs.stub +12 -12
- package/lib/migrations/seed/stub/ts.stub +13 -13
- package/lib/query/method-constants.js +1 -0
- package/lib/query/querybuilder.js +24 -25
- package/lib/query/querycompiler.js +11 -0
- package/lib/util/security.js +26 -0
- package/package.json +21 -18
- package/scripts/docker-compose.yml +2 -2
- package/scripts/next-release-howto.md +1 -1
- package/scripts/oracledb-install-driver-libs.sh +82 -82
- package/scripts/release.sh +36 -34
- package/scripts/runkit-example.js +1 -0
- package/scripts/stress-test/README.txt +18 -18
- package/scripts/stress-test/docker-compose.yml +16 -16
- package/scripts/stress-test/knex-stress-test.js +7 -3
- package/scripts/stress-test/mysql2-random-hanging-every-now-and-then.js +7 -3
- package/scripts/stress-test/mysql2-sudden-exit-without-error.js +2 -1
- package/scripts/stress-test/reconnect-test-mysql-based-drivers.js +7 -3
- package/types/index.d.ts +54 -13
- package/types/result.d.ts +10 -10
|
@@ -28,6 +28,7 @@ const {
|
|
|
28
28
|
const debugBindings = debug('knex:bindings');
|
|
29
29
|
|
|
30
30
|
const components = [
|
|
31
|
+
'comments',
|
|
31
32
|
'columns',
|
|
32
33
|
'join',
|
|
33
34
|
'where',
|
|
@@ -50,6 +51,7 @@ class QueryCompiler {
|
|
|
50
51
|
this.method = builder._method || 'select';
|
|
51
52
|
this.options = builder._options;
|
|
52
53
|
this.single = builder._single;
|
|
54
|
+
this.queryComments = builder._comments;
|
|
53
55
|
this.timeout = builder._timeout || false;
|
|
54
56
|
this.cancelOnTimeout = builder._cancelOnTimeout || false;
|
|
55
57
|
this.grouped = groupBy(builder._statements, 'grouping');
|
|
@@ -138,6 +140,7 @@ class QueryCompiler {
|
|
|
138
140
|
case 'union':
|
|
139
141
|
unionStatement = statement;
|
|
140
142
|
break;
|
|
143
|
+
case 'comments':
|
|
141
144
|
case 'columns':
|
|
142
145
|
case 'join':
|
|
143
146
|
case 'where':
|
|
@@ -317,6 +320,14 @@ class QueryCompiler {
|
|
|
317
320
|
);
|
|
318
321
|
}
|
|
319
322
|
|
|
323
|
+
// Add comments to the query
|
|
324
|
+
comments() {
|
|
325
|
+
if (!this.queryComments.length) return '';
|
|
326
|
+
return this.queryComments
|
|
327
|
+
.map((comment) => `/* ${comment.comment} */`)
|
|
328
|
+
.join(' ');
|
|
329
|
+
}
|
|
330
|
+
|
|
320
331
|
_aggregate(stmt, { aliasSeparator = ' as ', distinctParentheses } = {}) {
|
|
321
332
|
const value = stmt.value;
|
|
322
333
|
const method = stmt.method;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets a hidden (non-enumerable) property on the `target` object, copying it
|
|
3
|
+
* from `source`.
|
|
4
|
+
*
|
|
5
|
+
* This is useful when we want to protect certain data from being accidentally
|
|
6
|
+
* leaked through logs, also when the property is non-enumerable on the `source`
|
|
7
|
+
* object and we want to ensure that it is properly copied.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} target
|
|
10
|
+
* @param {object} source - default: target
|
|
11
|
+
* @param {string} propertyName - default: 'password'
|
|
12
|
+
*/
|
|
13
|
+
function setHiddenProperty(target, source, propertyName = 'password') {
|
|
14
|
+
if (!source) {
|
|
15
|
+
source = target;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(target, propertyName, {
|
|
19
|
+
enumerable: false,
|
|
20
|
+
value: source[propertyName],
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
module.exports = {
|
|
25
|
+
setHiddenProperty,
|
|
26
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "knex",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.1",
|
|
4
4
|
"description": "A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3",
|
|
5
5
|
"main": "knex",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -8,18 +8,20 @@
|
|
|
8
8
|
"node": ">=12"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "npm run build:gitignore && npm run build:ts",
|
|
11
|
+
"build": "npm run build:gitignore && npm run build:ts && npm run format",
|
|
12
12
|
"clean": "node scripts/clean.js",
|
|
13
13
|
"build:ts": "tsc",
|
|
14
14
|
"build:gitignore": "node scripts/update_gitignore_for_tsc_output.js run",
|
|
15
|
-
"format": "prettier --write
|
|
16
|
-
"format:check
|
|
15
|
+
"format": "prettier --write --list-different .",
|
|
16
|
+
"format:check": "prettier --list-different .",
|
|
17
17
|
"debug:test": "mocha --inspect-brk --exit -t 0 test/all-tests-suite.js",
|
|
18
18
|
"debug:tape": "node --inspect-brk test/tape/index.js",
|
|
19
19
|
"coveralls": "nyc report --reporter=lcov",
|
|
20
|
-
"lint": "eslint
|
|
20
|
+
"lint": "eslint --cache \"**/*.js\"",
|
|
21
|
+
"lint:fix": "eslint --cache --fix \"**/*.js\"",
|
|
21
22
|
"lint:types": "tsd && dtslint types",
|
|
22
|
-
"lint:everything": "npm run lint
|
|
23
|
+
"lint:everything": "npm run lint && npm run lint:types",
|
|
24
|
+
"lint:fix:everything": "npm run lint:fix && npm run lint:types",
|
|
23
25
|
"test:unit": "npm run test:unit-only && npm run test:cli",
|
|
24
26
|
"test:unit-only": "mocha --exit -t 10000 --config test/mocha-unit-config-test.js",
|
|
25
27
|
"test:db": "mocha --exit -t 10000 --config test/mocha-integration-config-test.js",
|
|
@@ -58,11 +60,11 @@
|
|
|
58
60
|
"stress:test": "node scripts/stress-test/knex-stress-test.js | grep -A 5 -B 60 -- '- STATS '",
|
|
59
61
|
"stress:destroy": "docker-compose -f scripts/stress-test/docker-compose.yml stop",
|
|
60
62
|
"prepare": "husky install && npm run clean && npm run build",
|
|
61
|
-
"prepublishOnly": "npm run format:check
|
|
63
|
+
"prepublishOnly": "npm run format:check && npm run lint:everything && npm run clean && npm run build"
|
|
62
64
|
},
|
|
63
65
|
"dependencies": {
|
|
64
66
|
"colorette": "2.0.19",
|
|
65
|
-
"commander": "^
|
|
67
|
+
"commander": "^10.0.0",
|
|
66
68
|
"debug": "4.3.4",
|
|
67
69
|
"escalade": "^3.1.1",
|
|
68
70
|
"esm": "^3.2.25",
|
|
@@ -70,7 +72,7 @@
|
|
|
70
72
|
"getopts": "2.3.0",
|
|
71
73
|
"interpret": "^2.2.0",
|
|
72
74
|
"lodash": "^4.17.21",
|
|
73
|
-
"pg-connection-string": "2.
|
|
75
|
+
"pg-connection-string": "2.6.1",
|
|
74
76
|
"rechoir": "^0.8.0",
|
|
75
77
|
"resolve-from": "^5.0.0",
|
|
76
78
|
"tarn": "^3.0.2",
|
|
@@ -100,13 +102,12 @@
|
|
|
100
102
|
}
|
|
101
103
|
},
|
|
102
104
|
"lint-staged": {
|
|
103
|
-
"
|
|
104
|
-
|
|
105
|
-
]
|
|
105
|
+
"*": "prettier --ignore-unknown --write",
|
|
106
|
+
"*.js": "eslint --cache --fix"
|
|
106
107
|
},
|
|
107
108
|
"devDependencies": {
|
|
108
109
|
"@tsconfig/recommended": "^1.0.1",
|
|
109
|
-
"@types/node": "^
|
|
110
|
+
"@types/node": "^20.4.0",
|
|
110
111
|
"better-sqlite3": "^7.6.2",
|
|
111
112
|
"chai": "^4.3.6",
|
|
112
113
|
"chai-as-promised": "^7.1.1",
|
|
@@ -127,12 +128,12 @@
|
|
|
127
128
|
"mocha": "^10.0.0",
|
|
128
129
|
"mock-fs": "^5.1.4",
|
|
129
130
|
"mysql": "^2.18.1",
|
|
130
|
-
"mysql2": "^2.
|
|
131
|
+
"mysql2": "^3.2.0",
|
|
131
132
|
"nyc": "^15.1.0",
|
|
132
133
|
"oracledb": "^5.4.0",
|
|
133
134
|
"pg": "^8.8.0",
|
|
134
135
|
"pg-query-stream": "^4.2.4",
|
|
135
|
-
"prettier": "2.8.
|
|
136
|
+
"prettier": "2.8.7",
|
|
136
137
|
"rimraf": "^3.0.2",
|
|
137
138
|
"sinon": "^15.0.1",
|
|
138
139
|
"sinon-chai": "^3.7.0",
|
|
@@ -143,8 +144,8 @@
|
|
|
143
144
|
"tedious": "^14.4.0",
|
|
144
145
|
"toxiproxy-node-client": "^2.0.6",
|
|
145
146
|
"ts-node": "^10.9.1",
|
|
146
|
-
"tsd": "^0.
|
|
147
|
-
"typescript": "
|
|
147
|
+
"tsd": "^0.28.1",
|
|
148
|
+
"typescript": "5.0.4"
|
|
148
149
|
},
|
|
149
150
|
"buildDependencies": [
|
|
150
151
|
"rimraf"
|
|
@@ -234,6 +235,7 @@
|
|
|
234
235
|
"CHANGELOG.md",
|
|
235
236
|
"CONTRIBUTING.md",
|
|
236
237
|
"knex.js",
|
|
238
|
+
"knex.mjs",
|
|
237
239
|
"LICENSE",
|
|
238
240
|
"README.md",
|
|
239
241
|
"UPGRADING.md"
|
|
@@ -251,7 +253,8 @@
|
|
|
251
253
|
],
|
|
252
254
|
"exclude": [
|
|
253
255
|
"lib/dialects/oracle",
|
|
254
|
-
"lib/dialects/oracledb"
|
|
256
|
+
"lib/dialects/oracledb",
|
|
257
|
+
"test/**/*.spec.js"
|
|
255
258
|
]
|
|
256
259
|
},
|
|
257
260
|
"tsd": {
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# Exit on error
|
|
4
|
-
set -e
|
|
5
|
-
|
|
6
|
-
# Directory constants
|
|
7
|
-
repo_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )"
|
|
8
|
-
exec_dir="$( pwd )"
|
|
9
|
-
script_dir="$repo_dir/scripts/"
|
|
10
|
-
docker_compose_file="$repo_dir/scripts/docker-compose.yml"
|
|
11
|
-
|
|
12
|
-
help_text="
|
|
13
|
-
Helper script to install oracle drivers on local linux machine from Oracle
|
|
14
|
-
database container.
|
|
15
|
-
|
|
16
|
-
oracledb-install-driver-libs.sh COMMAND
|
|
17
|
-
|
|
18
|
-
COMMAND:
|
|
19
|
-
run: Do the driver install.
|
|
20
|
-
dry-run: Do the driver install but do not save any files.
|
|
21
|
-
help: Print this menu.
|
|
22
|
-
|
|
23
|
-
NOTES FOR USAGE:
|
|
24
|
-
1. This script is tested to work on Ubuntu 18.04 LTS.
|
|
25
|
-
2. This script requires you to have sudo capabilities so to use ldconfig.
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
# Main script logic
|
|
29
|
-
cmd="$1"
|
|
30
|
-
|
|
31
|
-
function main () {
|
|
32
|
-
case "$1" in
|
|
33
|
-
"run")
|
|
34
|
-
printf "Starting run ...\n"
|
|
35
|
-
do_install true
|
|
36
|
-
exit 0
|
|
37
|
-
;;
|
|
38
|
-
"dry-run")
|
|
39
|
-
printf "Starting dry-run ...\n"
|
|
40
|
-
do_install false
|
|
41
|
-
exit 0
|
|
42
|
-
;;
|
|
43
|
-
"help"|"--help"|"-h"|"")
|
|
44
|
-
printf "$help_text"
|
|
45
|
-
exit 0
|
|
46
|
-
;;
|
|
47
|
-
*)
|
|
48
|
-
printf "Unsupported command: $cmd\n"
|
|
49
|
-
printf "Try running with 'help' to see supported commands.\n"
|
|
50
|
-
exit 1
|
|
51
|
-
;;
|
|
52
|
-
esac
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function do_install () {
|
|
56
|
-
do_changes="$1"
|
|
57
|
-
printf "\nEnsuring oracle containers from docker-compose are up ...\n"
|
|
58
|
-
docker-compose -f "$docker_compose_file" up --build -d oracledb
|
|
59
|
-
docker-compose -f "$docker_compose_file" up waitoracledb
|
|
60
|
-
printf "\nSleeping an extra 15 seconds to ensure oracle has fully started ...\n"
|
|
61
|
-
sleep 15
|
|
62
|
-
printf "\nInstalling oracle client libs to db container ...\n"
|
|
63
|
-
set -x
|
|
64
|
-
docker-compose -f "$docker_compose_file" exec -T oracledb curl http://yum.oracle.com/public-yum-ol7.repo -o /etc/yum.repos.d/public-yum-ol7.repo
|
|
65
|
-
docker-compose -f "$docker_compose_file" exec -T oracledb yum install -y yum-utils
|
|
66
|
-
docker-compose -f "$docker_compose_file" exec -T oracledb yum-config-manager --enable ol7_oracle_instantclient
|
|
67
|
-
docker-compose -f "$docker_compose_file" exec -T oracledb yum install -y oracle-instantclient18.3-basiclite
|
|
68
|
-
set +x
|
|
69
|
-
printf "\nCopying to host's ~/lib directory and adding to ldconfig ...\n"
|
|
70
|
-
if [ "$do_changes" = "true" ]; then
|
|
71
|
-
set -x
|
|
72
|
-
docker cp oracledb_container:/usr/lib/oracle/18.3/client64/lib/ ~/
|
|
73
|
-
sudo sh -c "echo $HOME/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
|
|
74
|
-
sudo ldconfig
|
|
75
|
-
set +x
|
|
76
|
-
else
|
|
77
|
-
printf "(skipping because dry-run)\n"
|
|
78
|
-
fi
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
# Start the bash app's main function
|
|
82
|
-
main "$cmd"
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
# Exit on error
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
# Directory constants
|
|
7
|
+
repo_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null 2>&1 && pwd )"
|
|
8
|
+
exec_dir="$( pwd )"
|
|
9
|
+
script_dir="$repo_dir/scripts/"
|
|
10
|
+
docker_compose_file="$repo_dir/scripts/docker-compose.yml"
|
|
11
|
+
|
|
12
|
+
help_text="
|
|
13
|
+
Helper script to install oracle drivers on local linux machine from Oracle
|
|
14
|
+
database container.
|
|
15
|
+
|
|
16
|
+
oracledb-install-driver-libs.sh COMMAND
|
|
17
|
+
|
|
18
|
+
COMMAND:
|
|
19
|
+
run: Do the driver install.
|
|
20
|
+
dry-run: Do the driver install but do not save any files.
|
|
21
|
+
help: Print this menu.
|
|
22
|
+
|
|
23
|
+
NOTES FOR USAGE:
|
|
24
|
+
1. This script is tested to work on Ubuntu 18.04 LTS.
|
|
25
|
+
2. This script requires you to have sudo capabilities so to use ldconfig.
|
|
26
|
+
"
|
|
27
|
+
|
|
28
|
+
# Main script logic
|
|
29
|
+
cmd="$1"
|
|
30
|
+
|
|
31
|
+
function main () {
|
|
32
|
+
case "$1" in
|
|
33
|
+
"run")
|
|
34
|
+
printf "Starting run ...\n"
|
|
35
|
+
do_install true
|
|
36
|
+
exit 0
|
|
37
|
+
;;
|
|
38
|
+
"dry-run")
|
|
39
|
+
printf "Starting dry-run ...\n"
|
|
40
|
+
do_install false
|
|
41
|
+
exit 0
|
|
42
|
+
;;
|
|
43
|
+
"help"|"--help"|"-h"|"")
|
|
44
|
+
printf "$help_text"
|
|
45
|
+
exit 0
|
|
46
|
+
;;
|
|
47
|
+
*)
|
|
48
|
+
printf "Unsupported command: $cmd\n"
|
|
49
|
+
printf "Try running with 'help' to see supported commands.\n"
|
|
50
|
+
exit 1
|
|
51
|
+
;;
|
|
52
|
+
esac
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function do_install () {
|
|
56
|
+
do_changes="$1"
|
|
57
|
+
printf "\nEnsuring oracle containers from docker-compose are up ...\n"
|
|
58
|
+
docker-compose -f "$docker_compose_file" up --build -d oracledb
|
|
59
|
+
docker-compose -f "$docker_compose_file" up waitoracledb
|
|
60
|
+
printf "\nSleeping an extra 15 seconds to ensure oracle has fully started ...\n"
|
|
61
|
+
sleep 15
|
|
62
|
+
printf "\nInstalling oracle client libs to db container ...\n"
|
|
63
|
+
set -x
|
|
64
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb curl http://yum.oracle.com/public-yum-ol7.repo -o /etc/yum.repos.d/public-yum-ol7.repo
|
|
65
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb yum install -y yum-utils
|
|
66
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb yum-config-manager --enable ol7_oracle_instantclient
|
|
67
|
+
docker-compose -f "$docker_compose_file" exec -T oracledb yum install -y oracle-instantclient18.3-basiclite
|
|
68
|
+
set +x
|
|
69
|
+
printf "\nCopying to host's ~/lib directory and adding to ldconfig ...\n"
|
|
70
|
+
if [ "$do_changes" = "true" ]; then
|
|
71
|
+
set -x
|
|
72
|
+
docker cp oracledb_container:/usr/lib/oracle/18.3/client64/lib/ ~/
|
|
73
|
+
sudo sh -c "echo $HOME/lib > /etc/ld.so.conf.d/oracle-instantclient.conf"
|
|
74
|
+
sudo ldconfig
|
|
75
|
+
set +x
|
|
76
|
+
else
|
|
77
|
+
printf "(skipping because dry-run)\n"
|
|
78
|
+
fi
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Start the bash app's main function
|
|
82
|
+
main "$cmd"
|
package/scripts/release.sh
CHANGED
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
#!/bin/bash -e
|
|
2
|
-
|
|
3
|
-
changelog=node_modules/.bin/changelog
|
|
4
|
-
|
|
5
|
-
update_version() {
|
|
6
|
-
echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
|
|
7
|
-
echo "Updated ${1} version to ${2}"
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
current_version=$(node -p "require('./package').version")
|
|
11
|
-
|
|
12
|
-
printf "Next version (current is $current_version)? "
|
|
13
|
-
read next_version
|
|
14
|
-
|
|
15
|
-
if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
|
|
16
|
-
echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
|
|
17
|
-
exit 1
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
next_ref="v$next_version"
|
|
21
|
-
|
|
22
|
-
git add -u
|
|
23
|
-
|
|
24
|
-
npm run build
|
|
25
|
-
npm
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
git
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
#!/bin/bash -e
|
|
2
|
+
|
|
3
|
+
changelog=node_modules/.bin/changelog
|
|
4
|
+
|
|
5
|
+
update_version() {
|
|
6
|
+
echo "$(node -p "p=require('./${1}');p.version='${2}';JSON.stringify(p,null,2)")" > $1
|
|
7
|
+
echo "Updated ${1} version to ${2}"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
current_version=$(node -p "require('./package').version")
|
|
11
|
+
|
|
12
|
+
printf "Next version (current is $current_version)? "
|
|
13
|
+
read next_version
|
|
14
|
+
|
|
15
|
+
if ! [[ $next_version =~ ^[0-9]\.[0-9]+\.[0-9](-.+)? ]]; then
|
|
16
|
+
echo "Version must be a valid semver string, e.g. 1.0.2 or 2.3.0-beta.1"
|
|
17
|
+
exit 1
|
|
18
|
+
fi
|
|
19
|
+
|
|
20
|
+
next_ref="v$next_version"
|
|
21
|
+
|
|
22
|
+
git add -u
|
|
23
|
+
|
|
24
|
+
npm run build
|
|
25
|
+
npm run format:check
|
|
26
|
+
npm run lint:everything
|
|
27
|
+
npm test
|
|
28
|
+
|
|
29
|
+
update_version 'package.json' $next_version
|
|
30
|
+
|
|
31
|
+
git commit -am "release $next_version"
|
|
32
|
+
git tag $next_version
|
|
33
|
+
|
|
34
|
+
git push --tags
|
|
35
|
+
|
|
36
|
+
npm publish
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
# Test scripts to evaluate stability of drivers / pool etc.
|
|
2
|
-
|
|
3
|
-
# To run this test you need to be in this directory + have node >= 8
|
|
4
|
-
# and startup docker containers with proxy and sql servers
|
|
5
|
-
|
|
6
|
-
docker-compose up --no-start
|
|
7
|
-
docker-compose start
|
|
8
|
-
|
|
9
|
-
# Select different test script to run:
|
|
10
|
-
|
|
11
|
-
node mysql2-random-hanging-every-now-and-then.js 2> /dev/null | grep -B500 -A2 -- "- STATS"
|
|
12
|
-
node mysql2-sudden-exit-without-error
|
|
13
|
-
node knex-stress-test.js | grep -A 3 -- "- STATS "
|
|
14
|
-
node reconnect-test-mysql-based-drivers.js 2> /dev/null | grep -A 3 -- "- STATS "
|
|
15
|
-
|
|
16
|
-
# Shut down docker instances when done:
|
|
17
|
-
|
|
18
|
-
docker-compose down
|
|
1
|
+
# Test scripts to evaluate stability of drivers / pool etc.
|
|
2
|
+
|
|
3
|
+
# To run this test you need to be in this directory + have node >= 8
|
|
4
|
+
# and startup docker containers with proxy and sql servers
|
|
5
|
+
|
|
6
|
+
docker-compose up --no-start
|
|
7
|
+
docker-compose start
|
|
8
|
+
|
|
9
|
+
# Select different test script to run:
|
|
10
|
+
|
|
11
|
+
node mysql2-random-hanging-every-now-and-then.js 2> /dev/null | grep -B500 -A2 -- "- STATS"
|
|
12
|
+
node mysql2-sudden-exit-without-error
|
|
13
|
+
node knex-stress-test.js | grep -A 3 -- "- STATS "
|
|
14
|
+
node reconnect-test-mysql-based-drivers.js 2> /dev/null | grep -A 3 -- "- STATS "
|
|
15
|
+
|
|
16
|
+
# Shut down docker instances when done:
|
|
17
|
+
|
|
18
|
+
docker-compose down
|
|
@@ -4,23 +4,23 @@ services:
|
|
|
4
4
|
toxiproxy:
|
|
5
5
|
image: shopify/toxiproxy
|
|
6
6
|
ports:
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
7
|
+
- '8474:8474'
|
|
8
|
+
- '23306:23306'
|
|
9
|
+
- '25432:25432'
|
|
10
|
+
- '25433:25433'
|
|
11
|
+
- '21521:21521'
|
|
12
|
+
- '21433:21433'
|
|
13
13
|
links:
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
14
|
+
- 'mysql'
|
|
15
|
+
- 'postgresql'
|
|
16
|
+
- 'pgnative'
|
|
17
|
+
- 'oracledb'
|
|
18
|
+
- 'mssql'
|
|
19
19
|
|
|
20
20
|
mysql:
|
|
21
21
|
image: mysql:5.7
|
|
22
22
|
ports:
|
|
23
|
-
-
|
|
23
|
+
- '33306:3306'
|
|
24
24
|
environment:
|
|
25
25
|
- TZ=UTC
|
|
26
26
|
- MYSQL_ROOT_PASSWORD=mysqlrootpassword
|
|
@@ -28,7 +28,7 @@ services:
|
|
|
28
28
|
postgresql:
|
|
29
29
|
image: mdillon/postgis
|
|
30
30
|
ports:
|
|
31
|
-
-
|
|
31
|
+
- '35432:5432'
|
|
32
32
|
environment:
|
|
33
33
|
- POSTGRES_PASSWORD=postgresrootpassword
|
|
34
34
|
- POSTGRES_USER=postgres
|
|
@@ -36,7 +36,7 @@ services:
|
|
|
36
36
|
pgnative:
|
|
37
37
|
image: mdillon/postgis
|
|
38
38
|
ports:
|
|
39
|
-
-
|
|
39
|
+
- '35433:5432'
|
|
40
40
|
environment:
|
|
41
41
|
- POSTGRES_PASSWORD=postgresrootpassword
|
|
42
42
|
- POSTGRES_USER=postgres
|
|
@@ -44,14 +44,14 @@ services:
|
|
|
44
44
|
oracledb:
|
|
45
45
|
image: quillbuilduser/oracle-18-xe
|
|
46
46
|
ports:
|
|
47
|
-
-
|
|
47
|
+
- '31521:1521'
|
|
48
48
|
environment:
|
|
49
49
|
- ORACLE_ALLOW_REMOTE=true
|
|
50
50
|
|
|
51
51
|
mssql:
|
|
52
52
|
image: microsoft/mssql-server-linux:2017-latest
|
|
53
53
|
ports:
|
|
54
|
-
-
|
|
54
|
+
- '31433:1433'
|
|
55
55
|
environment:
|
|
56
56
|
- ACCEPT_EULA=Y
|
|
57
57
|
- SA_PASSWORD=S0meVeryHardPassword
|
|
@@ -81,7 +81,7 @@ let lastCounters = _.cloneDeep(counters);
|
|
|
81
81
|
|
|
82
82
|
setInterval(() => {
|
|
83
83
|
const reqsPerSec = {};
|
|
84
|
-
for (
|
|
84
|
+
for (const key of Object.keys(counters)) {
|
|
85
85
|
reqsPerSec[key] = {
|
|
86
86
|
queries: (counters[key].queries - lastCounters[key].queries) / 2,
|
|
87
87
|
results: (counters[key].results - lastCounters[key].results) / 2,
|
|
@@ -106,7 +106,7 @@ async function killConnectionsPg(client) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
async function killConnectionsMyslq(client) {
|
|
109
|
-
const [rows
|
|
109
|
+
const [rows] = await client.raw(`SHOW FULL PROCESSLIST`);
|
|
110
110
|
await Promise.all(rows.map((row) => client.raw(`KILL ${row.Id}`)));
|
|
111
111
|
}
|
|
112
112
|
|
|
@@ -119,6 +119,7 @@ async function main() {
|
|
|
119
119
|
async function loopQueries(prefix, query) {
|
|
120
120
|
const queries = () => [...Array(50).fill(query)];
|
|
121
121
|
|
|
122
|
+
// eslint-disable-next-line no-constant-condition
|
|
122
123
|
while (true) {
|
|
123
124
|
try {
|
|
124
125
|
await Promise.all(queries());
|
|
@@ -133,7 +134,9 @@ async function main() {
|
|
|
133
134
|
await rp.delete({
|
|
134
135
|
url: `${toxicli.host}/proxies/${serviceName}`,
|
|
135
136
|
});
|
|
136
|
-
} catch (err) {
|
|
137
|
+
} catch (err) {
|
|
138
|
+
/* empty */
|
|
139
|
+
}
|
|
137
140
|
|
|
138
141
|
const proxy = await toxicli.createProxy({
|
|
139
142
|
name: serviceName,
|
|
@@ -188,6 +191,7 @@ async function main() {
|
|
|
188
191
|
|
|
189
192
|
setInterval(recreateProxies, 2000);
|
|
190
193
|
|
|
194
|
+
// eslint-disable-next-line no-constant-condition
|
|
191
195
|
while (true) {
|
|
192
196
|
await delay(20); // kill everything every quite often from server side
|
|
193
197
|
try {
|
|
@@ -56,7 +56,7 @@ async function mysql2Query(sql) {
|
|
|
56
56
|
|
|
57
57
|
const counters = {};
|
|
58
58
|
function setMysqlQueryCounters(name) {
|
|
59
|
-
|
|
59
|
+
counters[name] = { queries: 0, results: 0, errors: 0 };
|
|
60
60
|
}
|
|
61
61
|
setMysqlQueryCounters('mysql2');
|
|
62
62
|
|
|
@@ -64,7 +64,7 @@ setMysqlQueryCounters('mysql2');
|
|
|
64
64
|
let lastCounters = _.cloneDeep(counters);
|
|
65
65
|
setInterval(() => {
|
|
66
66
|
const reqsPerSec = {};
|
|
67
|
-
for (
|
|
67
|
+
for (const key of Object.keys(counters)) {
|
|
68
68
|
reqsPerSec[key] = {
|
|
69
69
|
queries: counters[key].queries - lastCounters[key].queries,
|
|
70
70
|
results: counters[key].results - lastCounters[key].results,
|
|
@@ -86,7 +86,9 @@ async function recreateProxy(serviceName, listenPort, proxyToPort) {
|
|
|
86
86
|
await rp.delete({
|
|
87
87
|
url: `${toxicli.host}/proxies/${serviceName}`,
|
|
88
88
|
});
|
|
89
|
-
} catch (err) {
|
|
89
|
+
} catch (err) {
|
|
90
|
+
/* empty */
|
|
91
|
+
}
|
|
90
92
|
|
|
91
93
|
const proxy = await toxicli.createProxy({
|
|
92
94
|
name: serviceName,
|
|
@@ -118,6 +120,7 @@ async function main() {
|
|
|
118
120
|
async function loopQueries(prefix, query) {
|
|
119
121
|
const counts = counters[prefix];
|
|
120
122
|
|
|
123
|
+
// eslint-disable-next-line no-constant-condition
|
|
121
124
|
while (true) {
|
|
122
125
|
try {
|
|
123
126
|
counts.queries += 1;
|
|
@@ -135,6 +138,7 @@ async function main() {
|
|
|
135
138
|
loopQueries('mysql2', () => mysql2Query('select 1'));
|
|
136
139
|
|
|
137
140
|
// wait forever
|
|
141
|
+
// eslint-disable-next-line no-constant-condition
|
|
138
142
|
while (true) {
|
|
139
143
|
await delay(1000);
|
|
140
144
|
}
|
|
@@ -18,7 +18,7 @@ async function recreateProxy(serviceName, listenPort, proxyToPort) {
|
|
|
18
18
|
// there was no proxy by that name... its ok
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
await toxicli.createProxy({
|
|
22
22
|
name: serviceName,
|
|
23
23
|
listen: `0.0.0.0:${listenPort}`,
|
|
24
24
|
upstream: `${serviceName}:${proxyToPort}`,
|
|
@@ -69,6 +69,7 @@ async function main() {
|
|
|
69
69
|
console.log('Proxy recreated... start waiting');
|
|
70
70
|
|
|
71
71
|
// wait forever
|
|
72
|
+
// eslint-disable-next-line no-constant-condition
|
|
72
73
|
while (true) {
|
|
73
74
|
await delay(1000);
|
|
74
75
|
try {
|