Sequelize(PostgreSQL)bulkCreate返回不正确的值

时间:2019-07-19 14:19:49

标签: node.js sequelize.js

数据库:postgres 11.4,续集:5.10.1

我有一个字段[eva:alarm] foo.c:33: Warning: out of bounds read. assert \valid_read(tmp); (tmp from *ptr++) ,如果为空,则之前的触发器会自动填充。 方法code按预期工作,并返回带有自动设置字段create()的条目。

code

bulkCreate()返回一个代码,该代码具有我们发送到服务器的值(代码= null),而不是实际上已插入到表中的事实。

const response = await models.Cartridge.create(
    { quantity, active, code: null },
    { returning: true }
  );

  // dataValues: {id: 5, quantity: 500, active: true, code: "090217205", updatedAt: Fri Jul 19 2019 16:35:59 GMT+0300 (Eastern European Summer Time), …}

型号:

const response = await models.Cartridge.bulkCreate(
    [{ quantity, active, code: null }],
    { returning: true }
  );

  // [ { dataValues: {id: 7, code: null, quantity: 500, active: true, createdAt: Fri Jul 19 2019 16:48:27 GMT+0300 (Eastern European Summer T }]

迁移:

module.exports = (sequelize, DataTypes) => {
  const Cartridge = sequelize.define('Cartridge', {
    code: DataTypes.STRING,
    quantity: DataTypes.INTEGER,
    balance: DataTypes.INTEGER,
    active: DataTypes.BOOLEAN,
    lastActive: DataTypes.DATE,
    lastDevice: DataTypes.STRING
  }, {});

  return Cartridge;
};

谢谢。

0 个答案:

没有答案