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

typeorm decimal value of column repeatedly generating migration ? #6140

Closed
dhiraj-ppp opened this issue May 27, 2020 · 3 comments · Fixed by #6879
Closed

typeorm decimal value of column repeatedly generating migration ? #6140

dhiraj-ppp opened this issue May 27, 2020 · 3 comments · Fixed by #6879

Comments

@dhiraj-ppp
Copy link

Issue type:

[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[x] mysql / mariadb
[ ] oracle
[ ] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

import {Entity, PrimaryGeneratedColumn, Column} from "typeorm";

@Entity()
export class User {

    @PrimaryGeneratedColumn()
    id: number;

    @Column()
    firstName: string;

    @Column()
    lastName: string;

    @Column()
    age: number;

    @Column()
    city: number;

    @Column({ type: 'decimal', precision: 22, scale: 2,default: 0.00 })
    bday: number;

}

Migration

import {MigrationInterface, QueryRunner} from "typeorm";

export class Adddecl1590562535409 implements MigrationInterface {
    name = 'Adddecl1590562535409'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query("ALTER TABLE `user` CHANGE `bday` `bday` decimal(22,2) NOT NULL DEFAULT 0");
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query("ALTER TABLE `user` CHANGE `bday` `bday` decimal(22,2) NOT NULL DEFAULT '0.00'");
    }

}

I continually getting migrations generated even after running them. I am not making any changes in Schema.
Step:1 Generate a migration
Step :2 Run a migration
Step :3 Generate a migration

As per step 3 migration should not be generated because i have already ran the migration and made no changes in DB scheme since i ran migration.

Note:
If i don't set the default value in schema then i don't get any migration generated on step 3.

jeiea added a commit to jeiea/typeorm that referenced this issue Oct 9, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 9, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 10, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 10, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 11, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 11, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 11, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
jeiea added a commit to jeiea/typeorm that referenced this issue Oct 11, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
imnotjames pushed a commit that referenced this issue Oct 11, 2020
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close #6140
Close #5407
zaro pushed a commit to zaro/typeorm that referenced this issue Jan 12, 2021
MySQL/MariaDB decimal column is represented like '0.0'.
MysqlDriver.normalizeDefault didn't consider trailing zeros.
User can bypass this by passing default as string, but we
can't guide the zeros by type, so we should convert user input.

undefined scale was compared with defined scale. Skip this comparison.

Close typeorm#6140
Close typeorm#5407
@maratumba
Copy link

This exact issue is seen on Postgres today on typeORM 0.3.20

@AdilSarwarNU
Copy link

can confirm this happening in a project of ours. using 'decimal' type - Any fixes on this?

@codewithalihamza
Copy link

Anyone Please tell me about the solution to this bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants