json-fs-query 1.0.3 → 1.0.4

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.
@@ -28,6 +28,13 @@ const getJoinIndexedList = async (parsed, recordData, dataSets) => {
28
28
  // was actually parsed - silently discarding every join clause whenever the query had no WHERE.
29
29
  return parsed
30
30
  }
31
+ if (!joinClauses.length) {
32
+ // A WHERE condition DID index entity's own rows above, but this query has no join at all -
33
+ // joinEntity is undefined. The loop below writes dataSets[entity][anEntity][joinEntity]
34
+ // unconditionally; left unguarded, that assigns a literal "undefined" key (object[undefined]
35
+ // coerces to the string "undefined") onto every row, since there's no join to actually attach.
36
+ return parsed
37
+ }
31
38
  for (const anEntity in dataSets[entity]) {
32
39
  const currentEntity = dataSets[entity][anEntity]
33
40
  // Loop over each of the main entities
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJoinIndexedList=void 0;var _siFunciona=_interopRequireDefault(require("si-funciona")),_splitEntityProperty=require("./parsers/splitEntityProperty"),_retrieveRecord=require("./retrieveRecord"),_getMatchingIndexes=require("./getMatchingIndexes"),_matchIndexedJoins=require("./matchIndexedJoins"),_restrictIndexedList=require("./restrictIndexedList");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const getJoinIndexedList=async(e,t,r)=>{let i=[];const n={};let o=!0;const s=e.entity,c=e.joinEntity,d=e.joinClauses;if(!r[s].length)return e;for(const e in r[s]){const a=r[s][e];let p={};p[s]=[_siFunciona.default.cloneObject(a)];for(let e of d){let c=_siFunciona.default.cloneObject(n);const{entity:d,property:a}=(0,_splitEntityProperty.splitEntityProperty)(e.propertyA),{entity:l,property:u}=(0,_splitEntityProperty.splitEntityProperty)(e.propertyB);Object.prototype.hasOwnProperty.call(t,d)||(t[d]=await(0,_retrieveRecord.retrieveRecord)(d)),Object.prototype.hasOwnProperty.call(t,l)||(t[l]=await(0,_retrieveRecord.retrieveRecord)(l)),c=(0,_restrictIndexedList.restrictIndexedList)(e,p,c);const y=(0,_matchIndexedJoins.matchIndexedJoins)(s,c,r),_=await(0,_getMatchingIndexes.getMatchingIndexes)(d,a,t,e,p,n),x=await(0,_getMatchingIndexes.getMatchingIndexes)(l,u,t,e,p,n,y);!(_||x)&&o&&(i.push(e),o=!1)}r[s][e][c]=p[c]}return e.joinClauses=i,e};exports.getJoinIndexedList=getJoinIndexedList;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.getJoinIndexedList=void 0;var _siFunciona=_interopRequireDefault(require("si-funciona")),_splitEntityProperty=require("./parsers/splitEntityProperty"),_retrieveRecord=require("./retrieveRecord"),_getMatchingIndexes=require("./getMatchingIndexes"),_matchIndexedJoins=require("./matchIndexedJoins"),_restrictIndexedList=require("./restrictIndexedList");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const getJoinIndexedList=async(e,t,r)=>{let i=[];const n={};let o=!0;const s=e.entity,c=e.joinEntity,d=e.joinClauses;if(!r[s].length)return e;if(!d.length)return e;for(const e in r[s]){const a=r[s][e];let p={};p[s]=[_siFunciona.default.cloneObject(a)];for(let e of d){let c=_siFunciona.default.cloneObject(n);const{entity:d,property:a}=(0,_splitEntityProperty.splitEntityProperty)(e.propertyA),{entity:l,property:u}=(0,_splitEntityProperty.splitEntityProperty)(e.propertyB);Object.prototype.hasOwnProperty.call(t,d)||(t[d]=await(0,_retrieveRecord.retrieveRecord)(d)),Object.prototype.hasOwnProperty.call(t,l)||(t[l]=await(0,_retrieveRecord.retrieveRecord)(l)),c=(0,_restrictIndexedList.restrictIndexedList)(e,p,c);const y=(0,_matchIndexedJoins.matchIndexedJoins)(s,c,r),_=await(0,_getMatchingIndexes.getMatchingIndexes)(d,a,t,e,p,n),x=await(0,_getMatchingIndexes.getMatchingIndexes)(l,u,t,e,p,n,y);!(_||x)&&o&&(i.push(e),o=!1)}r[s][e][c]=p[c]}return e.joinClauses=i,e};exports.getJoinIndexedList=getJoinIndexedList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-fs-query",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Use json files to manage and read data.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",