spice-couchbase 2.0.23 → 2.0.26

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/build/index.js CHANGED
@@ -446,6 +446,10 @@ module.exports = class Database {
446
446
  var is_legacy = _this15.scope_name !== "_default" && _this15.collection_name !== "_default";
447
447
  var bucket = "`".concat(_this15.use_bucket_name ? _this15.bucket : _this15.collection_name, "`");
448
448
 
449
+ function containsIdWithSpace(str) {
450
+ return /\b\.?id\b/i.test(str); // Updated regex to match "id" as a separate word or preceded by a dot (".id")
451
+ }
452
+
449
453
  try {
450
454
  var fix = ", META(".concat(bucket, ").id AS id");
451
455
 
@@ -457,7 +461,7 @@ module.exports = class Database {
457
461
  columns = "";
458
462
  }
459
463
 
460
- var front_query = "SELECT ".concat(columns, " ").concat(fix, " FROM ").concat(bucket);
464
+ var front_query = "SELECT ".concat(columns, " ").concat(containsIdWithSpace(columns) ? "" : fix, " FROM ").concat(bucket);
461
465
  var conditions = [];
462
466
 
463
467
  if (_this15.use_bucket_name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spice-couchbase",
3
- "version": "2.0.23",
3
+ "version": "2.0.26",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
package/src/index.js CHANGED
@@ -416,6 +416,10 @@ module.exports = class Database {
416
416
  this.use_bucket_name ? this.bucket : this.collection_name
417
417
  }\``;
418
418
 
419
+ function containsIdWithSpace(str) {
420
+ return /\b\.?id\b/i.test(str); // Updated regex to match "id" as a separate word or preceded by a dot (".id")
421
+ }
422
+
419
423
  try {
420
424
  const fix = `, META(${bucket}).id AS id`;
421
425
 
@@ -427,7 +431,9 @@ module.exports = class Database {
427
431
  columns = "";
428
432
  }
429
433
 
430
- const front_query = `SELECT ${columns} ${fix} FROM ${bucket}`;
434
+ const front_query = `SELECT ${columns} ${
435
+ containsIdWithSpace(columns) ? "" : fix
436
+ } FROM ${bucket}`;
431
437
  const conditions = [];
432
438
 
433
439
  if (this.use_bucket_name) {