@malloydata/db-duckdb 0.0.125-dev240212230553 → 0.0.125-dev240213000017
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/dist/duckdb_connection.d.ts +1 -0
- package/dist/duckdb_connection.js +18 -10
- package/package.json +2 -2
|
@@ -35,6 +35,7 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
35
35
|
this.additionalExtensions = [];
|
|
36
36
|
this.databasePath = ':memory:';
|
|
37
37
|
this.workingDirectory = '.';
|
|
38
|
+
this.isMotherDuck = false;
|
|
38
39
|
this.readOnly = false;
|
|
39
40
|
this.connection = null;
|
|
40
41
|
if (typeof arg === 'string') {
|
|
@@ -73,25 +74,28 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
73
74
|
if (this.databasePath === ':memory:') {
|
|
74
75
|
this.readOnly = false;
|
|
75
76
|
}
|
|
77
|
+
this.isMotherDuck =
|
|
78
|
+
this.databasePath.startsWith('md:') ||
|
|
79
|
+
this.databasePath.startsWith('motherduck:');
|
|
76
80
|
this.connecting = this.init();
|
|
77
81
|
}
|
|
78
82
|
async init() {
|
|
79
83
|
return new Promise(resolve => {
|
|
80
|
-
let activeDB;
|
|
81
84
|
if (this.databasePath in DuckDBConnection.activeDBs) {
|
|
82
|
-
activeDB = DuckDBConnection.activeDBs[this.databasePath];
|
|
85
|
+
const activeDB = DuckDBConnection.activeDBs[this.databasePath];
|
|
83
86
|
this.connection = activeDB.database.connect();
|
|
84
87
|
activeDB.connections.push(this.connection);
|
|
85
88
|
resolve();
|
|
86
89
|
}
|
|
87
90
|
else {
|
|
88
|
-
if (this.
|
|
91
|
+
if (this.isMotherDuck) {
|
|
89
92
|
if (this.motherDuckToken) {
|
|
90
93
|
process.env['motherduck_token'] = this.motherDuckToken;
|
|
91
94
|
}
|
|
92
95
|
if (!process.env['motherduck_token'] &&
|
|
93
96
|
!process.env['MOTHERDUCK_TOKEN']) {
|
|
94
97
|
this.setupError = new Error('Please set your MotherDuck Token');
|
|
98
|
+
// Resolve instead of error because errors cannot be caught.
|
|
95
99
|
return resolve();
|
|
96
100
|
}
|
|
97
101
|
}
|
|
@@ -100,13 +104,17 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
|
|
|
100
104
|
this.setupError = err;
|
|
101
105
|
}
|
|
102
106
|
else {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
this.connection = database.connect();
|
|
108
|
+
// Don't cache MotherDuck connections so they can
|
|
109
|
+
// pick up fresh credentials if necessary.
|
|
110
|
+
if (!this.isMotherDuck) {
|
|
111
|
+
const activeDB = {
|
|
112
|
+
database,
|
|
113
|
+
connections: [],
|
|
114
|
+
};
|
|
115
|
+
DuckDBConnection.activeDBs[this.databasePath] = activeDB;
|
|
116
|
+
activeDB.connections.push(this.connection);
|
|
117
|
+
}
|
|
110
118
|
}
|
|
111
119
|
resolve();
|
|
112
120
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/db-duckdb",
|
|
3
|
-
"version": "0.0.125-
|
|
3
|
+
"version": "0.0.125-dev240213000017",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@malloydata/duckdb-wasm": "0.0.6",
|
|
44
|
-
"@malloydata/malloy": "^0.0.125-
|
|
44
|
+
"@malloydata/malloy": "^0.0.125-dev240213000017",
|
|
45
45
|
"apache-arrow": "^13.0.0",
|
|
46
46
|
"duckdb": "0.9.2",
|
|
47
47
|
"web-worker": "^1.2.0"
|