duckdb 0.4.1-dev2356.0 → 0.4.1-dev2367.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/lib/duckdb.js CHANGED
@@ -92,6 +92,7 @@ QueryResult.prototype[Symbol.asyncIterator] = async function*() {
92
92
 
93
93
 
94
94
  /**
95
+ * Run a SQL statement and trigger a callback when done
95
96
  * @arg sql
96
97
  * @param {...*} params
97
98
  * @param callback
@@ -103,6 +104,7 @@ Connection.prototype.run = function (sql) {
103
104
  }
104
105
 
105
106
  /**
107
+ * Run a SQL query and triggers the callback once for all result rows
106
108
  * @arg sql
107
109
  * @param {...*} params
108
110
  * @param callback
@@ -114,6 +116,7 @@ Connection.prototype.all = function (sql) {
114
116
  }
115
117
 
116
118
  /**
119
+ * Runs a SQL query and triggers the callback for each result row
117
120
  * @arg sql
118
121
  * @param {...*} params
119
122
  * @param callback
@@ -260,6 +263,7 @@ Connection.prototype.register = function (name, return_type, fun) {
260
263
  }
261
264
 
262
265
  /**
266
+ * Prepare a SQL query for execution
263
267
  * @method
264
268
  * @arg sql
265
269
  * @param {...*} params
@@ -268,6 +272,7 @@ Connection.prototype.register = function (name, return_type, fun) {
268
272
  */
269
273
  Connection.prototype.prepare;
270
274
  /**
275
+ * Execute a SQL query
271
276
  * @method
272
277
  * @arg sql
273
278
  * @param {...*} params
@@ -305,16 +310,28 @@ var default_connection = function (o) {
305
310
 
306
311
 
307
312
  /**
313
+ * Closes database instance
308
314
  * @method
309
315
  * @param callback
310
316
  * @return {void}
311
317
  */
312
- Database.prototype.close;
318
+ Database.prototype.close = function() {
319
+ this.default_connection = null
320
+ this.close_internal.apply(this, arguments);
321
+ };
313
322
 
314
323
  /**
324
+ * Internal method. Do not use, call Connection#close instead
325
+ * @method
326
+ * @param callback
327
+ * @return {void}
328
+ */
329
+ Database.prototype.close_internal;
330
+
331
+ /**
332
+ * Triggers callback when all scheduled database tasks have completed.
315
333
  * @method
316
334
  * @param callback
317
- * TODO: what does this do?
318
335
  * @return {void}
319
336
  */
320
337
  Database.prototype.wait;
@@ -336,6 +353,7 @@ Database.prototype.serialize;
336
353
  Database.prototype.parallelize;
337
354
 
338
355
  /**
356
+ * Create a new database connection
339
357
  * @method
340
358
  * @arg path the database to connect to, either a file path, or `:memory:`
341
359
  * @return {Connection}
@@ -343,7 +361,7 @@ Database.prototype.parallelize;
343
361
  Database.prototype.connect;
344
362
 
345
363
  /**
346
- * TODO: what does this do?
364
+ * Supposedly interrupt queries, but currently does not do anything.
347
365
  * @method
348
366
  * @param callback
349
367
  * @return {void}
@@ -351,6 +369,7 @@ Database.prototype.connect;
351
369
  Database.prototype.interrupt;
352
370
 
353
371
  /**
372
+ * Prepare a SQL query for execution
354
373
  * @arg sql
355
374
  * @return {Statement}
356
375
  */
@@ -359,6 +378,7 @@ Database.prototype.prepare = function () {
359
378
  }
360
379
 
361
380
  /**
381
+ * Convenience method for Connection#run using a built-in default connection
362
382
  * @arg sql
363
383
  * @param {...*} params
364
384
  * @param callback
@@ -370,6 +390,7 @@ Database.prototype.run = function () {
370
390
  }
371
391
 
372
392
  /**
393
+ * Convenience method for Connection#each using a built-in default connection
373
394
  * @arg sql
374
395
  * @param {...*} params
375
396
  * @param callback
@@ -381,6 +402,7 @@ Database.prototype.each = function () {
381
402
  }
382
403
 
383
404
  /**
405
+ * Convenience method for Connection#apply using a built-in default connection
384
406
  * @arg sql
385
407
  * @param {...*} params
386
408
  * @param callback
@@ -392,6 +414,7 @@ Database.prototype.all = function () {
392
414
  }
393
415
 
394
416
  /**
417
+ * Convenience method for Connection#exec using a built-in default connection
395
418
  * @arg sql
396
419
  * @param {...*} params
397
420
  * @param callback
@@ -403,9 +426,7 @@ Database.prototype.exec = function () {
403
426
  }
404
427
 
405
428
  /**
406
- * Register a User Defined Function
407
- *
408
- * Convenience method for Connection#register
429
+ * Convenience method for Connection#register using a built-in default connection
409
430
  * @arg name
410
431
  * @arg return_type
411
432
  * @arg fun
@@ -417,9 +438,7 @@ Database.prototype.register = function () {
417
438
  }
418
439
 
419
440
  /**
420
- * Unregister a User Defined Function
421
- *
422
- * Convenience method for Connection#unregister
441
+ * Convenience method for Connection#unregister using a built-in default connection
423
442
  * @arg name
424
443
  * @return {this}
425
444
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.4.1-dev2356.0",
4
+ "version": "0.4.1-dev2367.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
@@ -31,8 +31,29 @@ struct ConnectTask : public Task {
31
31
 
32
32
  void DoWork() override {
33
33
  auto &connection = Get<Connection>();
34
+ if (!connection.database_ref || !connection.database_ref->database) {
35
+ return;
36
+ }
34
37
  connection.connection = duckdb::make_unique<duckdb::Connection>(*connection.database_ref->database);
38
+ success = true;
39
+ }
40
+ void Callback() override {
41
+ auto &connection = Get<Connection>();
42
+ Napi::Env env = connection.Env();
43
+
44
+ std::vector<napi_value> args;
45
+ if (!success) {
46
+ args.push_back(Utils::CreateError(env, "Invalid database object"));
47
+ } else {
48
+ args.push_back(env.Null());
49
+ }
50
+
51
+ Napi::HandleScope scope(env);
52
+
53
+ callback.Value().MakeCallback(connection.Value(), args);
35
54
  }
55
+
56
+ bool success = false;
36
57
  };
37
58
 
38
59
  Connection::Connection(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Connection>(info) {
package/src/database.cpp CHANGED
@@ -11,7 +11,7 @@ Napi::Object Database::Init(Napi::Env env, Napi::Object exports) {
11
11
 
12
12
  Napi::Function t = DefineClass(
13
13
  env, "Database",
14
- {InstanceMethod("close", &Database::Close), InstanceMethod("wait", &Database::Wait),
14
+ {InstanceMethod("close_internal", &Database::Close), InstanceMethod("wait", &Database::Wait),
15
15
  InstanceMethod("serialize", &Database::Serialize), InstanceMethod("parallelize", &Database::Parallelize),
16
16
  InstanceMethod("connect", &Database::Connect), InstanceMethod("interrupt", &Database::Interrupt)});
17
17
 
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "73530d93c"
15
- #define DUCKDB_VERSION "v0.4.1-dev2356"
14
+ #define DUCKDB_SOURCE_ID "32e28e153"
15
+ #define DUCKDB_VERSION "v0.4.1-dev2367"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //