Skip to content

Commit

Permalink
fix: wrapped where param in db query (VirtusLab-Open-Source#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
ltsNotMike authored Jul 27, 2022
1 parent 0bb17db commit bd652c3
Show file tree
Hide file tree
Showing 5 changed files with 466 additions and 845 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
environment:
CODECOV_TOKEN: 02e2d4e8-88c4-4e5d-99da-a9a2888634c6
docker:
- image: circleci/node:14.17.3
- image: cimg/node:14.19.3
working_directory: ~/repo
steps:
- checkout
Expand Down
2 changes: 1 addition & 1 deletion server/services/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export = ({ strapi }: StrapiContext): IServiceClient => ({

const relatedEntity = await strapi.db
.query<RelatedEntity>(uid)
.findOne(relatedId);
.findOne({ where: { id: relatedId } });
if (!relatedEntity) {
throw new PluginError(
400,
Expand Down
4 changes: 2 additions & 2 deletions server/services/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
import {
CommentsPluginConfig,
FindAllFlatProps,
FindAllInHierarhyProps,
FindAllInHierarchyProps,
IServiceCommon,
ToBeFixed,
Comment,
Expand Down Expand Up @@ -287,7 +287,7 @@ export = ({ strapi }: StrapiContext): IServiceCommon => ({
fields,
startingFromId = null,
dropBlockedThreads = false,
}: FindAllInHierarhyProps,
}: FindAllInHierarchyProps,
relatedEntity?: RelatedEntity | null | boolean
): Promise<Array<Comment>> {
const entities = await this.findAllFlat(
Expand Down
8 changes: 5 additions & 3 deletions types/services.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import {
StrapiRequestQueryFieldsClause,
PopulateClause,
StrapiDBBulkActionResponse,
StrapiAdminUser,
WhereClause,
} from "strapi-typed";
import { ToBeFixed } from "./common";
import {
Expand Down Expand Up @@ -42,7 +44,7 @@ export type FindAllFlatProps<T, TFields = keyof T> = {
pagination?: StrapiPagination;
};

export type FindAllInHierarhyProps = Omit<FindAllFlatProps, "pagination"> & {
export type FindAllInHierarchyProps = Omit<FindAllFlatProps, "pagination"> & {
startingFromId?: Id | null;
dropBlockedThreads?: boolean;
isAdmin?: boolean;
Expand Down Expand Up @@ -80,10 +82,10 @@ export interface IServiceCommon {
relatedEntity?: RelatedEntity | null | boolean
): Promise<StrapiPaginatedResponse<Comment>>;
findAllInHierarchy(
props: FindAllInHierarhyProps,
props: FindAllInHierarchyProps,
relatedEntity?: RelatedEntity | null | boolean
): Promise<Array<Comment>>;
findOne(criteria: KeyValueSet<any>): Promise<Comment>;
findOne(criteria: WhereClause): Promise<Comment>;
findRelatedEntitiesFor(entities: Array<Comment>): Promise<RelatedEntity[]>;
mergeRelatedEntityTo(
entity: ToBeFixed,
Expand Down
Loading

0 comments on commit bd652c3

Please sign in to comment.