Skip to content

bigNumberStrings: false option isn't work properly with relationship. #11226

Closed as not planned

Description

@changchanghwang

Issue description

The bigNumberStrings: false option triggers child entity's orphanedRowAction even when there are no changes

Expected Behavior

when save a with no change in bs, just update a. not any mutation query for b

 UPDATE `a` SET `name` = ? WHERE `id` IN (?) -- PARAMETERS: ["test2",2]

Actual Behavior

typeORM delete bs by orphanedRowAction

image

Steps to reproduce

import "reflect-metadata";
import {
  Column,
  DataSource,
  Entity,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
} from "typeorm";
import * as express from "express";

@Entity()
class A {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column({ type: "varchar", length: 255 })
  name!: string;

  @OneToMany(() => B, (b) => b.a, { cascade: true, eager: true })
  bs!: B[];

  constructor(args?: { name: string }) {
    if (args) {
      this.name = args.name;
      this.bs = Array.from({ length: 5 }, (_, i) => new B({ value: i }));
    }
  }
}

@Entity()
class B {
  @PrimaryGeneratedColumn({ unsigned: true, type: "bigint" })
  id!: number;

  @Column({ type: "int" })
  value!: number;

  @ManyToOne(() => A, (a) => a.bs, { orphanedRowAction: "delete" })
  a!: never;

  constructor(args?: { value: number }) {
    if (args) {
      this.value = args.value;
    }
  }
}

async function initDB() {
  const connection = new DataSource({
    type: "mysql",
    host: "localhost",
    port: 3306,
    username: "root",
    password: "1234",
    database: "test",
    bigNumberStrings: false,
    synchronize: true,
    logging: true,
    entities: [A, B],
  });

  await connection.initialize();

  return connection;
}

(async () => {
  const app = express();

  const db = await initDB();

  app.get("/save", async (_, res) => {
    const a = new A({ name: "test" });

    await db.manager.save(a);

    res.send("pong");
  });

  app.get("/update", async (_, res) => {
    const [a] = await db.manager.find(A, {
      where: {
        name: "test",
      },
    });

    a.name = "test2";

    await db.manager.save([a]);

    res.send(a);
  });

  app.listen(3333, () => {
    console.log("Server is running on port 3333");
  });
})();

My Environment

Dependency Version
Operating System
Node.js version 20.17.0
Typescript version 5.7.2
TypeORM version 0.3.20

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

Yes, I have the time, but I don't know how to start. I would need guidance.

Activity

  1. changed the title [-]`bigNumberStrings: false` trigger `orphanedRowAction` with using cascade[/-] [+]`bigNumberStrings` false option isn't work properly with relationship.[/+] on Jan 7, 2025
  2. changed the title [-]`bigNumberStrings` false option isn't work properly with relationship.[/-] [+]`bigNumberStrings: false` option isn't work properly with relationship.[/+] on Jan 7, 2025
  3. changchanghwang commented on Feb 27, 2025

    @changchanghwang
    Author

    is there any update?

  4. github-actions commented on Sep 17, 2025

    @github-actions

    TypeORM has returned to active development after recently transitioning to new leadership (see related announcement).

    As part of the new team's efforts to prioritise work on the project moving forward, it is necessary to clean up the backlog of stale issues.

    🧹 This issue is being automatically closed because it has had no activity in the last 6 months.
    If you believe this issue is still relevant, feel free to comment below and the maintainers may reopen it. Thank you for your contribution.

  5. added this to the 1.0 milestone on Mar 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions