@graffy/pg 0.16.6 → 0.16.7

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 +8 -2
  2. package/index.mjs +8 -2
  3. package/package.json +2 -2
package/index.cjs CHANGED
@@ -81,7 +81,9 @@ const valid = {
81
81
  $all: true,
82
82
  $has: true,
83
83
  $cts: true,
84
- $ctd: true
84
+ $ctd: true,
85
+ $keycts: true,
86
+ $keyctd: true
85
87
  };
86
88
  const inverse = {
87
89
  $eq: "$neq",
@@ -352,7 +354,9 @@ const opSql = {
352
354
  $re: sql`~`,
353
355
  $ire: sql`~*`,
354
356
  $cts: sql`@>`,
355
- $ctd: sql`<@`
357
+ $ctd: sql`<@`,
358
+ $keycts: sql`?|`,
359
+ $keyctd: sql`?&`
356
360
  };
357
361
  function getBinarySql(lhs, type, op, value, textLhs) {
358
362
  if (value === null && op === "$eq")
@@ -379,6 +383,8 @@ function getBinarySql(lhs, type, op, value, textLhs) {
379
383
  if (typeof value === "string") {
380
384
  return sql`${textLhs} ${sqlOp} ${value}`;
381
385
  }
386
+ if ((op === "$keycts" || op === "$keyctd") && Array.isArray(value))
387
+ return sql`${lhs} ${sqlOp} ${value}::text[]`;
382
388
  return sql`${lhs} ${sqlOp} ${JSON.stringify(value)}::jsonb`;
383
389
  }
384
390
  if (type === "cube")
package/index.mjs CHANGED
@@ -79,7 +79,9 @@ const valid = {
79
79
  $all: true,
80
80
  $has: true,
81
81
  $cts: true,
82
- $ctd: true
82
+ $ctd: true,
83
+ $keycts: true,
84
+ $keyctd: true
83
85
  };
84
86
  const inverse = {
85
87
  $eq: "$neq",
@@ -350,7 +352,9 @@ const opSql = {
350
352
  $re: sql`~`,
351
353
  $ire: sql`~*`,
352
354
  $cts: sql`@>`,
353
- $ctd: sql`<@`
355
+ $ctd: sql`<@`,
356
+ $keycts: sql`?|`,
357
+ $keyctd: sql`?&`
354
358
  };
355
359
  function getBinarySql(lhs, type, op, value, textLhs) {
356
360
  if (value === null && op === "$eq")
@@ -377,6 +381,8 @@ function getBinarySql(lhs, type, op, value, textLhs) {
377
381
  if (typeof value === "string") {
378
382
  return sql`${textLhs} ${sqlOp} ${value}`;
379
383
  }
384
+ if ((op === "$keycts" || op === "$keyctd") && Array.isArray(value))
385
+ return sql`${lhs} ${sqlOp} ${value}::text[]`;
380
386
  return sql`${lhs} ${sqlOp} ${JSON.stringify(value)}::jsonb`;
381
387
  }
382
388
  if (type === "cube")
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.16.6",
5
+ "version": "0.16.7",
6
6
  "main": "./index.cjs",
7
7
  "exports": {
8
8
  "import": "./index.mjs",
@@ -16,7 +16,7 @@
16
16
  },
17
17
  "license": "Apache-2.0",
18
18
  "dependencies": {
19
- "@graffy/common": "0.16.6",
19
+ "@graffy/common": "0.16.7",
20
20
  "debug": "^4.3.3"
21
21
  },
22
22
  "peerDependencies": {