Incremental migration does not configure existing PK column to enable auto-generated values
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 45/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript, node.js, postgresql
研究方向
使用連結的 postgres-pk-auto-gen 分支及其兩個提交,在 loopback-next todo 應用程式中重現此問題。在啟用 generated: true 前後執行 npm migrate,然後確認建立不含 ID 的 todo 是否成功,以及 ID 是否會自動產生。
由索引模型根據 Issue 內容生成。
描述
Description/Steps to reproduce
From my testing using LoopBack 4 and this connector, the migration performed by npm run migrate does not configure the id (primary key) column to be auto-generated when generated: true is enabled on the property.
Link to reproduction sandbox
I've set up a branch on my loopback-next fork with a recreate. The branch is here:
https://github.com/aharbis/loopback-next/tree/postgres-pk-auto-gen
The recreate uses the todo application. There are two commits on the branch:
https://github.com/aharbis/loopback-next/commit/cdee3cb60305a02e5e1e5a49069e043079615289 - Adds the Postgres data source
https://github.com/aharbis/loopback-next/commit/43368cc4687521f06a79102b6484494cda6e27be - Sets generated: true on todo model
Steps to recreate
- Checkout first commit (that adds the datasource)
- Install dependencies (
npm i) - Run migration (
npm run migrate) - Start app (
npm start) - Try to create todo with ID, to confirm this works
- Stop app
- Checkout second commit (that sets
generated: true) - Run migration (
npm run migrate) - Start app (
npm start) - Try to create todo without ID
Expected result
In step 10, this create should succeed and the ID should be auto-generated.
Actual result
In step 10, this create yields a 500 error:
Unhandled error in POST /todos: 500 error: null value in column "id" violates not-null constraint
at Connection.parseE (/Users/aharbis/git/loopback-next/examples/todo/node_modules/pg/lib/connection.js:602:11)
at Connection.parseMessage (/Users/aharbis/git/loopback-next/examples/todo/node_modules/pg/lib/connection.js:399:19)
at Socket.<anonymous> (/Users/aharbis/git/loopback-next/examples/todo/node_modules/pg/lib/connection.js:121:22)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:601:20)
Additional information
$ node -e 'console.log(process.platform, process.arch, process.versions.node)'
darwin x64 8.12.0
$ npm ls --prod --depth 0 | grep loopback
@loopback/[email protected] /Users/aharbis/git/loopback-next/examples/todo
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── @loopback/[email protected]
├── [email protected]
└── [email protected]
$ psql --version
psql (PostgreSQL) 10.5
- 主要語言
- JavaScript
- 星號
- 118
- 分支
- 182
- 平均合併
- 5 天 4 小時
- 30 天內合併 PR
- 7
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
loopbackio/loopback-connector-postgresql 的其他 Issue
-
Partial JSON Update可能已有人在做 @vaibhavbhalla2505 於 279 天前認領。 未關閉feature
難度 5/5 一週以上 新手友好度 20/100
-
bug
難度 4/5 3-5 天 新手友好度 30/100
loopbackio/loopback-connector-postgresql#748 · 1 則留言 ·
-
bug
難度 3/5 1-2 天 新手友好度 38/100
-
bug
難度 4/5 3-5 天 新手友好度 25/100
-
bug
難度 2/5 1-3 小時 新手友好度 45/100
loopbackio/loopback-connector-postgresql#732 · 1 則留言 ·
查看 loopbackio/loopback-connector-postgresql 的全部 Issue
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 85/100
521xueweihan/HelloGitHub#4115 ·
-
bug
難度 2/5 1-3 小時 新手友好度 68/100
outline/outline#14348 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
維護者通常 1 天內回覆
-
area:install bug needs-triage
難度 2/5 1-3 小時 新手友好度 68/100
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 75/100
維護者通常 1 天內回覆