Skip to content

_warningRow is not iterable #9919

Closed

Description

@zyfmix

What you are doing?

when i config sequelize log with winston logger with config below:

// 标准日志服务组件...
let wsLogs = require(global.appRoot + '/libs/WsLogs');
let sqlLogger = wsLogs.logger('sql');

let sequelizeOptions = {
    operatorsAliases: false,
    //operatorsAliases: Op,
    // 显示 SQL 警告信息...
    showWarnings: true,
    //logging: false,
    //logging: sqlLogger.verbose,
    logging: (msg) => sqlLogger.verbose(msg),
    // disable inserting undefined values as NULL
    // - default: false
    omitNull: false,
    ...db_config[name]
};

I had set options with showWarnings: true to show sql errors,

What do you expect to happen?

when i exe a warning sql,it crashed with error: _warningRow is not iterable,and can't show any warning msg from mysql,how to work around this?
i hava exe this sql in terminal manual:

mysql> INSERT INTO `tours` (`id`,`name`,`city`,`thumb`,`phone1`,`phone2`,`body`,`detail_address`,`traffic_blue`,`traffic_self`,`privilege`,`is_recommend`,`coord_x`,`coord_y`,`tips`,`open_time`,`close_time`,`url`,`level`,`toursn`,`price`,`tey_limits`,`created_at`,`updated_at`) VALUES (10029,'测试景区[10029][F:0][R:0][YL:100][D:0]','xh','http://ekt-userface.oss-cn-shenzhen.aliyuncs.com/20180502/ea4ae9c477c9aa2e415fda6745a7d3b5.jpg','','','','','','','',0,0,0,'','13:30','22:00','http://www.mltc.cn/',0,10029,188,0,'2018-05-01 12:30:00','2018-09-13 16:01:19');
Query OK, 1 row affected, 1 warning (0.01 sec)

mysql> show warnings;
+---------+------+-------------------------------------------+
| Level   | Code | Message                                   |
+---------+------+-------------------------------------------+
| Warning | 1265 | Data truncated for column 'name' at row 1 |
+---------+------+-------------------------------------------+
1 row in set (0.01 sec)

this is because column name is too long.

What is actually happening?

my environment:
sequelize version 4.38.0;
mysql version 5.7.12;
winston version 3.1.0;

Activity

  1. sushantdhiman commented on Sep 13, 2018

    @sushantdhiman
    Contributor

    Can you show query that throws warning or reproduce this issue?

  2. zyfmix commented on Sep 13, 2018

    @zyfmix
    Author

    Can you show query that throws warning or reproduce this issue?

    i had update my issue and insert sql.

  3. sushantdhiman commented on Sep 13, 2018

    @sushantdhiman
    Contributor

    SSCCE

    'use strict';
    
    const Sequelize = require('./index');
    const sequelize = require('./test/support').createSequelizeInstance({
      showWarnings: true
    });
    
    const Model = sequelize.define('model', {
      name: Sequelize.DataTypes.STRING(10, true)
    });
    
    sequelize.sync({ force: true }).then(() => {
      return sequelize.authenticate();
    }).then(() => {
      return sequelize.query(`SET SESSION sql_mode='';`);
    }).then(() => {
      return Model.create({
        name: 'very-long-long-name'
      });
    });
  4. added
    type: bug
    dialect: mysql
    and removed on Sep 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: mysqltype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions