diff --git a/lib/DboBuilder/ViewHandler/ViewHandler.ts b/lib/DboBuilder/ViewHandler/ViewHandler.ts index d5f47080..dc0f5e30 100644 --- a/lib/DboBuilder/ViewHandler/ViewHandler.ts +++ b/lib/DboBuilder/ViewHandler/ViewHandler.ts @@ -268,17 +268,15 @@ export class ViewHandler { } find = find.bind(this); - async findOne(filter?: Filter, selectParams?: SelectParams, param3_unused?: undefined, table_rules?: TableRule, localParams?: LocalParams): Promise { + async findOne(filter?: Filter, selectParams?: SelectParams, _param3_unused?: undefined, table_rules?: TableRule, localParams?: LocalParams): Promise { try { await this._log({ command: "find", localParams, data: { filter, selectParams } }); - const { select = "*", orderBy, offset = 0 } = selectParams || {}; - if (selectParams) { - const good_params = ["select", "orderBy", "offset"]; - const bad_params = Object.keys(selectParams).filter(k => !good_params.includes(k)); - if (bad_params && bad_params.length) throw "Invalid params: " + bad_params.join(", ") + " \n Expecting: " + good_params.join(", "); + const { limit, ...params } = selectParams ?? {}; + if (limit) { + throw "limit not allowed in findOne()"; } - return this.find(filter, { select, orderBy, limit: 1, offset, returnType: "row" }, undefined, table_rules, localParams); + return this.find(filter, { ...params, limit: 1, returnType: "row" }, undefined, table_rules, localParams); } catch (e) { if (localParams && localParams.testRule) throw e; throw parseError(e, `Issue with dbo.${this.name}.findOne()`); diff --git a/package-lock.json b/package-lock.json index 0a731278..ab7da891 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "prostgles-server", - "version": "4.2.57", + "version": "4.2.58", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "prostgles-server", - "version": "4.2.57", + "version": "4.2.58", "license": "MIT", "dependencies": { "bluebird": "^3.7.2", diff --git a/package.json b/package.json index 49fd5a86..dd607a69 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "prostgles-server", - "version": "4.2.57", + "version": "4.2.58", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/tests/server/DBoGenerated.d.ts b/tests/server/DBoGenerated.d.ts index aeccf676..6b3d681b 100644 --- a/tests/server/DBoGenerated.d.ts +++ b/tests/server/DBoGenerated.d.ts @@ -246,6 +246,18 @@ export type DBSchemaGenerated = { name?: null | string; }; }; + logs: { + is_view: false; + select: true; + insert: true; + update: true; + delete: true; + columns: { + created_at?: string; + id?: string; + request?: null | any; + }; + }; lookup_col1: { is_view: false; select: true; @@ -292,6 +304,19 @@ export type DBSchemaGenerated = { y?: null | number; }; }; + plans: { + is_view: false; + select: true; + insert: true; + update: true; + delete: true; + columns: { + id: string; + info?: null | any; + name: string; + price?: null | string; + }; + }; "prostgles_test.basic": { is_view: false; select: true; @@ -388,6 +413,17 @@ export type DBSchemaGenerated = { srtext?: null | string; }; }; + subscriptions: { + is_view: false; + select: true; + insert: true; + update: true; + delete: true; + columns: { + created_at?: string; + plan_id: string; + }; + }; symbols: { is_view: false; select: true; diff --git a/tests/server/package-lock.json b/tests/server/package-lock.json index 88ae5b5d..8cb6f1fe 100644 --- a/tests/server/package-lock.json +++ b/tests/server/package-lock.json @@ -21,7 +21,7 @@ }, "../..": { "name": "prostgles-server", - "version": "4.2.57", + "version": "4.2.58", "license": "MIT", "dependencies": { "bluebird": "^3.7.2",