loopbackio / loopbackio/loopback-datasource-juggler

loopback fails on referencesMany relation missing foreignKey in scope for nested hasMany inclusion

未关闭
#779 6 条评论 1 个 reaction 已指派 1 人 在 GitHub 查看

还没有人认领这个 Issue。

backlog bug major
主要语言
JavaScript
星标
282
派生
366
平均合并
17 小时 4 分钟
30 天内合并 PR
10

描述

  1. say model A as a referencesMany relation with model B
    and model B has a hasMany relation with model C
  2. adding a scope in relation A>B to restrict fields in a way that 'A.id' is not included in results
  3. doing a GET on model A to get B relations through referencesMany, using built-in methods, and including relation B>C using filter {include:C}

loopback fails with
TypeError: Cannot read property 'toString' of undefined at KVMap.keyToString (../api_loopback/node_modules/loopback-datasource-juggler/lib/include_utils.js:64:46) at Object.KVMap.mapImpl.set (../api_loopback/node_modules/loopback-datasource-juggler/lib/include_utils.js:70:13) at Object.buildOneToOneIdentityMapWithOrigKeys (../api_loopback/node_modules/loopback-datasource-juggler/lib/include_utils.js:19:11) at includeHasManySimple (../api_loopback/node_modules/loopback-datasource-juggler/lib/include.js:498:36) at processIncludeItem (../api_loopback/node_modules/loopback-datasource-juggler/lib/include.js:275:16) at ../api_loopback/node_modules/loopback-datasource-juggler/lib/include.js:173:5 at ../api_loopback/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:157:13 at _each (../api_loopback/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:57:9) at Object.async.each (../api_loopback/node_modules/loopback-datasource-juggler/node_modules/async/lib/async.js:156:9) at Function.Inclusion.include (../api_loopback/node_modules/loopback-datasource-juggler/lib/include.js:172:9)

Obviously the include cannot work as i'm missing the id for relation hasMany to work, but this should be caught silently and not return the inclusion (which is actually the intent) rather than killing the server

Could easily fix this, but as there are many places to do so, i'd prefer to wait for proper guidance before submitting a fix proposal.

Eric

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。