monetdb 1.3.4 → 2.0.0
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/.github/workflows/Linux.yml +3 -3
- package/.github/workflows/docs.yml +79 -0
- package/.github/workflows/macos.yml +3 -3
- package/.github/workflows/monetdb-versions.yml +43 -0
- package/README.md +41 -511
- package/docs/components/alert.tsx +10 -0
- package/docs/components/info.tsx +6 -0
- package/docs/next.config.js +24 -0
- package/docs/package-lock.json +5069 -0
- package/docs/package.json +22 -0
- package/docs/pages/_app.js +9 -0
- package/docs/pages/_meta.json +16 -0
- package/docs/pages/apis/_meta.json +4 -0
- package/docs/pages/apis/connection.mdx +60 -0
- package/docs/pages/apis/result.mdx +39 -0
- package/docs/pages/index.mdx +27 -0
- package/docs/theme.config.js +35 -0
- package/docs/v1/README.md +532 -0
- package/package.json +16 -20
- package/src/PrepareStatement.ts +37 -0
- package/src/connection.ts +125 -0
- package/src/defaults.ts +13 -0
- package/src/file-transfer.ts +173 -0
- package/src/index.ts +3 -0
- package/src/mapi.ts +1016 -0
- package/src/monetize.ts +67 -0
- package/test/connection.ts +43 -0
- package/test/exec-queries.ts +100 -0
- package/test/filetransfer.ts +94 -0
- package/test/prepare-statement.ts +27 -0
- package/test/query-stream.ts +41 -0
- package/test/tmp/.gitignore +4 -0
- package/tsconfig.json +24 -0
- package/.travis.yml +0 -11
- package/dist/mapi.d.ts +0 -58
- package/dist/mapi.js +0 -250
- package/dist/mapi.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/foo.js +0 -16
- package/index.js +0 -5
- package/src/mapi-connection.js +0 -784
- package/src/monetdb-connection.js +0 -385
- package/src/utils.js +0 -27
- package/test/common.js +0 -45
- package/test/install-monetdb.sh +0 -11
- package/test/monetdb_stream.js +0 -106
- package/test/start-monetdb.sh +0 -38
- package/test/test.js +0 -908
- package/test/test_connection.js +0 -290
- /package/docs/{README.v0.md → v0/README.v0.md} +0 -0
- /package/docs/{MapiConnection.md → v1/MapiConnection.md} +0 -0
- /package/docs/{v1-notes.md → v1/v1-notes.md} +0 -0
package/test/test_connection.js
DELETED
@@ -1,290 +0,0 @@
|
|
1
|
-
var Q = require("q");
|
2
|
-
|
3
|
-
const mdb = require("../index.js");
|
4
|
-
const { shouldHaveValidResult, notSoRandom } = require('./common');
|
5
|
-
|
6
|
-
function noop() {}
|
7
|
-
|
8
|
-
function getMDB() {
|
9
|
-
return mdb({warnings: false, dbname: "test"});
|
10
|
-
}
|
11
|
-
|
12
|
-
|
13
|
-
describe("#Connection", function() {
|
14
|
-
this.timeout(5000);
|
15
|
-
|
16
|
-
var MDB = getMDB();
|
17
|
-
|
18
|
-
it("2 byte characters", async () => {
|
19
|
-
var string = 'éééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééééé';
|
20
|
-
string += string;
|
21
|
-
string += string;
|
22
|
-
string += string;
|
23
|
-
string += string;
|
24
|
-
string += string;
|
25
|
-
const qry = `select \'${string}\'`;
|
26
|
-
const conn = new MDB();
|
27
|
-
await conn.connect();
|
28
|
-
const res = await conn.query(qry);
|
29
|
-
res.data[0][0].should.equal(string);
|
30
|
-
});
|
31
|
-
|
32
|
-
it("should fail on invalid hostname", async function() {
|
33
|
-
const conn = new MDB({host: "veryinvalidhostnamethathopefullyresolvesnowhere"});
|
34
|
-
try {
|
35
|
-
return await conn.connect().should.be.rejected;
|
36
|
-
} finally {
|
37
|
-
conn.close();
|
38
|
-
}
|
39
|
-
});
|
40
|
-
|
41
|
-
it("should fail on non existing database", async function() {
|
42
|
-
const conn = new MDB({dbname: "nonexist"});
|
43
|
-
try {
|
44
|
-
return await conn.connect().should.be.rejected;
|
45
|
-
} finally {
|
46
|
-
conn.close();
|
47
|
-
}
|
48
|
-
});
|
49
|
-
|
50
|
-
it("should fail on invalid user", async function() {
|
51
|
-
const conn = new MDB({user: "nonexist"});
|
52
|
-
try {
|
53
|
-
return await conn.connect().should.be.rejected;
|
54
|
-
} finally {
|
55
|
-
conn.close();
|
56
|
-
}
|
57
|
-
});
|
58
|
-
|
59
|
-
it("should connect", async function() {
|
60
|
-
const conn = new MDB();
|
61
|
-
try {
|
62
|
-
return await conn.connect().should.not.be.rejected;
|
63
|
-
} finally {
|
64
|
-
conn.close();
|
65
|
-
}
|
66
|
-
});
|
67
|
-
|
68
|
-
it("should finish all its queries when closed", async function() {
|
69
|
-
const conn = new MDB();
|
70
|
-
try {
|
71
|
-
conn.connect();
|
72
|
-
const qs = [
|
73
|
-
conn.query("SELECT 1"),
|
74
|
-
conn.query("SELECT 2"),
|
75
|
-
conn.query("SELECT 3")
|
76
|
-
];
|
77
|
-
const res = await Promise.all(qs);
|
78
|
-
return res.should.not.be.null;
|
79
|
-
} finally {
|
80
|
-
conn.close();
|
81
|
-
}
|
82
|
-
});
|
83
|
-
|
84
|
-
it("should fail all queries on destroyed connection", async function() {
|
85
|
-
const conn = new MDB();
|
86
|
-
try {
|
87
|
-
conn.destroy();
|
88
|
-
return await Promise.all([
|
89
|
-
conn.query("SELECT 1"),
|
90
|
-
conn.query("SELECT 2"),
|
91
|
-
conn.query("SELECT 3")
|
92
|
-
]).should.be.rejected;
|
93
|
-
} finally {
|
94
|
-
conn.close();
|
95
|
-
}
|
96
|
-
});
|
97
|
-
|
98
|
-
it("should have the appropriate state at all times", function() {
|
99
|
-
const conn = new MDB();
|
100
|
-
conn.getState().should.equal("disconnected");
|
101
|
-
return conn.connect().then(function() {
|
102
|
-
conn.getState().should.equal("ready");
|
103
|
-
return conn.close();
|
104
|
-
}).then(function() {
|
105
|
-
conn.getState().should.equal("destroyed");
|
106
|
-
}).finally(function(){
|
107
|
-
conn.close();
|
108
|
-
});
|
109
|
-
});
|
110
|
-
|
111
|
-
it("should properly start queries after some idle time after connect", function() {
|
112
|
-
const conn = new MDB();
|
113
|
-
conn.connect();
|
114
|
-
return new Promise((resolve, reject) => {
|
115
|
-
setTimeout(function() {
|
116
|
-
conn.query("SELECT 42")
|
117
|
-
.then(function(r) {
|
118
|
-
resolve(r);
|
119
|
-
}, function(err) {
|
120
|
-
reject(err);
|
121
|
-
})
|
122
|
-
.finally(function(){
|
123
|
-
conn.close();
|
124
|
-
});
|
125
|
-
}, 100);
|
126
|
-
});
|
127
|
-
});
|
128
|
-
|
129
|
-
it("should give its appropriate environment on request", async function() {
|
130
|
-
const conn = new MDB();
|
131
|
-
try {
|
132
|
-
await conn.connect();
|
133
|
-
return conn.env()
|
134
|
-
.should.eventually.be.an("object")
|
135
|
-
.that.has.property("monet_version")
|
136
|
-
.that.is.a("string");
|
137
|
-
} finally {
|
138
|
-
conn.close();
|
139
|
-
}
|
140
|
-
});
|
141
|
-
|
142
|
-
it("should fail on non existing defaultSchema", async function() {
|
143
|
-
const conn = new MDB({defaultSchema: "non_existant"});
|
144
|
-
try {
|
145
|
-
return await conn.connect().should.be.rejected;
|
146
|
-
} finally {
|
147
|
-
conn.close();
|
148
|
-
}
|
149
|
-
});
|
150
|
-
|
151
|
-
it("should pass on existing defaultSchema", async function() {
|
152
|
-
const conn1 = new MDB();
|
153
|
-
const conn2 = new MDB({defaultSchema: "some_schema"});
|
154
|
-
await conn1.connect();
|
155
|
-
return conn1.query("START TRANSACTION; " +
|
156
|
-
"CREATE SCHEMA some_schema; " +
|
157
|
-
"SET SCHEMA some_schema; " +
|
158
|
-
"CREATE TABLE a (a INT); " +
|
159
|
-
"INSERT INTO a VALUES (1); " +
|
160
|
-
"COMMIT;").then(function() {
|
161
|
-
return conn2.connect();
|
162
|
-
})
|
163
|
-
.then(function() {
|
164
|
-
return conn2.query("SELECT * FROM a");
|
165
|
-
})
|
166
|
-
.finally(function() {
|
167
|
-
conn1.close();
|
168
|
-
conn2.close();
|
169
|
-
})
|
170
|
-
.should.eventually.have.property("rows", 1)
|
171
|
-
});
|
172
|
-
|
173
|
-
it("should have the right aliases", function() {
|
174
|
-
const conn = new MDB();
|
175
|
-
conn.open.should.equal(conn.connect);
|
176
|
-
conn.request.should.equal(conn.query);
|
177
|
-
conn.disconnect.should.equal(conn.close);
|
178
|
-
});
|
179
|
-
|
180
|
-
});
|
181
|
-
|
182
|
-
describe("#Reconnect logic", function() {
|
183
|
-
this.timeout(10000);
|
184
|
-
var MDB = getMDB();
|
185
|
-
|
186
|
-
it("should finish query after reconnect", function() {
|
187
|
-
var conn = new MDB({testing: true, debug: true, logger: noop});
|
188
|
-
var query = conn.connect()
|
189
|
-
.then(function() {
|
190
|
-
conn.mapiConnection.socketError("ECONNRESET");
|
191
|
-
return conn.query("SELECT 'whatever' AS a");
|
192
|
-
})
|
193
|
-
.finally(function() {
|
194
|
-
conn.close();
|
195
|
-
});
|
196
|
-
|
197
|
-
shouldHaveValidResult(query, 1, 1, ["a"])
|
198
|
-
.should.eventually.have.property("data")
|
199
|
-
.that.deep.equals([["whatever"]]);
|
200
|
-
});
|
201
|
-
|
202
|
-
it("should finish many queries when reconnects occur in between", function() {
|
203
|
-
this.timeout(300000);
|
204
|
-
|
205
|
-
var conn = new MDB({testing: true});
|
206
|
-
return conn.connect()
|
207
|
-
.then(function() {
|
208
|
-
var qs = [];
|
209
|
-
for(var i=0; i<100; ++i) {
|
210
|
-
qs.push(
|
211
|
-
conn.query("SELECT " + i + " AS i")
|
212
|
-
.should.eventually.have.property("data")
|
213
|
-
.that.deep.equals([[i]])
|
214
|
-
);
|
215
|
-
}
|
216
|
-
// simulate connection failure with a random interval
|
217
|
-
var timeout = null;
|
218
|
-
function failNow() {
|
219
|
-
try {
|
220
|
-
conn.mapiConnection.socketError("ECONNRESET");
|
221
|
-
} catch(e) {}
|
222
|
-
timeout = setTimeout(failNow, 200 + Math.round(notSoRandom()*500));
|
223
|
-
}
|
224
|
-
failNow();
|
225
|
-
return Q.all(qs)
|
226
|
-
.finally(function() {
|
227
|
-
if(timeout !== null) clearTimeout(timeout);
|
228
|
-
conn.close();
|
229
|
-
});
|
230
|
-
});
|
231
|
-
});
|
232
|
-
|
233
|
-
it("should give up and fail queries after reaching its limits", function() {
|
234
|
-
var conn = new MDB({testing: true, maxReconnects: 2, reconnectTimeout: 1, debug: true, logger: noop});
|
235
|
-
return conn.connect()
|
236
|
-
.then(function() {
|
237
|
-
var qs = [
|
238
|
-
conn.query("SELECT 1").should.be.rejected,
|
239
|
-
conn.query("SELECT 2").should.be.rejected,
|
240
|
-
conn.query("SELECT 3").should.be.rejected
|
241
|
-
];
|
242
|
-
try {
|
243
|
-
conn.mapiConnection.socketError("ECONNRESET", true);
|
244
|
-
} catch(e) {
|
245
|
-
conn.close();
|
246
|
-
}
|
247
|
-
return Promise.all(qs)
|
248
|
-
})
|
249
|
-
.finally(function(){
|
250
|
-
conn.close();
|
251
|
-
});
|
252
|
-
|
253
|
-
});
|
254
|
-
|
255
|
-
});
|
256
|
-
|
257
|
-
describe("auto_commit logic", function() {
|
258
|
-
const MDB = getMDB();
|
259
|
-
|
260
|
-
it('should set auto_commit true by default' , async () => {
|
261
|
-
const conn = new MDB();
|
262
|
-
conn.autoCommit.should.equals(true);
|
263
|
-
});
|
264
|
-
|
265
|
-
it('should set auto_commit off and transactions not explicitly commited should be rolled back', async () => {
|
266
|
-
let conn = new MDB();
|
267
|
-
await conn.connect();
|
268
|
-
await conn.query(`
|
269
|
-
drop table if exists foo;
|
270
|
-
CREATE TABLE foo(a INT, b FLOAT, c BLOB);
|
271
|
-
`);
|
272
|
-
let res = await conn.query("select * from foo");
|
273
|
-
res['rows'].should.equals(0);
|
274
|
-
conn.close();
|
275
|
-
conn = new MDB({autoCommit: false});
|
276
|
-
conn.autoCommit.should.equals(false);
|
277
|
-
await conn.connect();
|
278
|
-
const qry = `INSERT INTO foo VALUES (42,4.2,'42'),(43,4.3,'43'),(44,4.4,'44'),(45,4.5,'45')`;
|
279
|
-
await conn.query(qry);
|
280
|
-
res = await conn.query("select * from foo");
|
281
|
-
res.rows.should.equals(4);
|
282
|
-
conn.close()
|
283
|
-
conn = new MDB();
|
284
|
-
await conn.connect();
|
285
|
-
res = await conn.query("select * from foo");
|
286
|
-
res.rows.should.equals(0);
|
287
|
-
await conn.query("drop table if exists foo;");
|
288
|
-
conn.close();
|
289
|
-
});
|
290
|
-
});
|
File without changes
|
File without changes
|
File without changes
|