loopbackio / loopbackio/loopback-datasource-juggler

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

Đang mở
#779 6 bình luận 1 reaction 1 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

backlog bug major
Ngôn ngữ chính
JavaScript
Star
282
Fork
366
Merge trung bình
17 giờ 4 phút
Pull request đã merge (30 ngày)
10

Mô tả

  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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.