Przeglądaj źródła

fix(core): Make facetValueCollectionFilter safe with uuids

Michael Bromley 4 lat temu
rodzic
commit
a3fef0f89b

+ 4 - 2
packages/core/src/config/catalog/default-collection-filters.ts

@@ -26,8 +26,10 @@ export const facetValueCollectionFilter = new CollectionFilter({
         const ids = args.facetValueIds;
 
         if (ids.length) {
-            const idsName = `ids_${ids.join('_')}`;
-            const countName = `count_${ids.join('_')}`;
+            // uuid IDs can include `-` chars, which we cannot use in a TypeORM key name.
+            const safeIdsConcat = ids.join('_').replace(/-/g, '_');
+            const idsName = `ids_${safeIdsConcat}`;
+            const countName = `count_${safeIdsConcat}`;
             const productFacetValues = qb.connection
                 .createQueryBuilder(ProductVariant, 'product_variant')
                 .select('product_variant.id', 'variant_id')

+ 1 - 1
packages/elasticsearch-plugin/e2e/elasticsearch-plugin-uuid.e2e-spec.ts

@@ -27,7 +27,7 @@ describe('Elasticsearch plugin with UuidIdStrategy', () => {
     const { server, adminClient, shopClient } = createTestEnvironment(
         mergeConfig(testConfig(), {
             entityOptions: { entityIdStrategy: new UuidIdStrategy() },
-            logger: new DefaultLogger({ level: LogLevel.Info }),
+            // logger: new DefaultLogger({ level: LogLevel.Info }),
             plugins: [
                 ElasticsearchPlugin.init({
                     indexPrefix: 'e2e-uuid-tests',