Repository navigation
Conversation
Code Review by Qodo🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)
Great, no issues found!Qodo reviewed your code and found no material issues that require review
Previous review resultsReview updated until commit a887a6e Results up to commit c7740ea
Great, no issues found!Qodo reviewed your code and found no material issues that require reviewResults up to commit 99baad6
Great, no issues found!Qodo reviewed your code and found no material issues that require review |
commit: |
Cprakhar
approved these changes
Jul 17, 2026
xianjianlf2
force-pushed
the
fix/insert-orupdate-raw-table-metadata-11549
branch
from
July 22, 2026 02:59
99baad6 to
c7740ea
Compare
Contributor
Author
|
Rebased this branch onto the latest Local checks:
Note: I kept the unrelated untracked local |
… tables When building an INSERT ... ON CONFLICT DO UPDATE SET query for a raw table name passed to .into() (no entity metadata), createInsertExpression unconditionally read mainAlias.metadata.columns to append UpdateDateColumn "= DEFAULT" clauses, throwing "Cannot get entity metadata for the given alias". A raw table has no UpdateDateColumns, so guard the access with hasMetadata, matching the surrounding metadata-dependent branches. Closes typeorm#11549
xianjianlf2
force-pushed
the
fix/insert-orupdate-raw-table-metadata-11549
branch
from
July 22, 2026 09:50
c7740ea to
a887a6e
Compare
Contributor
Author
|
Rebased this PR onto current Local verification after the rebase:
|
alumni
approved these changes
Jul 22, 2026
gioboa
approved these changes
Jul 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #11549. Building an upsert against a raw table name throws before the query can be generated:
In
InsertQueryBuilder.createInsertExpression(), after assembling theON CONFLICT ... DO UPDATE SETcolumns, the code unconditionally readthis.expressionMap.mainAlias!.metadata.columnsto appendUpdateDateColumn = DEFAULTentries. A raw table has no entity metadata, soAlias.metadata's getter throws. Every other metadata access in this method (the SQLite JSON branch, the MSSQL IDENTITY_INSERT branch,getInsertedColumns) is already guarded byhasMetadata; this was the lone unguarded read.Fix
Wrap the update-date-column block in
if (this.expressionMap.mainAlias!.hasMetadata) { … }, matching the method's established guard pattern. A raw table has noUpdateDateColumn, so there is nothing to append.Tests
Added a DB-free test to
test/functional/query-builder/insert-on-conflict/(per the compliance checklist, with the issue reference in a comment) that builds the raw-table upsert and assertsgetSql()containsON CONFLICT ( "id" ) DO UPDATE SET "name" = EXCLUDED."name". Runs on the in-memory better-sqlite3 harness (sameon-conflict-do-updatepath as Postgres). Verified break→red (Cannot get entity metadata … InsertQueryBuilder.ts) → restore→green; on-conflict describe 8/8 passing.Closes #11549