From 32dd377c3e77a1c7927f309955105f406afb7a3c Mon Sep 17 00:00:00 2001 From: Christopher Kolstad Date: Fri, 26 Jan 2024 10:44:53 +0100 Subject: [PATCH] fix: Use knex whereLike instead of whereRaw to fix escaping (#6041) This escape with `??` double escaped the LIKE query causing no results. This updates to using whereLike, which does the correct escaping for string query. --- src/lib/db/client-instance-store.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/db/client-instance-store.ts b/src/lib/db/client-instance-store.ts index ccdcf388d8..f0f75f5821 100644 --- a/src/lib/db/client-instance-store.ts +++ b/src/lib/db/client-instance-store.ts @@ -167,10 +167,11 @@ export default class ClientInstanceStore implements IClientInstanceStore { } async getBySdkName(sdkName: string): Promise { + const sdkPrefix = `${sdkName}%`; const rows = await this.db .select() .from(TABLE) - .whereRaw(`sdk_version LIKE '??%'`, [sdkName]) + .whereLike('sdk_version', sdkPrefix) .orderBy('last_seen', 'desc'); return rows.map(mapRow); }