[BUG] create helper function ignores the id property when it's equal to 0.
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 新手友好度
- 55/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
- 領域
- databases
研究方向
從 dao.js 第 378 行附近的 createCallback 函式開始,追蹤 callback id 如何指派給已建立的物件。重現一次 id 為 0 的 create 呼叫,然後為預期回應新增涵蓋範圍,並驗證 0 及更大的 id 都會被保留。
由索引模型根據 Issue 內容生成。
描述
Description :
Create call on a loopback model returns a property id as a response, in case where the property id starts from 0 it is removed from response. This is because the create function( dao.js line no 378) which gets the id as a callback on the create call in a loopback model, does not accepts 0 as an id.
Code snippet from dao.js
if id is 0 it is skipping the if block
function createCallback(err, id, rev) {
if (id) {
obj.__data[_idName] = id;
defineReadonlyProp(obj, _idName, id);
}
We have a scenario where the id starts from 0, and this is causing the id property for our 0th element to be removed from the response.
Steps to reproduce :
- Model which has a property id which starts from 0.
- Call the api to create which will have the id (starting from 0) in response.
- Response will be missing the id property for the first call where id is 0, and it'll add the id property in response starting from id as 1 onwards.
Current Response Behaviour :
id is removed when its value is equal to 0
{
"property1" : "property1",
"property2" : "property2"
}
Expected Results :
{
"id" : 0
"property1" : "property1",
"property2" : "property2"
}
- 主要語言
- JavaScript
- 星號
- 279
- 分支
- 362
- 平均合併
- 21 小時 14 分鐘
- 30 天內合併 PR
- 16
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
loopbackio/loopback-datasource-juggler 的其他 Issue
-
Breaking changes for `loopback-datasource-juggler@7` not listed anywhere可能重新可做 @dhmlau 於 158 天前認領,目前沒有進行中的 PR。 未關閉bug
loopbackio/loopback-datasource-juggler#2548 · 1 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
難度 3/5 1-2 天 新手友好度 68/100
loopbackio/loopback-datasource-juggler#2530 ·
維護者通常 1 天內回覆
-
allow empty array in createAll可能已有人在做 @ajay-prajapati07 於 533 天前認領。 未關閉feature
難度 3/5 1-2 天 新手友好度 45/100
loopbackio/loopback-datasource-juggler#2409 ·
維護者通常 1 天內回覆
-
bug
難度 4/5 3-5 天 新手友好度 25/100
loopbackio/loopback-datasource-juggler#2319 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 15/100
loopbackio/loopback-datasource-juggler#1917 ·
維護者通常 1 天內回覆
查看 loopbackio/loopback-datasource-juggler 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 82/100
ipfs/ipfs-webui#2507 ·
-
Environments table lists page size 5 after 30可能已有人在做 @raus7n 今天認領。 未關閉
難度 1/5 1 小時以內 新手友好度 90/100
litmuschaos/litmus#5743 ·
維護者通常 2 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 63/100
anothaDev/luci-theme-vantage#143 ·
維護者通常 1 天內回覆
-
desktop grp:admin-donors type:graphics-bug ui-admin
難度 2/5 1-3 小時 新手友好度 72/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 72/100
kingcharleslzy-ai/dsh-purge#282 ·
維護者通常 1 天內回覆