@graffy/pg 0.17.8-alpha.2 → 0.17.8-alpha.3

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.
Files changed (3) hide show
  1. package/index.cjs +7 -8
  2. package/index.mjs +7 -8
  3. package/package.json +4 -4
package/index.cjs CHANGED
@@ -130,7 +130,7 @@ const lookup = (prop, options) => {
130
130
  return sql`"${raw(prefix)}" #> ${suffix}`;
131
131
  }
132
132
  if (types2[prefix] === "cube" && suffix.length === 1) {
133
- return sql`"${raw(prefix)}" ~> ${Number.parseInt(suffix[0])}`;
133
+ return sql`"${raw(prefix)}" ~> ${Number.parseInt(suffix[0], 10)}`;
134
134
  }
135
135
  throw Error(`pg.cannot_lookup ${prop}`);
136
136
  };
@@ -261,7 +261,7 @@ const getInsert = (rows, options) => {
261
261
  ", "
262
262
  ),
263
263
  updates: join(
264
- colSqls.map((col, ix) => sql`${col} = "excluded".${col}`).filter(isUsed),
264
+ colSqls.map((col, _ix) => sql`${col} = "excluded".${col}`).filter(isUsed),
265
265
  ", "
266
266
  )
267
267
  };
@@ -298,8 +298,8 @@ function getJsonUpdate(object, col, path) {
298
298
  let hasNulls = false;
299
299
  const patchSqls = Object.entries(object).map(([key, value]) => {
300
300
  const [valSql, nullable] = getJsonUpdate(value, col, path.concat(key));
301
- maybeNull && (maybeNull = nullable);
302
- hasNulls || (hasNulls = nullable);
301
+ maybeNull &&= nullable;
302
+ hasNulls ||= nullable;
303
303
  return sql`${key}::text, ${valSql}`;
304
304
  });
305
305
  let clause = sql`${baseSql} || jsonb_build_object(${join(patchSqls, ", ")})`;
@@ -666,7 +666,7 @@ function getSingleSql(arg, options) {
666
666
  };
667
667
  }
668
668
  const { where, meta } = getArgSql(arg, options);
669
- if (!(where == null ? void 0 : where.length)) throw Error("pg_write.no_condition");
669
+ if (!where?.length) throw Error("pg_write.no_condition");
670
670
  return {
671
671
  where: sql`"${raw(idCol)}" = (
672
672
  SELECT "${raw(idCol)}"
@@ -735,9 +735,8 @@ class Db {
735
735
  }
736
736
  }
737
737
  async query(sql2, tableOptions) {
738
- var _a, _b;
739
738
  log(`Making SQL query: ${sql2.text}`, sql2.values);
740
- const cubeOid = Number.parseInt(((_b = (_a = tableOptions == null ? void 0 : tableOptions.schema) == null ? void 0 : _a.typeOids) == null ? void 0 : _b.cube) || "0") || null;
739
+ const cubeOid = Number.parseInt(tableOptions?.schema?.typeOids?.cube || "0", 10) || null;
741
740
  try {
742
741
  sql2.types = {
743
742
  getTypeParser: (oid, format) => {
@@ -841,7 +840,7 @@ class Db {
841
840
  log("getByArgs", wrappedGraph);
842
841
  common.merge(results, wrappedGraph);
843
842
  };
844
- const explainArgs = async (args, projection) => {
843
+ const explainArgs = async (args, _projection) => {
845
844
  const { analyze, $explain: qArgs } = args;
846
845
  const qSql = selectByArgs(qArgs, null, tableOptions);
847
846
  const sql$1 = sql`EXPLAIN (${analyze ? sql`ANALYZE, BUFFERS, TIMING, ` : sql``}COSTS, VERBOSE, FORMAT JSON) ${qSql}`;
package/index.mjs CHANGED
@@ -128,7 +128,7 @@ const lookup = (prop, options) => {
128
128
  return sql`"${raw(prefix)}" #> ${suffix}`;
129
129
  }
130
130
  if (types2[prefix] === "cube" && suffix.length === 1) {
131
- return sql`"${raw(prefix)}" ~> ${Number.parseInt(suffix[0])}`;
131
+ return sql`"${raw(prefix)}" ~> ${Number.parseInt(suffix[0], 10)}`;
132
132
  }
133
133
  throw Error(`pg.cannot_lookup ${prop}`);
134
134
  };
@@ -259,7 +259,7 @@ const getInsert = (rows, options) => {
259
259
  ", "
260
260
  ),
261
261
  updates: join(
262
- colSqls.map((col, ix) => sql`${col} = "excluded".${col}`).filter(isUsed),
262
+ colSqls.map((col, _ix) => sql`${col} = "excluded".${col}`).filter(isUsed),
263
263
  ", "
264
264
  )
265
265
  };
@@ -296,8 +296,8 @@ function getJsonUpdate(object, col, path) {
296
296
  let hasNulls = false;
297
297
  const patchSqls = Object.entries(object).map(([key, value]) => {
298
298
  const [valSql, nullable] = getJsonUpdate(value, col, path.concat(key));
299
- maybeNull && (maybeNull = nullable);
300
- hasNulls || (hasNulls = nullable);
299
+ maybeNull &&= nullable;
300
+ hasNulls ||= nullable;
301
301
  return sql`${key}::text, ${valSql}`;
302
302
  });
303
303
  let clause = sql`${baseSql} || jsonb_build_object(${join(patchSqls, ", ")})`;
@@ -664,7 +664,7 @@ function getSingleSql(arg, options) {
664
664
  };
665
665
  }
666
666
  const { where, meta } = getArgSql(arg, options);
667
- if (!(where == null ? void 0 : where.length)) throw Error("pg_write.no_condition");
667
+ if (!where?.length) throw Error("pg_write.no_condition");
668
668
  return {
669
669
  where: sql`"${raw(idCol)}" = (
670
670
  SELECT "${raw(idCol)}"
@@ -733,9 +733,8 @@ class Db {
733
733
  }
734
734
  }
735
735
  async query(sql2, tableOptions) {
736
- var _a, _b;
737
736
  log(`Making SQL query: ${sql2.text}`, sql2.values);
738
- const cubeOid = Number.parseInt(((_b = (_a = tableOptions == null ? void 0 : tableOptions.schema) == null ? void 0 : _a.typeOids) == null ? void 0 : _b.cube) || "0") || null;
737
+ const cubeOid = Number.parseInt(tableOptions?.schema?.typeOids?.cube || "0", 10) || null;
739
738
  try {
740
739
  sql2.types = {
741
740
  getTypeParser: (oid, format2) => {
@@ -839,7 +838,7 @@ class Db {
839
838
  log("getByArgs", wrappedGraph);
840
839
  merge(results, wrappedGraph);
841
840
  };
842
- const explainArgs = async (args, projection) => {
841
+ const explainArgs = async (args, _projection) => {
843
842
  const { analyze, $explain: qArgs } = args;
844
843
  const qSql = selectByArgs(qArgs, null, tableOptions);
845
844
  const sql$1 = sql`EXPLAIN (${analyze ? sql`ANALYZE, BUFFERS, TIMING, ` : sql``}COSTS, VERBOSE, FORMAT JSON) ${qSql}`;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graffy/pg",
3
3
  "description": "The standard Postgres module for Graffy. Each instance this module mounts a Postgres table as a Graffy subtree.",
4
4
  "author": "aravind (https://github.com/aravindet)",
5
- "version": "0.17.8-alpha.2",
5
+ "version": "0.17.8-alpha.3",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -16,9 +16,9 @@
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@graffy/common": "0.17.8-alpha.2",
20
- "debug": "^4.4.1",
21
- "sql-formatter": "^15.6.4"
19
+ "@graffy/common": "0.17.8-alpha.3",
20
+ "debug": "^4.4.3",
21
+ "sql-formatter": "^15.7.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "pg": "^8.0.0"