Skip to content

ValueTransformers are not applied when column is queried for relationships (@ManyToOne, @ManyToMany, @JoinTable) #10365

Open

Description

@leonceaklin

Issue description

TypeORM doesn't transform values when querying a column for relationships

Expected Behavior

When a column has one or multiple transformers defined in an entity, TypeORM always transforms any values when querying the field. This should also be the case whenever a field is queried for relationships.

Actual Behavior

TypeORM omits transforming values for a column with a transformer when it's queried for determining relationships (OneToMany, ManyToMany…).

Steps to reproduce

  1. Create an entity A in TypeORM that has a @PrimaryColumn with a transformer
  2. Create a second entity B that has a @manytoone relationship to the first entity
  3. Enable logging for TypeORM
  4. Query a doc of entity B that has a relationship with A, in the log, you can see that the field is not transformed

My Environment

Dependency Version
Operating System macOS 13.4.1
Node.js version 18.12.1
Typescript version 4.3.5
TypeORM version 0.3.17

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. leonceaklin commented on Sep 17, 2023

    @leonceaklin
    Author

    I'd like to solve this problem by adding ApplyValueTransformers to the necessary places. Would somebody like to show me how to start?

  2. leonceaklin commented on Oct 19, 2023

    @leonceaklin
    Author

    Does somebody of the maintainers have the time to help me implement this bugfix? I don't know where to start…

  3. cs-pablorb commented on Mar 6, 2024

    @cs-pablorb

    We have the same issue. Where both sides of the m2m have a transformer and the save method triggers an error forcing of null value for the id.

  4. cs-pablorb commented on Mar 11, 2024

    @cs-pablorb

    I've been banging my head against the code, trying to figure out where the transformation went MIA. Seriously, it's like a maze of layers, and I'm starting to think the only way out is to ditch the whole entities and go for schemas with manual transformation. Or, you know, I'm tempted to pull the plug on TypeORM altogether.

  5. github-actions commented on Sep 18, 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.

  6. Frederick888 commented on Sep 18, 2025

    @Frederick888

    Please reopen. Thank you.

  7. reopened this on Sep 18, 2025
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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions