@malloydata/db-duckdb 0.0.147-dev240517204819 → 0.0.147-dev240522023038

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.
@@ -88,16 +88,24 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
88
88
  }
89
89
  else {
90
90
  if (this.isMotherDuck) {
91
- if (this.motherDuckToken) {
92
- process.env['motherduck_token'] = this.motherDuckToken;
93
- process.env['MOTHERDUCK_TOKEN'] = this.motherDuckToken;
94
- }
95
- if (!process.env['motherduck_token'] &&
91
+ if (!this.motherDuckToken &&
92
+ !process.env['motherduck_token'] &&
96
93
  !process.env['MOTHERDUCK_TOKEN']) {
97
94
  this.setupError = new Error('Please set your MotherDuck Token');
98
95
  // Resolve instead of error because errors cannot be caught.
99
96
  return resolve();
100
97
  }
98
+ if (this.motherDuckToken) {
99
+ try {
100
+ const dbUrl = new URL(this.databasePath);
101
+ dbUrl.searchParams.set('motherduck_token', this.motherDuckToken);
102
+ this.databasePath = dbUrl.toString();
103
+ }
104
+ catch {
105
+ // eslint-disable-next-line no-console
106
+ console.warn('Unable to update MotherDuck URL with token');
107
+ }
108
+ }
101
109
  }
102
110
  const database = new duckdb_1.Database(this.databasePath, this.readOnly ? duckdb_1.OPEN_READONLY : duckdb_1.OPEN_READWRITE, err => {
103
111
  if (err) {
@@ -105,16 +113,12 @@ class DuckDBConnection extends duckdb_common_1.DuckDBCommon {
105
113
  }
106
114
  else {
107
115
  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
- }
116
+ const activeDB = {
117
+ database,
118
+ connections: [],
119
+ };
120
+ DuckDBConnection.activeDBs[this.databasePath] = activeDB;
121
+ activeDB.connections.push(this.connection);
118
122
  }
119
123
  resolve();
120
124
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/db-duckdb",
3
- "version": "0.0.147-dev240517204819",
3
+ "version": "0.0.147-dev240522023038",
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
  "@duckdb/duckdb-wasm": "1.28.1-dev195.0",
44
- "@malloydata/malloy": "^0.0.147-dev240517204819",
44
+ "@malloydata/malloy": "^0.0.147-dev240522023038",
45
45
  "@motherduck/wasm-client": "^0.6.1",
46
46
  "apache-arrow": "^15.0.2",
47
47
  "duckdb": "0.10.2",