@pineliner/odb-client 1.5.0 → 1.5.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"odblite-socket.d.ts","sourceRoot":"","sources":["../../../src/database/adapters/odblite-socket.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAkC,MAAM,UAAU,CAAA;AAExG,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AA0KjE,MAAM,WAAW,mBAAoB,SAAQ,YAAY;CAAG;AAE5D,qBAAa,oBAAqB,YAAW,eAAe;IAC1D,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAmB;IAC7C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAc;gBAEzB,MAAM,EAAE,mBAAmB;IAIjC,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAMzC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAmBpC;AAED;;mCAEmC;AACnC,eAAO,MAAM,sBAAsB,IAAI,CAAA;AAEvC,sFAAsF;AACtF,eAAO,MAAM,mBAAmB,sBAAsB,CAAA;AAEtD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,CAAC,EAAE,MAAM,GAAG,YAAY,CAO1D;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,kBAAmB,YAAW,eAAe;IACxD,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6C;IAClE,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAI;gBAEX,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC;QAAC,IAAI,EAAE,GAA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Q,CAAC,IAAI,CAA6C;IAClE,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,WAAW,CAAI;gBAEX,IAAI,EAAE;QAAE,MAAM,CAAC,EAAE,mBAAmB,CAAC;QAAC,IAAI,EAAE,GAAG,CAAA;KAAE;YAK/C,IAAI;IAWlB,oEAAoE;YACtD,SAAS;IAgBvB;;8CAE0C;YAC5B,YAAY;IAY1B;uFACmF;IACnF,OAAO,CAAC,UAAU;IAgBZ,OAAO,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC;IAIzC,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAG5C,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;CAGpC"}
package/dist/index.cjs CHANGED
@@ -2452,13 +2452,15 @@ var __webpack_exports__ = {};
2452
2452
  return toQueryResult(res);
2453
2453
  }
2454
2454
  async query(sql, params = []) {
2455
- if (null != this.streamId) return await this.streamExec(sql, params);
2455
+ const s = 'string' == typeof sql ? sql : sql.sql;
2456
+ const p = 'string' == typeof sql ? params : sql.args ?? [];
2457
+ if (null != this.streamId) return await this.streamExec(s, p);
2456
2458
  return toQueryResult(await this.one([
2457
2459
  {
2458
2460
  type: 'execute',
2459
2461
  stmt: {
2460
- sql,
2461
- args: params.map(toHrana)
2462
+ sql: s,
2463
+ args: p.map(toHrana)
2462
2464
  }
2463
2465
  }
2464
2466
  ]));
package/dist/index.js CHANGED
@@ -2362,13 +2362,15 @@ class OdbliteSocketConnection {
2362
2362
  return toQueryResult(res);
2363
2363
  }
2364
2364
  async query(sql, params = []) {
2365
- if (null != this.streamId) return await this.streamExec(sql, params);
2365
+ const s = 'string' == typeof sql ? sql : sql.sql;
2366
+ const p = 'string' == typeof sql ? params : sql.args ?? [];
2367
+ if (null != this.streamId) return await this.streamExec(s, p);
2366
2368
  return toQueryResult(await this.one([
2367
2369
  {
2368
2370
  type: 'execute',
2369
2371
  stmt: {
2370
- sql,
2371
- args: params.map(toHrana)
2372
+ sql: s,
2373
+ args: p.map(toHrana)
2372
2374
  }
2373
2375
  }
2374
2376
  ]));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pineliner/odb-client",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Isomorphic client for ODB-Lite with postgres.js-like template string SQL support",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -91,9 +91,14 @@ class OdbliteSocketConnection implements Connection {
91
91
  return toQueryResult(res)
92
92
  }
93
93
 
94
- async query<T = any>(sql: string, params: any[] = []): Promise<QueryResult<T>> {
95
- if (this.streamId != null) return (await this.streamExec(sql, params)) as QueryResult<T>
96
- return toQueryResult(await this.one([{ type: 'execute', stmt: { sql, args: params.map(toHrana) } }])) as QueryResult<T>
94
+ async query<T = any>(sql: string | { sql: string; args?: any[] }, params: any[] = []): Promise<QueryResult<T>> {
95
+ // Accept both query(sql, params) and query({ sql, args }) symmetric with
96
+ // execute() and the other adapters. Without this, object-form calls sent the
97
+ // object itself as the SQL string ("Expected 'query' to be a string, got 'object'").
98
+ const s = typeof sql === 'string' ? sql : sql.sql
99
+ const p = typeof sql === 'string' ? params : (sql.args ?? [])
100
+ if (this.streamId != null) return (await this.streamExec(s, p)) as QueryResult<T>
101
+ return toQueryResult(await this.one([{ type: 'execute', stmt: { sql: s, args: p.map(toHrana) } }])) as QueryResult<T>
97
102
  }
98
103
 
99
104
  async execute(sql: string | { sql: string; args?: any[] }, params: any[] = []): Promise<QueryResult> {