loopbackio / loopbackio/loopback-datasource-juggler
[BUG] create helper function ignores the id property when it's equal to 0.
まだ誰も着手していません。
- 主要言語
- JavaScript
- スター
- 282
- フォーク
- 366
- 平均マージ
- 17時間 4分
- マージ済み PR(30日)
- 10
説明
**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"
}
```
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
dao.js の 378 行目付近にある createCallback 関数から始め、callback id が作成されたオブジェクトにどのように割り当てられるかを追跡します。id が 0 の create 呼び出しを再現し、その後、期待されるレスポンスのカバレッジを追加して、0 以上の id が保持されることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- javascript
- 領域
- databases
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100