Skip to content

Commit aab346d

Browse files
committed
update docs
1 parent fe03054 commit aab346d

File tree

1 file changed

+12
-1
lines changed
  • docs/backend/reference

1 file changed

+12
-1
lines changed

docs/backend/reference/pk.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@ ID 作为主键的默认声明方式=={.note}
5353

5454
- 使用雪花 ID 时,需确保时钟同步(如通过 NTP)和节点 ID 的唯一性分配
5555
- 传统自增 ID 在数据迁移或合并时需特别注意冲突问题
56-
- 选择时需权衡业务规模、性能需求、开发复杂度和未来扩展性
56+
- ==前端渲染长整数偏移=={.danger}
57+
58+
当后端 api 返回长整数时,返回结果是没有问题的,但是通过前端组件渲染为 table 等数据之后,可能导致长整数渲染错误。
59+
60+
通过控制台可以发现,数据 id 与返回数据不一致,最佳解决方法是:后端将长整数序列化为字符串之后再返回,例如:
61+
62+
```python
63+
# 在所有定义返回数据的 schema 中添加字段序列化器
64+
@field_serializer("id")
65+
def serialize_id(self, value) -> str:
66+
return str(value)
67+
```
5768

5869

5970

0 commit comments

Comments
 (0)