环回2.0(mySql)db字段长度转换工作不正常

环回2.0(mySql)db字段长度转换工作不正常,mysql,strongloop,Mysql,Strongloop,使用datasource.createModelschema_v1.name、schema_v1.properties、schema_v1.options时…-方法,则环回在数据库中创建具有指定字段datalength的相应模型 但在检索创建的模型时,字段datalength完全不同,尽管在数据库中是正确的 例如: var schema_v1 = { "name": "CustomerTest", "options": { "idInjection": false, "m

使用datasource.createModelschema_v1.name、schema_v1.properties、schema_v1.options时…-方法,则环回在数据库中创建具有指定字段datalength的相应模型

但在检索创建的模型时,字段datalength完全不同,尽管在数据库中是正确的

例如:

var schema_v1 =
{
  "name": "CustomerTest",
  "options": {
    "idInjection": false,
    "mysql": {
      "schema": "LOOPBACK",
      "table": "CUSTOMER_TEST"
    }
  },
  "properties": {
    "id": {
      "type": "String",
      "length": 20,
      "id": 1
    },
    "email": {
      "type": "String",
      "required": false,
      "length": 150      
    }
  }
};
创建模型并检索其属性后,属性的datalength肯定是错误的

datasource.createModel(schema_v1.name, schema_v1.properties, schema_v1.options);
datasource.automigrate(function () {
  datasource.discoverModelProperties('CUSTOMER_TEST', function (err, props) {
    if (err) {
      console.log(err);
    }
    console.log(props);
  });
});
输出:使用datalength 150创建。。。检索的数据长度为450

 {   
    owner: 'aloop',
    tableName: 'customer_test',
    columnName: 'email',
    dataType: 'varchar',
    dataLength: 450,
    dataPrecision: null,
    dataScale: null,
    nullable: 'YES',
    type: 'String'
 }
这是环回mySql连接器中的一个Bug吗?有什么想法吗?先谢谢你

更新日期:2014年9月25日@Raymond

我按照您的建议设置了DEBUG=…-属性,并使用slc run运行了节点应用程序

输出结果如下:

supervisor running without clustering (unsupervised)
  loopback:connector:mysql Settings: {"host":"127.0.0.1","port":3306,"database":"strongloop","username":"root","password":"","name":"mySql","connector":"mysql","debug":false,"collation":"utf8_general_ci","charset":"utf8","supportBigNumbers":false,"timezone":"local"
} +0ms
  loopback:connector:mysql Settings: {"connector":{},"host":"127.0.0.1","port":3306,"database":"janushkaloop","username":"root","password":"","name":"mySql3","debug":false,"collation":"utf8_general_ci","charset":"utf8","supportBigNumbers":false,"timezone":"local"}
+1s
  loopback:connector:mysql SQL: DROP TABLE IF EXISTS `CUSTOMER_TEST` +3ms
Browse your REST API at http://localhost:3000/explorer
Web server listening at: http://localhost:3000/
  loopback:connector:mysql Data:  +87ms { fieldCount: 0,
  affectedRows: 0,
  insertId: 0,
  serverStatus: 2,
  warningCount: 0,
  message: '',
  protocol41: true,
  changedRows: 0 }
  loopback:connector:mysql SQL: CREATE TABLE `CUSTOMER_TEST` (
  `id` VARCHAR(20) NOT NULL PRIMARY KEY,
  `name` VARCHAR(40) NULL,
  `AMAIL` VARCHAR(150) NULL,
  `age` INT(11) NULL
) +4ms
  loopback:connector:mysql Data:  +49ms { fieldCount: 0,
  affectedRows: 0,
  insertId: 0,
  serverStatus: 2,
  warningCount: 0,
  message: '',
  protocol41: true,
  changedRows: 0 }
  loopback:connector:mysql SQL: SELECT table_schema AS "owner", table_name AS "tableName", column_name AS "columnName", data_type AS "dataType", character_octet_length AS "dataLength", numeric_precision AS "dataPrecision", numeric_scale AS "dataScale", is_nullable
AS "nullable" FROM information_schema.columns WHERE table_schema='JANUSHKALOOP' AND table_name='CUSTOMER_TEST' +1ms
  loopback:connector:mysql Data:  +52ms [ { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'id',
    dataType: 'varchar',
    dataLength: 60,
    dataPrecision: null,
    dataScale: null,
    nullable: 'NO' },
  { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'name',
    dataType: 'varchar',
    dataLength: 120,
    dataPrecision: null,
    dataScale: null,
    nullable: 'YES' },
  { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'AMAIL',
    dataType: 'varchar',
    dataLength: 450,
    dataPrecision: null,
    dataScale: null,
    nullable: 'YES' },
  { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'age',
    dataType: 'int',
    dataLength: null,
    dataPrecision: 10,
    dataScale: 0,
    nullable: 'YES' } ]
[ { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'id',
    dataType: 'varchar',
    dataLength: 60,
    dataPrecision: null,
    dataScale: null,
    nullable: 'NO',
    type: 'String' },
  { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'name',
    dataType: 'varchar',
    dataLength: 120,
    dataPrecision: null,
    dataScale: null,
    nullable: 'YES',
    type: 'String' },
  { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'AMAIL',
    dataType: 'varchar',
    dataLength: 450,
    dataPrecision: null,
    dataScale: null,
    nullable: 'YES',
    type: 'String' },
  { owner: 'janushkaloop',
    tableName: 'customer_test',
    columnName: 'age',
    dataType: 'int',
    dataLength: null,
    dataPrecision: 10,
    dataScale: 0,
    nullable: 'YES',
    type: 'Number' } ]

您能否使用DEBUG=loopback:connector:mysql节点应用程序重新运行代码,以查看生成了哪些SQL语句?您好,雷蒙德,非常感谢您的评论!我应该在哪里添加可选命令?你的意思是slc run DEBUG=loopback:connector:mysql。。。这样不行。事先谢谢。马克,格式是$DEBUG=[,…]slc run