1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-31 00:16:47 +01:00

chore: optimize sql query to not concatenate (#5321)

This commit is contained in:
Jaanus Sellin 2023-11-13 08:42:19 +02:00 committed by GitHub
parent 7f4df19660
commit 00327c359d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -562,12 +562,20 @@ class FeatureStrategiesStore implements IFeatureStrategiesStore {
]); ]);
} }
if (hasHalfTag) { if (hasHalfTag) {
const tagParameter = normalizedHalfTag.map((tag) => `%${tag}%`); const tagParameters = normalizedHalfTag.map(
tagQuery.orWhereRaw( (tag) => `%${tag}%`,
`(?? || ':' || ??) ILIKE ANY (ARRAY[${tagParameter );
const tagQueryParameters = normalizedHalfTag
.map(() => '?') .map(() => '?')
.join(',')}])`, .join(',');
['tag_type', 'tag_value', ...tagParameter], tagQuery
.orWhereRaw(
`(??) ILIKE ANY (ARRAY[${tagQueryParameters}])`,
['tag_type', ...tagParameters],
)
.orWhereRaw(
`(??) ILIKE ANY (ARRAY[${tagQueryParameters}])`,
['tag_value', ...tagParameters],
); );
} }