iobroker.sql 2.1.1 → 2.1.2
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/LICENSE +21 -21
- package/README.md +850 -847
- package/admin/i18n/de/translations.json +73 -73
- package/admin/i18n/en/translations.json +73 -73
- package/admin/i18n/es/translations.json +72 -72
- package/admin/i18n/fr/translations.json +72 -72
- package/admin/i18n/it/translations.json +72 -72
- package/admin/i18n/nl/translations.json +72 -72
- package/admin/i18n/pl/translations.json +72 -72
- package/admin/i18n/pt/translations.json +72 -72
- package/admin/i18n/ru/translations.json +72 -72
- package/admin/i18n/zh-cn/translations.json +73 -73
- package/admin/jsonConfig.json +335 -335
- package/admin/jsonCustom.json +236 -236
- package/admin/words.js +75 -75
- package/io-package.json +274 -273
- package/lib/aggregate.js +961 -894
- package/lib/mssql-client.js +61 -61
- package/lib/mssql.js +270 -270
- package/lib/mysql-client.js +62 -62
- package/lib/mysql.js +257 -257
- package/lib/postgresql-client.js +202 -202
- package/lib/postgresql.js +252 -252
- package/lib/sqlite.js +252 -252
- package/lib/tools.js +99 -99
- package/main.js +3464 -3464
- package/package.json +62 -62
package/lib/postgresql-client.js
CHANGED
|
@@ -1,202 +1,202 @@
|
|
|
1
|
-
// Generated by CoffeeScript 2.3.2
|
|
2
|
-
(function() {
|
|
3
|
-
let pg = require('pg');
|
|
4
|
-
const Url = require('url');
|
|
5
|
-
const querystring = require('querystring');
|
|
6
|
-
|
|
7
|
-
const SQLClient = require('sql-client/lib/sql-client').SQLClient;
|
|
8
|
-
const SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;
|
|
9
|
-
const ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;
|
|
10
|
-
|
|
11
|
-
try {
|
|
12
|
-
if ((pg != null ? pg['native'] : void 0) != null) {
|
|
13
|
-
pg = pg['native'];
|
|
14
|
-
}
|
|
15
|
-
} catch(err) {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// PostgreSQLConnectionFactory does not use any of node-pg's built-in pooling.
|
|
20
|
-
const PostgreSQLConnectionFactory = class PostgreSQLConnectionFactory extends ConnectionFactory {
|
|
21
|
-
constructor() {
|
|
22
|
-
super();
|
|
23
|
-
this.open_connection = this.open_connection.bind(this);
|
|
24
|
-
this.pre_process_sql = this.pre_process_sql.bind(this);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
open_connection(connect_string, callback) {
|
|
28
|
-
let connection = new pg.Client(connect_string);
|
|
29
|
-
return connection.connect((err) => {
|
|
30
|
-
return callback(err, connection);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
pre_process_sql(sql, bindvars, callback) {
|
|
35
|
-
let index;
|
|
36
|
-
if ((sql != null) && (bindvars != null)) {
|
|
37
|
-
index = 1;
|
|
38
|
-
sql = sql.replace(/\?/g, (function() {
|
|
39
|
-
return '$' + index++;
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
return callback(null, sql, bindvars);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const PostgreSQLClient = class PostgreSQLClient extends SQLClient {
|
|
47
|
-
constructor(...options) {
|
|
48
|
-
super(...options, new PostgreSQLConnectionFactory());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const PostgreSQLClientPool = class PostgreSQLClientPool extends SQLClientPool {
|
|
54
|
-
constructor(...options) {
|
|
55
|
-
super(...options, new PostgreSQLConnectionFactory());
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
exports.PostgreSQLConnectionFactory = PostgreSQLConnectionFactory;
|
|
61
|
-
exports.PostgreSQLClient = PostgreSQLClient;
|
|
62
|
-
exports.PostgreSQLClientPool = PostgreSQLClientPool;
|
|
63
|
-
|
|
64
|
-
const PostgreSQLConnectionFactory2 = (function() {
|
|
65
|
-
// PostgreSQLConnectionFactory2 DOES usenode-pg's built-in pooling.
|
|
66
|
-
class PostgreSQLConnectionFactory2 extends PostgreSQLConnectionFactory {
|
|
67
|
-
constructor() {
|
|
68
|
-
super();
|
|
69
|
-
this._parse_connect_string = this._parse_connect_string.bind(this);
|
|
70
|
-
this.open_connection = this.open_connection.bind(this);
|
|
71
|
-
this.close_connection = this.close_connection.bind(this);
|
|
72
|
-
this.pg_pools_by_connect_string = {};
|
|
73
|
-
this._connect_string_regexp = /^([^:]+):\/\/([^:]+):([^@]+)@([^:\/]+)(:([0-9]+))?(.*)$/;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
_parse_connect_string(connect_string) {
|
|
77
|
-
let config;
|
|
78
|
-
let matches;
|
|
79
|
-
let name;
|
|
80
|
-
let parsed_path;
|
|
81
|
-
let path;
|
|
82
|
-
let qs;
|
|
83
|
-
let value;
|
|
84
|
-
|
|
85
|
-
if (typeof connect_string === 'string' && this._connect_string_regexp.test(connect_string)) {
|
|
86
|
-
matches = connect_string.match(this._connect_string_regexp);
|
|
87
|
-
config = {};
|
|
88
|
-
config.database = matches[1];
|
|
89
|
-
config.user = matches[2];
|
|
90
|
-
config.password = matches[3];
|
|
91
|
-
config.host = matches[4];
|
|
92
|
-
if (matches[6] != null) {
|
|
93
|
-
config.port = parseInt(matches[6]);
|
|
94
|
-
}
|
|
95
|
-
path = matches[7];
|
|
96
|
-
parsed_path = Url.parse(path);
|
|
97
|
-
config.database = parsed_path.pathname.substring(1);
|
|
98
|
-
if (parsed_path.query != null) {
|
|
99
|
-
qs = querystring.parse(parsed_path.query);
|
|
100
|
-
for (name in qs) {
|
|
101
|
-
value = qs[name];
|
|
102
|
-
if (value === 'true') {
|
|
103
|
-
value = true;
|
|
104
|
-
} else if (value === 'false') {
|
|
105
|
-
value = false;
|
|
106
|
-
} else if (`${value}` === `${parseInt(value)}`) {
|
|
107
|
-
value = parseInt(value);
|
|
108
|
-
}
|
|
109
|
-
config[name] = value;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return config;
|
|
113
|
-
} else {
|
|
114
|
-
return connect_string;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
open_connection(connect_string, callback) {
|
|
119
|
-
let key;
|
|
120
|
-
let pg_pool;
|
|
121
|
-
|
|
122
|
-
key = connect_string;
|
|
123
|
-
if (typeof key !== 'string') {
|
|
124
|
-
key = JSON.stringify(key);
|
|
125
|
-
}
|
|
126
|
-
pg_pool = this.pg_pools_by_connect_string[key];
|
|
127
|
-
if (pg_pool == null) {
|
|
128
|
-
pg_pool = new pg.Pool(this._parse_connect_string(connect_string));
|
|
129
|
-
this.pg_pools_by_connect_string[key] = pg_pool;
|
|
130
|
-
}
|
|
131
|
-
return pg_pool.connect((err, client, done_fn) => {
|
|
132
|
-
let connection;
|
|
133
|
-
connection = client;
|
|
134
|
-
if (connection != null) {
|
|
135
|
-
connection._sqlclient_done = done_fn;
|
|
136
|
-
connection._pg_pool_key = key;
|
|
137
|
-
}
|
|
138
|
-
return callback(err, connection);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
close_connection(connection, callback) {
|
|
143
|
-
if ((connection != null ? connection._sqlclient_done : void 0) != null) {
|
|
144
|
-
connection._sqlclient_done();
|
|
145
|
-
return typeof callback === "function" ? callback(null) : void 0;
|
|
146
|
-
} else {
|
|
147
|
-
return super.close_connection(connection, callback);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
return PostgreSQLConnectionFactory2;
|
|
154
|
-
|
|
155
|
-
}).call(this);
|
|
156
|
-
|
|
157
|
-
const PostgreSQLClient2 = class PostgreSQLClient2 extends SQLClient {
|
|
158
|
-
constructor(...options) {
|
|
159
|
-
super(...options, new PostgreSQLConnectionFactory2());
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
};
|
|
163
|
-
|
|
164
|
-
const PostgreSQLClientPool2 = class PostgreSQLClientPool2 extends SQLClientPool {
|
|
165
|
-
constructor(...options) {
|
|
166
|
-
super(...options, new PostgreSQLConnectionFactory2());
|
|
167
|
-
this.destroy = this.destroy.bind(this);
|
|
168
|
-
this.close = this.close.bind(this);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
destroy(client, callback) {
|
|
172
|
-
if (client != null) {
|
|
173
|
-
return client.disconnect(callback);
|
|
174
|
-
} else {
|
|
175
|
-
return typeof callback === "function" ? callback() : void 0;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
close(callback) {
|
|
180
|
-
return super.close((...args) => {
|
|
181
|
-
let key;
|
|
182
|
-
let pg_pool;
|
|
183
|
-
let pools_to_close;
|
|
184
|
-
let ref;
|
|
185
|
-
let ref1;
|
|
186
|
-
pools_to_close = (ref = this.factory) != null ? ref.pg_pools_by_connect_string : void 0;
|
|
187
|
-
ref1 = pools_to_close != null ? pools_to_close : {};
|
|
188
|
-
for (key in ref1) {
|
|
189
|
-
pg_pool = ref1[key];
|
|
190
|
-
if (!((pg_pool == null) || (pg_pool.ending || pg_pool.ended))) {
|
|
191
|
-
pg_pool.end();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
return typeof callback === "function" ? callback(...args) : void 0;
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
exports.PostgreSQLConnectionFactory2 = PostgreSQLConnectionFactory2;
|
|
200
|
-
exports.PostgreSQLClient2 = PostgreSQLClient2;
|
|
201
|
-
exports.PostgreSQLClientPool2 = PostgreSQLClientPool2;
|
|
202
|
-
}).call(this);
|
|
1
|
+
// Generated by CoffeeScript 2.3.2
|
|
2
|
+
(function() {
|
|
3
|
+
let pg = require('pg');
|
|
4
|
+
const Url = require('url');
|
|
5
|
+
const querystring = require('querystring');
|
|
6
|
+
|
|
7
|
+
const SQLClient = require('sql-client/lib/sql-client').SQLClient;
|
|
8
|
+
const SQLClientPool = require('sql-client/lib/sql-client-pool').SQLClientPool;
|
|
9
|
+
const ConnectionFactory = require('sql-client/lib/connection-factory').ConnectionFactory;
|
|
10
|
+
|
|
11
|
+
try {
|
|
12
|
+
if ((pg != null ? pg['native'] : void 0) != null) {
|
|
13
|
+
pg = pg['native'];
|
|
14
|
+
}
|
|
15
|
+
} catch(err) {
|
|
16
|
+
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// PostgreSQLConnectionFactory does not use any of node-pg's built-in pooling.
|
|
20
|
+
const PostgreSQLConnectionFactory = class PostgreSQLConnectionFactory extends ConnectionFactory {
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.open_connection = this.open_connection.bind(this);
|
|
24
|
+
this.pre_process_sql = this.pre_process_sql.bind(this);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
open_connection(connect_string, callback) {
|
|
28
|
+
let connection = new pg.Client(connect_string);
|
|
29
|
+
return connection.connect((err) => {
|
|
30
|
+
return callback(err, connection);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pre_process_sql(sql, bindvars, callback) {
|
|
35
|
+
let index;
|
|
36
|
+
if ((sql != null) && (bindvars != null)) {
|
|
37
|
+
index = 1;
|
|
38
|
+
sql = sql.replace(/\?/g, (function() {
|
|
39
|
+
return '$' + index++;
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
return callback(null, sql, bindvars);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const PostgreSQLClient = class PostgreSQLClient extends SQLClient {
|
|
47
|
+
constructor(...options) {
|
|
48
|
+
super(...options, new PostgreSQLConnectionFactory());
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const PostgreSQLClientPool = class PostgreSQLClientPool extends SQLClientPool {
|
|
54
|
+
constructor(...options) {
|
|
55
|
+
super(...options, new PostgreSQLConnectionFactory());
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.PostgreSQLConnectionFactory = PostgreSQLConnectionFactory;
|
|
61
|
+
exports.PostgreSQLClient = PostgreSQLClient;
|
|
62
|
+
exports.PostgreSQLClientPool = PostgreSQLClientPool;
|
|
63
|
+
|
|
64
|
+
const PostgreSQLConnectionFactory2 = (function() {
|
|
65
|
+
// PostgreSQLConnectionFactory2 DOES usenode-pg's built-in pooling.
|
|
66
|
+
class PostgreSQLConnectionFactory2 extends PostgreSQLConnectionFactory {
|
|
67
|
+
constructor() {
|
|
68
|
+
super();
|
|
69
|
+
this._parse_connect_string = this._parse_connect_string.bind(this);
|
|
70
|
+
this.open_connection = this.open_connection.bind(this);
|
|
71
|
+
this.close_connection = this.close_connection.bind(this);
|
|
72
|
+
this.pg_pools_by_connect_string = {};
|
|
73
|
+
this._connect_string_regexp = /^([^:]+):\/\/([^:]+):([^@]+)@([^:\/]+)(:([0-9]+))?(.*)$/;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
_parse_connect_string(connect_string) {
|
|
77
|
+
let config;
|
|
78
|
+
let matches;
|
|
79
|
+
let name;
|
|
80
|
+
let parsed_path;
|
|
81
|
+
let path;
|
|
82
|
+
let qs;
|
|
83
|
+
let value;
|
|
84
|
+
|
|
85
|
+
if (typeof connect_string === 'string' && this._connect_string_regexp.test(connect_string)) {
|
|
86
|
+
matches = connect_string.match(this._connect_string_regexp);
|
|
87
|
+
config = {};
|
|
88
|
+
config.database = matches[1];
|
|
89
|
+
config.user = matches[2];
|
|
90
|
+
config.password = matches[3];
|
|
91
|
+
config.host = matches[4];
|
|
92
|
+
if (matches[6] != null) {
|
|
93
|
+
config.port = parseInt(matches[6]);
|
|
94
|
+
}
|
|
95
|
+
path = matches[7];
|
|
96
|
+
parsed_path = Url.parse(path);
|
|
97
|
+
config.database = parsed_path.pathname.substring(1);
|
|
98
|
+
if (parsed_path.query != null) {
|
|
99
|
+
qs = querystring.parse(parsed_path.query);
|
|
100
|
+
for (name in qs) {
|
|
101
|
+
value = qs[name];
|
|
102
|
+
if (value === 'true') {
|
|
103
|
+
value = true;
|
|
104
|
+
} else if (value === 'false') {
|
|
105
|
+
value = false;
|
|
106
|
+
} else if (`${value}` === `${parseInt(value)}`) {
|
|
107
|
+
value = parseInt(value);
|
|
108
|
+
}
|
|
109
|
+
config[name] = value;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return config;
|
|
113
|
+
} else {
|
|
114
|
+
return connect_string;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
open_connection(connect_string, callback) {
|
|
119
|
+
let key;
|
|
120
|
+
let pg_pool;
|
|
121
|
+
|
|
122
|
+
key = connect_string;
|
|
123
|
+
if (typeof key !== 'string') {
|
|
124
|
+
key = JSON.stringify(key);
|
|
125
|
+
}
|
|
126
|
+
pg_pool = this.pg_pools_by_connect_string[key];
|
|
127
|
+
if (pg_pool == null) {
|
|
128
|
+
pg_pool = new pg.Pool(this._parse_connect_string(connect_string));
|
|
129
|
+
this.pg_pools_by_connect_string[key] = pg_pool;
|
|
130
|
+
}
|
|
131
|
+
return pg_pool.connect((err, client, done_fn) => {
|
|
132
|
+
let connection;
|
|
133
|
+
connection = client;
|
|
134
|
+
if (connection != null) {
|
|
135
|
+
connection._sqlclient_done = done_fn;
|
|
136
|
+
connection._pg_pool_key = key;
|
|
137
|
+
}
|
|
138
|
+
return callback(err, connection);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
close_connection(connection, callback) {
|
|
143
|
+
if ((connection != null ? connection._sqlclient_done : void 0) != null) {
|
|
144
|
+
connection._sqlclient_done();
|
|
145
|
+
return typeof callback === "function" ? callback(null) : void 0;
|
|
146
|
+
} else {
|
|
147
|
+
return super.close_connection(connection, callback);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
return PostgreSQLConnectionFactory2;
|
|
154
|
+
|
|
155
|
+
}).call(this);
|
|
156
|
+
|
|
157
|
+
const PostgreSQLClient2 = class PostgreSQLClient2 extends SQLClient {
|
|
158
|
+
constructor(...options) {
|
|
159
|
+
super(...options, new PostgreSQLConnectionFactory2());
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const PostgreSQLClientPool2 = class PostgreSQLClientPool2 extends SQLClientPool {
|
|
165
|
+
constructor(...options) {
|
|
166
|
+
super(...options, new PostgreSQLConnectionFactory2());
|
|
167
|
+
this.destroy = this.destroy.bind(this);
|
|
168
|
+
this.close = this.close.bind(this);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
destroy(client, callback) {
|
|
172
|
+
if (client != null) {
|
|
173
|
+
return client.disconnect(callback);
|
|
174
|
+
} else {
|
|
175
|
+
return typeof callback === "function" ? callback() : void 0;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
close(callback) {
|
|
180
|
+
return super.close((...args) => {
|
|
181
|
+
let key;
|
|
182
|
+
let pg_pool;
|
|
183
|
+
let pools_to_close;
|
|
184
|
+
let ref;
|
|
185
|
+
let ref1;
|
|
186
|
+
pools_to_close = (ref = this.factory) != null ? ref.pg_pools_by_connect_string : void 0;
|
|
187
|
+
ref1 = pools_to_close != null ? pools_to_close : {};
|
|
188
|
+
for (key in ref1) {
|
|
189
|
+
pg_pool = ref1[key];
|
|
190
|
+
if (!((pg_pool == null) || (pg_pool.ending || pg_pool.ended))) {
|
|
191
|
+
pg_pool.end();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return typeof callback === "function" ? callback(...args) : void 0;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
exports.PostgreSQLConnectionFactory2 = PostgreSQLConnectionFactory2;
|
|
200
|
+
exports.PostgreSQLClient2 = PostgreSQLClient2;
|
|
201
|
+
exports.PostgreSQLClientPool2 = PostgreSQLClientPool2;
|
|
202
|
+
}).call(this);
|