Skip to content

QueryBuilder .insert().orIgnore(true) incorrectly assigns autogenerated columns to Entities #5226

Closed as not planned

Description

@synchrone

Issue type:

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

Database system/driver:

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

TypeORM version:

[ ] latest
[ ] @next
[X] 0.2.1

Steps to reproduce or a small repository showing the problem:

When inserting into a table using QueryBuilder.insert() + orIgnore(true) - the entitiy collection gets incorrectly updated with generated columns because of missing rows in InsertResult.

Since ignored rows are skipped in InsertResult, and valueSets is still the ones the user passed in .values() - the indices get shifted, which results in the wrong entities overwritten in ReturningResultsEntityUpdator.insert()

Here is a testcase:
https://github.com/synchrone/typeorm/blob/issue-postgres-insert-orIgnore-returning-ids/test/github-issues/issue-postgres-insert-orIgnore-returning-ids/issue.ts

and a failed test run https://travis-ci.org/synchrone/typeorm/jobs/624132758

Activity

  1. IgorTurko commented on Nov 8, 2021

    @IgorTurko

    Guys do you know work around for this? Because insert().orIgnore().execute() returns empty identifiers and generatedMaps as a list of undefined.

  2. 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.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions