sql - Postgres 整数超出范围
问题描述
value "1574799549227" is out of range for type integer
尝试插入全新数据库上的全新表时出现错误。我正在使用带有 pg 模块的节点。
db
.query(`INSERT INTO users (uuid, email, password, created_at, updated_at) VALUES ($1, $2, $3, to_timestamp($4 / 1000), to_timestamp($4 / 1000))`,
[uuid, email, password, Date.now()])
.catch((err) => {
console.log(err);
});
这是桌子
CREATE TABLE public.users
(
id serial,
uuid uuid,
email character varying,
password character varying,
created_at timestamp with time zone,
updated_at timestamp with time zone,
CONSTRAINT user_id_pk PRIMARY KEY (id)
)
我也尝试过重置 id 字段的序列号
解决方案
我最终弄清楚了。原来这是我拥有的时间戳。我在to_timestamp($4 / 1000)
应该使用的时候使用to_timestamp($4 / 1000.0)
推荐阅读
- python - 为什么创建虚拟环境后会存在 3 个 pip 模块?
- intellij-idea - IdeaVim - 如何在正常模式下使用竖线?
- objective-c - 计算目标 C 的预计到达时间和到达距离
- mysql - 如何使用 MySQL 将数据从一个服务器数据库插入到另一个服务器数据库?
- c# - 从 Project Online 获取 ProjectSiteUrl 不起作用
- angularjs - 在 ng-repeat 中附加结果,可能吗?
- java - 设置 Java 跟踪日志记录的最大文件大小
- python-3.x - 谁能告诉我哪个 dask.dataframe 在内存效率方面比 pandas 更胜一筹?
- ios - 如何从系统警报中获取本地化标题
- javascript - SAPUI5 在正确的时间分配模型