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

Nullable BigInt column is trying to save NULL as string #631

Closed
pepakriz opened this issue Jul 1, 2020 · 2 comments
Closed

Nullable BigInt column is trying to save NULL as string #631

pepakriz opened this issue Jul 1, 2020 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@pepakriz
Copy link
Contributor

pepakriz commented Jul 1, 2020

When I have an entity with nullable bigint and I'm trying to save null value, it tries to convert null to string.

To Reproduce

@Entity()
export class AppVersion {

    @PrimaryKey()
    public id: number = null;

    @Property({ type: BigIntType, nullable: true })
    public disabledSince: number | null = null;

}

const appVersion = new AppVersion();
await em.persistAndFlush(appVersion);

It can be fixed by changing methods in the BigIntType.ts like this:

  convertToDatabaseValue(value: any, platform: Platform): any {
    if (!value) {
      return value;
    }

    return '' + value;
  }

  convertToJSValue(value: any, platform: Platform): any {
    if (!value) {
      return value;
    }

    return '' + value;
  }

Is it a good solution?

@pepakriz pepakriz added the bug Something isn't working label Jul 1, 2020
@B4nan
Copy link
Member

B4nan commented Jul 1, 2020

Yeah agreed

B4nan added a commit that referenced this issue Jul 7, 2020
@B4nan
Copy link
Member

B4nan commented Jul 7, 2020

Closing as fixed in v4 via 2e0ef58

@B4nan B4nan closed this as completed Jul 7, 2020
B4nan added a commit that referenced this issue Jul 7, 2020
B4nan added a commit that referenced this issue Aug 2, 2020
B4nan added a commit that referenced this issue Aug 9, 2020
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