Skip to content

Commit

Permalink
fix(core): Improved CockroachDB compatibility for DefaultSearchPlugin
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Jul 27, 2023
1 parent f6881bf commit b8d8dec
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ export class PostgresSearchStrategy implements SearchStrategy {
new Brackets(qb1 => {
for (const id of facetValueIds) {
const placeholder = createPlaceholderFromId(id);
const clause = `:${placeholder} = ANY (string_to_array(si.facetValueIds, ','))`;
const clause = `:${placeholder}::varchar = ANY (string_to_array(si.facetValueIds, ','))`;
const params = { [placeholder]: id };
if (facetValueOperator === LogicalOperator.AND) {
qb1.andWhere(clause, params);
Expand All @@ -218,14 +218,14 @@ export class PostgresSearchStrategy implements SearchStrategy {
}
if (facetValueFilter.and) {
const placeholder = createPlaceholderFromId(facetValueFilter.and);
const clause = `:${placeholder} = ANY (string_to_array(si.facetValueIds, ','))`;
const clause = `:${placeholder}::varchar = ANY (string_to_array(si.facetValueIds, ','))`;
const params = { [placeholder]: facetValueFilter.and };
qb2.where(clause, params);
}
if (facetValueFilter.or?.length) {
for (const id of facetValueFilter.or) {
const placeholder = createPlaceholderFromId(id);
const clause = `:${placeholder} = ANY (string_to_array(si.facetValueIds, ','))`;
const clause = `:${placeholder}::varchar = ANY (string_to_array(si.facetValueIds, ','))`;
const params = { [placeholder]: id };
qb2.orWhere(clause, params);
}
Expand All @@ -237,10 +237,12 @@ export class PostgresSearchStrategy implements SearchStrategy {
);
}
if (collectionId) {
qb.andWhere(":collectionId = ANY (string_to_array(si.collectionIds, ','))", { collectionId });
qb.andWhere(":collectionId::varchar = ANY (string_to_array(si.collectionIds, ','))", {
collectionId,
});
}
if (collectionSlug) {
qb.andWhere(":collectionSlug = ANY (string_to_array(si.collectionSlugs, ','))", {
qb.andWhere(":collectionSlug::varchar = ANY (string_to_array(si.collectionSlugs, ','))", {
collectionSlug,
});
}
Expand Down

0 comments on commit b8d8dec

Please sign in to comment.