Search code examples
javascriptmysqlloopback

Loopback Mysql Connector: BIT(1) is recognized always true


I am using Loopback 3.22 with loopback-connector-mysql 5.3.1.

When i configure loopback to covert BIT(1) mysql column as boolean it always returns true

"isActive": {
  "type": "Boolean",
  "required": false,
  "length": null,
  "precision": 1,
  "scale": null,
  "mysql": {
    "columnName": "is_active",
    "dataType": "bit",
    "dataLength": null,
    "dataPrecision": 1,
    "dataScale": null,
    "nullable": "Y"
  }
},

I have wasted so much time here, I even tried to use before save hooks, but column type validation kicks in before.

Making the column type Binary pushes the problem to the frontend.


Solution

  • This is a know bug of LoopBack's MySQL connector, see the following GitHub issue: https://github.com/strongloop/loopback-connector-mysql/issues/325