@atscript/db-postgres 0.1.54 → 0.1.55

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/index.cjs CHANGED
@@ -514,8 +514,12 @@ var PostgresAdapter = class PostgresAdapter extends _atscript_db.BaseDbAdapter {
514
514
  async updateOne(filter, data, ops) {
515
515
  const where = buildWhere(filter);
516
516
  const tableName = this.resolveTableName();
517
+ const quotedTable = quoteTableName(tableName);
518
+ const pkCols = this._table.primaryKeys;
519
+ const quotedKeys = (pkCols.length > 0 ? pkCols : ["ctid"]).map((c) => c === "ctid" ? "ctid" : qi(c));
520
+ const colList = quotedKeys.join(", ");
517
521
  const { sql, params } = buildUpdate(tableName, data, {
518
- sql: `ctid = (SELECT ctid FROM ${quoteTableName(tableName)} WHERE ${where.sql} LIMIT 1)`,
522
+ sql: `${quotedKeys.length === 1 ? quotedKeys[0] : `(${colList})`} ${quotedKeys.length === 1 ? "=" : "IN"} (SELECT ${colList} FROM ${quotedTable} WHERE ${where.sql} LIMIT 1)`,
519
523
  params: where.params
520
524
  }, void 0, ops);
521
525
  this._log(sql, params);
package/dist/index.mjs CHANGED
@@ -513,8 +513,12 @@ var PostgresAdapter = class PostgresAdapter extends BaseDbAdapter {
513
513
  async updateOne(filter, data, ops) {
514
514
  const where = buildWhere(filter);
515
515
  const tableName = this.resolveTableName();
516
+ const quotedTable = quoteTableName(tableName);
517
+ const pkCols = this._table.primaryKeys;
518
+ const quotedKeys = (pkCols.length > 0 ? pkCols : ["ctid"]).map((c) => c === "ctid" ? "ctid" : qi(c));
519
+ const colList = quotedKeys.join(", ");
516
520
  const { sql, params } = buildUpdate$1(tableName, data, {
517
- sql: `ctid = (SELECT ctid FROM ${quoteTableName(tableName)} WHERE ${where.sql} LIMIT 1)`,
521
+ sql: `${quotedKeys.length === 1 ? quotedKeys[0] : `(${colList})`} ${quotedKeys.length === 1 ? "=" : "IN"} (SELECT ${colList} FROM ${quotedTable} WHERE ${where.sql} LIMIT 1)`,
518
522
  params: where.params
519
523
  }, void 0, ops);
520
524
  this._log(sql, params);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-postgres",
3
- "version": "0.1.54",
3
+ "version": "0.1.55",
4
4
  "description": "PostgreSQL adapter for @atscript/db with pg (node-postgres) driver support.",
5
5
  "keywords": [
6
6
  "atscript",
@@ -43,20 +43,20 @@
43
43
  "access": "public"
44
44
  },
45
45
  "devDependencies": {
46
- "@atscript/core": "^0.1.48",
47
- "@atscript/typescript": "^0.1.48",
46
+ "@atscript/core": "^0.1.50",
47
+ "@atscript/typescript": "^0.1.50",
48
48
  "@types/pg": "^8.11.0",
49
49
  "@uniqu/core": "^0.1.5",
50
50
  "pg": "^8.13.0",
51
- "unplugin-atscript": "^0.1.48"
51
+ "unplugin-atscript": "^0.1.50"
52
52
  },
53
53
  "peerDependencies": {
54
- "@atscript/core": "^0.1.48",
55
- "@atscript/typescript": "^0.1.48",
54
+ "@atscript/core": "^0.1.50",
55
+ "@atscript/typescript": "^0.1.50",
56
56
  "@uniqu/core": "^0.1.5",
57
57
  "pg": ">=8.0.0",
58
- "@atscript/db": "^0.1.54",
59
- "@atscript/db-sql-tools": "^0.1.54"
58
+ "@atscript/db-sql-tools": "^0.1.55",
59
+ "@atscript/db": "^0.1.55"
60
60
  },
61
61
  "peerDependenciesMeta": {
62
62
  "pg": {