You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I read through the code and can confirm the root cause. And to answer your question: yes, your propsed solution is exactly right.
The error is caused caused by an unguarded .metadata
access in the InsertQueryBuilder#createInsertExpression (the orUpdate path).
Alias.metadata is intentionally unsafe and throws when no entity metadata is present.
For raw table names, mainAlias.hasMetadata === false, so:
this.expressionMap.mainAlias.metadata.columns
throws an error.
This block attempts to appends updateDate columns to the DO UPDATE SET clause, but does not check hasMetadata,
unlike other parts of InsertQueryBuilder.
Fix:
Wrapping the block in the guard you suggested solves the issue safely:
Aligns with existing hasMetadata guards in execute() in the same file, and preserves raw table usage.
May be worth auditing other onUpdate paths for similar cases.
Happy to open a PR for this if my approach is confirmed! (:
Activity
0xkhass commentedon Apr 6, 2026
I read through the code and can confirm the root cause. And to answer your question: yes, your propsed solution is exactly right.
The error is caused caused by an unguarded
.metadataaccess in the
InsertQueryBuilder#createInsertExpression(theorUpdatepath).Alias.metadatais intentionally unsafe and throws when no entity metadata is present.For raw table names,
mainAlias.hasMetadata === false, so:throws an error.
This block attempts to appends
updateDatecolumns to theDO UPDATE SETclause, but does not checkhasMetadata,unlike other parts of
InsertQueryBuilder.Fix:
Wrapping the block in the guard you suggested solves the issue safely:
Aligns with existing
hasMetadataguards inexecute()in the same file, and preserves raw table usage.May be worth auditing other
onUpdatepaths for similar cases.Happy to open a PR for this if my approach is confirmed! (:
fix(query-builder): guard UpdateDateColumn access in orUpdate for raw…
fix(query-builder): guard UpdateDateColumn access in orUpdate for raw…