@@ -37,8 +37,9 @@ const resolveUserCompanyPart = async ({
3737 const company = await con
3838 . getRepository ( Company )
3939 . createQueryBuilder ( )
40+ . setParameter ( 'companyName' , name )
4041 . addSelect ( 'id' )
41- . addSelect ( `similarity(name, ' ${ name } ' )` , 'similarity' )
42+ . addSelect ( `similarity(name, :companyName )` , 'similarity' )
4243 . orderBy ( 'similarity' , 'DESC' )
4344 . getRawOne < Pick < Company , 'id' > & { similarity : number } > ( ) ;
4445
@@ -76,26 +77,32 @@ const resolveUserLocationPart = async ({
7677 . addSelect ( 'id' ) ;
7778
7879 if ( location . city ) {
79- datasetLocationQb . addSelect (
80- `coalesce(similarity(city, '${ location . city } '), 0)` ,
81- 'similarityCity' ,
82- ) ;
80+ datasetLocationQb
81+ . setParameter ( 'locationCity' , location . city )
82+ . addSelect (
83+ `coalesce(similarity(city, :locationCity), 0)` ,
84+ 'similarityCity' ,
85+ ) ;
8386 datasetLocationQb . addOrderBy ( '"similarityCity"' , 'DESC' ) ;
8487 }
8588
8689 if ( location . subdivision ) {
87- datasetLocationQb . addSelect (
88- `coalesce(similarity(subdivision, '${ location . subdivision } '), 0)` ,
89- 'similaritySubdivision' ,
90- ) ;
90+ datasetLocationQb
91+ . setParameter ( 'locationSubdivision' , location . subdivision )
92+ . addSelect (
93+ `coalesce(similarity(subdivision, :locationSubdivision), 0)` ,
94+ 'similaritySubdivision' ,
95+ ) ;
9196 datasetLocationQb . addOrderBy ( '"similaritySubdivision"' , 'DESC' ) ;
9297 }
9398
9499 if ( location . country ) {
95- datasetLocationQb . addSelect (
96- `coalesce(similarity(country, '${ location . country } '), 0)` ,
97- 'similarityCountry' ,
98- ) ;
100+ datasetLocationQb
101+ . setParameter ( 'locationCountry' , location . country )
102+ . addSelect (
103+ `coalesce(similarity(country, :locationCountry), 0)` ,
104+ 'similarityCountry' ,
105+ ) ;
99106 datasetLocationQb . addOrderBy ( '"similarityCountry"' , 'DESC' ) ;
100107 }
101108
0 commit comments