Skip to content

Commit

Permalink
Merge pull request ToolJet#9812 from ToolJet/hotfix/tjdb-query-subpath
Browse files Browse the repository at this point in the history
Hotfix: TJDB query subpath
  • Loading branch information
akshaysasidrn authored May 22, 2024
2 parents 2e6f451 + 8a9cd79 commit 4136010
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions server/src/services/tooljet_db_operations.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { QueryService, QueryResult } from '@tooljet/plugins/dist/packages/common
import { TooljetDbService } from './tooljet_db.service';
import { isEmpty } from 'lodash';
import { PostgrestProxyService } from './postgrest_proxy.service';
import { maybeSetSubPath } from 'src/helpers/utils.helper';

@Injectable()
export class TooljetDbOperationsService implements QueryService {
Expand Down Expand Up @@ -74,7 +75,7 @@ export class TooljetDbOperationsService implements QueryService {
!isEmpty(offset) && query.push(`offset=${offset}`);
}
const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id };
const url = `/api/tooljet-db/proxy/${tableId}` + `?${query}`;
const url = maybeSetSubPath(`/api/tooljet-db/proxy/${tableId}` + `?${query}`);

return await this.proxyPostgrest(url, 'GET', headers);
}
Expand All @@ -87,7 +88,7 @@ export class TooljetDbOperationsService implements QueryService {

const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id };

const url = `/api/tooljet-db/proxy/${queryOptions.table_id}`;
const url = maybeSetSubPath(`/api/tooljet-db/proxy/${queryOptions.table_id}`);
return await this.proxyPostgrest(url, 'POST', headers, columns);
}

Expand All @@ -112,7 +113,7 @@ export class TooljetDbOperationsService implements QueryService {
!isEmpty(whereQuery) && query.push(whereQuery);

const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id };
const url = `/api/tooljet-db/proxy/${tableId}?` + query.join('&') + '&order=id';
const url = maybeSetSubPath(`/api/tooljet-db/proxy/${tableId}?` + query.join('&') + '&order=id');
return await this.proxyPostgrest(url, 'PATCH', headers, body);
}

Expand Down Expand Up @@ -149,7 +150,7 @@ export class TooljetDbOperationsService implements QueryService {
limit && limit !== '' && query.push(`limit=${limit}&order=id`);

const headers = { 'data-query-id': queryOptions.id, 'tj-workspace-id': queryOptions.organization_id };
const url = `/api/tooljet-db/proxy/${tableId}?` + query.join('&');
const url = maybeSetSubPath(`/api/tooljet-db/proxy/${tableId}?` + query.join('&'));
return await this.proxyPostgrest(url, 'DELETE', headers);
}

Expand Down

0 comments on commit 4136010

Please sign in to comment.