cyjake / leoric

👑 JavaScript ORM for MySQL, PostgreSQL, and SQLite.

Home Page:https://leoric.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

set `TINYINT` and `UNSIGNED INT` not working

luckydrq opened this issue · comments

I'm using egg-orm when encounting this problem and i think it is related with leoric.

Example:

import { Application } from 'egg';

export default (app: Application) => {
  const { STRING, INTEGER, DATE } = app.model.DataTypes;

  return app.model.define('User', {
    name: STRING,
    tinyInt: INTEGER('tiny'),
    unsignedInt: INTEGER('').UNSIGNED,
    deletedAt: DATE,
  }, {
    tableName: 'users',
  });
}

Table in database:

image

try this:

const { STRING, INTEGER, DATE, TINYINT } = app.model.DataTypes;

app.model.define('User', {
  name: STRING,
  tinyInt: TINYINT,
  unsignedInt: INTEGER.UNSIGNED,
  deletedAt: DATE,
}

try this:

const { STRING, INTEGER, DATE, TINYINT } = app.model.DataTypes;

app.model.define('User', {
  name: STRING,
  tinyInt: TINYINT,
  unsignedInt: INTEGER.UNSIGNED,
  deletedAt: DATE,
}

It seems that TINYINT not included in DataTypes. I will look into that later.

yikes! TINYINT indeed is not supported yet. I'll look into it.

btw, if the intention is use TINYINT(1) to represent boolean in MySQL, you can use BOOLEAN directly.

Got