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
{{ message }}
Repository navigation
Raw operator does not properly escape nested columns #6264
[ ] latest
[ ] @next
[x] 11.5 (or put your version here)
Steps to reproduce or a small repository showing the problem:
Currently Raw operator is broken when using joins. columnPath that is passed in callback has a value of "SomeTable.someColumn" which resolved with an error missing from-clause entry for table when executing a query.
Example:
// This is brokenrepo.findOne({where: {field: Raw(columnPath=>`${columnPath} = "somevalue"`)},relation: ['someOtherTable']})// This worksfunctionwrapColumnPath(columnPath: string): string{returncolumnPath.split('.').map(c=>`"${c}"`).join('.')}repo.findOne({where: {field: Raw(columnPath=>`${wrapColumnPath(columnPath)} = "somevalue"`)},relation: ['someOtherTable']})
As mentioned in this issue we should have some sort of SafeRaw to handle this kind of issues.
Reacted by Vitalii Markov, Mykyta Sikriier, Roman Riabokon, Mykola Kreshchenko and Michał Wadas
The issue isn't that it isn't escaped - the issue is that the replacement that happens later on in the query building process doesn't replace it with the escaped value.
Activity
[-]Raw operator is broken[/-][+]Raw operator does not properly escape nested columns[/+]imnotjames commentedon Jun 27, 2021
The issue isn't that it isn't escaped - the issue is that the replacement that happens later on in the query building process doesn't replace it with the escaped value.