Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected default for generated entity #1917

Closed
ltudisco opened this issue Jun 10, 2021 · 0 comments
Closed

Unexpected default for generated entity #1917

ltudisco opened this issue Jun 10, 2021 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ltudisco
Copy link

Describe the bug

Unexpected default for generated entity with boolean property

To Reproduce

Steps to reproduce the behavior:

  1. Create the following table in a mysql database
CREATE TABLE `test_table` (
  `test_column` tinyint(1) not null default 0
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Screenshot 2021-06-10 at 17 05 33

  1. Run the following script to autogenerate entities based on the database above

ts-node generateEntities.ts

import { MikroORM } from '@mikro-orm/core';


(async () => {
  const orm = await MikroORM.init({
    discovery: {
      // we need to disable validation for no entities 
      warnWhenNoEntities: false,
    },
    dbName: dbName
    ....
  });
  const generator = orm.getEntityGenerator();
  const dump = await generator.generate({
    save: true,
    baseDir: process.cwd() + '/my-entities',
  });
  console.log(dump);
  await orm.close(true);
})();

Expected behavior

I would expect the generated entity to have a boolean property defaulting to False but the property is actually defaulting to True.

This is the actual autogenerated entity

import { Entity, Property } from '@mikro-orm/core';

@Entity()
export class TestTable {

  @Property()
  testColumn: boolean = true;

}
@B4nan B4nan added the bug Something isn't working label Jun 19, 2021
@B4nan B4nan closed this as completed in 908a638 Jun 19, 2021
B4nan added a commit that referenced this issue Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants