prostgles-server 4.2.623 → 4.2.625
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/debug/client-schema-types/DBGeneratedSchema.ts +13 -1
- package/dist/Audit/AuditTable.d.ts +2 -1
- package/dist/Audit/AuditTable.d.ts.map +1 -1
- package/dist/Audit/AuditTable.js +3 -2
- package/dist/Audit/AuditTable.js.map +1 -1
- package/dist/Audit/getAuditTableRules.d.ts +7 -0
- package/dist/Audit/getAuditTableRules.d.ts.map +1 -0
- package/dist/Audit/getAuditTableRules.js +191 -0
- package/dist/Audit/getAuditTableRules.js.map +1 -0
- package/dist/Audit/getAuditTriggerConfig.d.ts.map +1 -1
- package/dist/Audit/getAuditTriggerConfig.js +14 -1
- package/dist/Audit/getAuditTriggerConfig.js.map +1 -1
- package/dist/DBSchemaBuilder/getDBGeneratedSchema.d.ts.map +1 -1
- package/dist/DBSchemaBuilder/getDBGeneratedSchema.js +1 -2
- package/dist/DBSchemaBuilder/getDBGeneratedSchema.js.map +1 -1
- package/dist/DboBuilder/DboBuilder.js +1 -1
- package/dist/DboBuilder/DboBuilder.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts +10 -5
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.js +90 -71
- package/dist/DboBuilder/QueryBuilder/QueryBuilder.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getJoinQuery.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getJoinQuery.js +3 -2
- package/dist/DboBuilder/QueryBuilder/getJoinQuery.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getNewQuery.d.ts +2 -2
- package/dist/DboBuilder/QueryBuilder/getNewQuery.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getNewQuery.js +53 -116
- package/dist/DboBuilder/QueryBuilder/getNewQuery.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getQuerySource.d.ts +18 -0
- package/dist/DboBuilder/QueryBuilder/getQuerySource.d.ts.map +1 -0
- package/dist/DboBuilder/QueryBuilder/getQuerySource.js +29 -0
- package/dist/DboBuilder/QueryBuilder/getQuerySource.js.map +1 -0
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.d.ts.map +1 -1
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.js +6 -2
- package/dist/DboBuilder/QueryBuilder/getSelectQuery.js.map +1 -1
- package/dist/DboBuilder/QueryBuilder/parseJoinSelect.d.ts +13 -0
- package/dist/DboBuilder/QueryBuilder/parseJoinSelect.d.ts.map +1 -0
- package/dist/DboBuilder/QueryBuilder/parseJoinSelect.js +57 -0
- package/dist/DboBuilder/QueryBuilder/parseJoinSelect.js.map +1 -0
- package/dist/DboBuilder/TableHandler/TableHandler.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/TableHandler.js +2 -1
- package/dist/DboBuilder/TableHandler/TableHandler.js.map +1 -1
- package/dist/DboBuilder/TableHandler/delete.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/delete.js +2 -1
- package/dist/DboBuilder/TableHandler/delete.js.map +1 -1
- package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.js +2 -1
- package/dist/DboBuilder/TableHandler/runInsertUpdateQuery.js.map +1 -1
- package/dist/DboBuilder/TableHandler/update.d.ts.map +1 -1
- package/dist/DboBuilder/TableHandler/update.js +2 -1
- package/dist/DboBuilder/TableHandler/update.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts +6 -16
- package/dist/DboBuilder/ViewHandler/ViewHandler.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/ViewHandler.js +2 -7
- package/dist/DboBuilder/ViewHandler/ViewHandler.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/find.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/find.js +1 -1
- package/dist/DboBuilder/ViewHandler/find.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getExistsCondition.d.ts +1 -1
- package/dist/DboBuilder/ViewHandler/getExistsCondition.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/getExistsCondition.js +24 -13
- package/dist/DboBuilder/ViewHandler/getExistsCondition.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.d.ts +4 -1
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.js +20 -14
- package/dist/DboBuilder/ViewHandler/getTableJoinQuery.js.map +1 -1
- package/dist/DboBuilder/ViewHandler/prepareWhere.d.ts +7 -3
- package/dist/DboBuilder/ViewHandler/prepareWhere.d.ts.map +1 -1
- package/dist/DboBuilder/ViewHandler/prepareWhere.js +30 -23
- package/dist/DboBuilder/ViewHandler/prepareWhere.js.map +1 -1
- package/dist/DboBuilder/getCondition.d.ts +2 -1
- package/dist/DboBuilder/getCondition.d.ts.map +1 -1
- package/dist/DboBuilder/getCondition.js +9 -8
- package/dist/DboBuilder/getCondition.js.map +1 -1
- package/dist/DboBuilder/getSubscribeRelatedTables.d.ts.map +1 -1
- package/dist/DboBuilder/getSubscribeRelatedTables.js +3 -2
- package/dist/DboBuilder/getSubscribeRelatedTables.js.map +1 -1
- package/dist/DboBuilder/parseUpdateRules.d.ts.map +1 -1
- package/dist/DboBuilder/parseUpdateRules.js +3 -2
- package/dist/DboBuilder/parseUpdateRules.js.map +1 -1
- package/dist/DboBuilder/schema/getTablesForSchemaPostgresSQL.d.ts +2 -2
- package/dist/Prostgles.d.ts.map +1 -1
- package/dist/Prostgles.js +2 -0
- package/dist/Prostgles.js.map +1 -1
- package/dist/ProstglesContext.spec.js +25 -0
- package/dist/ProstglesContext.spec.js.map +1 -1
- package/dist/PubSubManager/PubSubManager.d.ts +1 -1
- package/dist/PublishParser/PublishParser.d.ts +17 -8
- package/dist/PublishParser/PublishParser.d.ts.map +1 -1
- package/dist/PublishParser/PublishParser.js +59 -28
- package/dist/PublishParser/PublishParser.js.map +1 -1
- package/dist/PublishParser/applyScopeToTableRules.d.ts +0 -1
- package/dist/PublishParser/applyScopeToTableRules.d.ts.map +1 -1
- package/dist/PublishParser/applyScopeToTableRules.js +3 -7
- package/dist/PublishParser/applyScopeToTableRules.js.map +1 -1
- package/dist/PublishParser/getFileTableRules.d.ts +1 -1
- package/dist/PublishParser/getFileTableRules.d.ts.map +1 -1
- package/dist/PublishParser/getFileTableRules.js +52 -41
- package/dist/PublishParser/getFileTableRules.js.map +1 -1
- package/dist/PublishParser/getParsedPublishTable.d.ts +4 -0
- package/dist/PublishParser/getParsedPublishTable.d.ts.map +1 -0
- package/dist/PublishParser/{getTableRulesWithoutFileTable.js → getParsedPublishTable.js} +13 -7
- package/dist/PublishParser/getParsedPublishTable.js.map +1 -0
- package/dist/PublishParser/getPublishSchemas.d.ts +4 -0
- package/dist/PublishParser/getPublishSchemas.d.ts.map +1 -0
- package/dist/PublishParser/getPublishSchemas.js +42 -0
- package/dist/PublishParser/getPublishSchemas.js.map +1 -0
- package/dist/PublishParser/getPublishedObjectFromResult.d.ts +4 -0
- package/dist/PublishParser/getPublishedObjectFromResult.d.ts.map +1 -0
- package/dist/PublishParser/getPublishedObjectFromResult.js +77 -0
- package/dist/PublishParser/getPublishedObjectFromResult.js.map +1 -0
- package/dist/PublishParser/getPublishedTableNames.d.ts.map +1 -1
- package/dist/PublishParser/getPublishedTableNames.js +20 -1
- package/dist/PublishParser/getPublishedTableNames.js.map +1 -1
- package/dist/PublishParser/getSchemaFromPublish.d.ts.map +1 -1
- package/dist/PublishParser/getSchemaFromPublish.js +11 -5
- package/dist/PublishParser/getSchemaFromPublish.js.map +1 -1
- package/dist/PublishParser/publishTypesAndUtils.d.ts +28 -7
- package/dist/PublishParser/publishTypesAndUtils.d.ts.map +1 -1
- package/dist/PublishParser/publishTypesAndUtils.js +6 -1
- package/dist/PublishParser/publishTypesAndUtils.js.map +1 -1
- package/dist/PublishParser/validatePublishProfiles.d.ts +2 -2
- package/dist/PublishParser/validatePublishProfiles.d.ts.map +1 -1
- package/dist/PublishParser/validatePublishProfiles.js.map +1 -1
- package/dist/TableConfig/getColumnSQLDefinitionQuery.d.ts.map +1 -1
- package/dist/TableConfig/getColumnSQLDefinitionQuery.js +1 -2
- package/dist/TableConfig/getColumnSQLDefinitionQuery.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/runClientRequest.d.ts.map +1 -1
- package/dist/runClientRequest.js +6 -1
- package/dist/runClientRequest.js.map +1 -1
- package/lib/Audit/AuditTable.ts +4 -3
- package/lib/Audit/getAuditTableRules.ts +288 -0
- package/lib/Audit/getAuditTriggerConfig.ts +14 -1
- package/lib/DBSchemaBuilder/getDBGeneratedSchema.ts +1 -2
- package/lib/DboBuilder/DboBuilder.ts +1 -1
- package/lib/DboBuilder/QueryBuilder/QueryBuilder.ts +118 -90
- package/lib/DboBuilder/QueryBuilder/getJoinQuery.ts +3 -2
- package/lib/DboBuilder/QueryBuilder/getNewQuery.ts +111 -194
- package/lib/DboBuilder/QueryBuilder/getQuerySource.ts +55 -0
- package/lib/DboBuilder/QueryBuilder/getSelectQuery.ts +8 -2
- package/lib/DboBuilder/QueryBuilder/parseJoinSelect.ts +73 -0
- package/lib/DboBuilder/TableHandler/TableHandler.ts +3 -6
- package/lib/DboBuilder/TableHandler/delete.ts +2 -1
- package/lib/DboBuilder/TableHandler/runInsertUpdateQuery.ts +2 -1
- package/lib/DboBuilder/TableHandler/update.ts +2 -1
- package/lib/DboBuilder/ViewHandler/ViewHandler.ts +6 -12
- package/lib/DboBuilder/ViewHandler/find.ts +0 -1
- package/lib/DboBuilder/ViewHandler/getExistsCondition.ts +35 -28
- package/lib/DboBuilder/ViewHandler/getTableJoinQuery.ts +22 -14
- package/lib/DboBuilder/ViewHandler/prepareWhere.ts +48 -27
- package/lib/DboBuilder/getCondition.ts +11 -10
- package/lib/DboBuilder/getSubscribeRelatedTables.ts +3 -2
- package/lib/DboBuilder/parseUpdateRules.ts +3 -2
- package/lib/Prostgles.ts +1 -0
- package/lib/ProstglesContext.spec.ts +30 -0
- package/lib/PublishParser/PublishParser.ts +108 -51
- package/lib/PublishParser/applyScopeToTableRules.ts +1 -7
- package/lib/PublishParser/getFileTableRules.ts +52 -45
- package/lib/PublishParser/{getTableRulesWithoutFileTable.ts → getParsedPublishTable.ts} +16 -12
- package/lib/PublishParser/getPublishSchemas.ts +49 -0
- package/lib/PublishParser/getPublishedObjectFromResult.ts +104 -0
- package/lib/PublishParser/getPublishedTableNames.ts +28 -1
- package/lib/PublishParser/getSchemaFromPublish.ts +9 -7
- package/lib/PublishParser/publishTypesAndUtils.ts +31 -11
- package/lib/PublishParser/validatePublishProfiles.ts +1 -1
- package/lib/TableConfig/getColumnSQLDefinitionQuery.ts +8 -2
- package/lib/index.ts +14 -1
- package/lib/runClientRequest.ts +4 -3
- package/package.json +1 -1
- package/dist/DBSchemaBuilder/getPublishSchemas.d.ts +0 -4
- package/dist/DBSchemaBuilder/getPublishSchemas.d.ts.map +0 -1
- package/dist/DBSchemaBuilder/getPublishSchemas.js +0 -34
- package/dist/DBSchemaBuilder/getPublishSchemas.js.map +0 -1
- package/dist/PublishParser/getTableRulesWithoutFileTable.d.ts +0 -6
- package/dist/PublishParser/getTableRulesWithoutFileTable.d.ts.map +0 -1
- package/dist/PublishParser/getTableRulesWithoutFileTable.js.map +0 -1
- package/lib/DBSchemaBuilder/getPublishSchemas.ts +0 -41
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { asName, type SelectParams } from "prostgles-types";
|
|
2
|
+
import type { ParsedTableRule } from "../../PublishParser/PublishParser";
|
|
3
|
+
import type {
|
|
4
|
+
Awaitable,
|
|
5
|
+
SelectRequestData,
|
|
6
|
+
SelectRule,
|
|
7
|
+
} from "../../PublishParser/publishTypesAndUtils";
|
|
8
|
+
import type { PGIdentifier } from "../DboBuilder";
|
|
9
|
+
import type { ViewHandler } from "../ViewHandler/ViewHandler";
|
|
10
|
+
|
|
11
|
+
const GET_TABLE_EXPRESSION = Symbol("getTableExpression");
|
|
12
|
+
const TABLE_EXPRESSION_ALIAS = "prostgles_table_expression";
|
|
13
|
+
|
|
14
|
+
type SelectRuleWithTableExpression = SelectRule & {
|
|
15
|
+
[GET_TABLE_EXPRESSION]?: (request: SelectRequestData) => Awaitable<string | undefined>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type QuerySource = {
|
|
19
|
+
expression: string;
|
|
20
|
+
alias?: PGIdentifier;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const withTableExpression = <T extends SelectRule>(
|
|
24
|
+
selectRule: T,
|
|
25
|
+
getTableExpression: NonNullable<SelectRuleWithTableExpression[typeof GET_TABLE_EXPRESSION]>,
|
|
26
|
+
): T => {
|
|
27
|
+
return Object.assign(selectRule, { [GET_TABLE_EXPRESSION]: getTableExpression });
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getQuerySource = async (
|
|
31
|
+
viewHandler: ViewHandler,
|
|
32
|
+
tableRules: ParsedTableRule | undefined,
|
|
33
|
+
filter: SelectRequestData["filter"],
|
|
34
|
+
params: SelectParams,
|
|
35
|
+
preferredAlias?: PGIdentifier,
|
|
36
|
+
): Promise<QuerySource> => {
|
|
37
|
+
const selectRule = tableRules?.select as SelectRuleWithTableExpression | undefined;
|
|
38
|
+
const getTableExpression = selectRule?.[GET_TABLE_EXPRESSION];
|
|
39
|
+
const tableExpression =
|
|
40
|
+
getTableExpression ? await getTableExpression({ filter, params }) : undefined;
|
|
41
|
+
const alias =
|
|
42
|
+
preferredAlias ??
|
|
43
|
+
(tableExpression ?
|
|
44
|
+
{ raw: TABLE_EXPRESSION_ALIAS, escaped: asName(TABLE_EXPRESSION_ALIAS) }
|
|
45
|
+
: undefined);
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
expression: tableExpression ?? viewHandler.escapedName,
|
|
49
|
+
alias,
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const getQuerySourceSQL = ({ expression, alias }: QuerySource) => {
|
|
54
|
+
return `${expression}${alias ? ` ${alias.escaped}` : ""}`;
|
|
55
|
+
};
|
|
@@ -3,6 +3,7 @@ import { isDefined, asName } from "prostgles-types";
|
|
|
3
3
|
import type { NewQuery } from "./QueryBuilder";
|
|
4
4
|
import type { ViewHandler } from "../ViewHandler/ViewHandler";
|
|
5
5
|
import { getJoinQuery } from "./getJoinQuery";
|
|
6
|
+
import { getQuerySourceSQL } from "./getQuerySource";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Used to prevent single row nested results in case of OR join conditions
|
|
@@ -46,6 +47,7 @@ export function getSelectQuery(
|
|
|
46
47
|
|
|
47
48
|
/** OR joins cannot be easily aggregated to one-many with the root table. Must group by root table id */
|
|
48
49
|
const hasOrJoins = parsedJoins.some((j) => j.isOrJoin);
|
|
50
|
+
const tableExpression = getQuerySourceSQL(q.source);
|
|
49
51
|
|
|
50
52
|
const joinCtes: string[][] = parsedJoins
|
|
51
53
|
.map((j) => {
|
|
@@ -58,7 +60,7 @@ export function getSelectQuery(
|
|
|
58
60
|
joinCtes.unshift([
|
|
59
61
|
`${q.table.escaped} AS (`,
|
|
60
62
|
` SELECT *, ${pkey ? asName(pkey.name) : "ROW_NUMBER() OVER()"} as ${ROOT_TABLE_ROW_NUM_ID}`,
|
|
61
|
-
` FROM ${
|
|
63
|
+
` FROM ${tableExpression}`,
|
|
62
64
|
`)`,
|
|
63
65
|
]);
|
|
64
66
|
}
|
|
@@ -80,7 +82,11 @@ export function getSelectQuery(
|
|
|
80
82
|
...indentLines(selectItems, { appendCommas: true }),
|
|
81
83
|
`FROM ( `,
|
|
82
84
|
` SELECT *`,
|
|
83
|
-
` FROM ${
|
|
85
|
+
` FROM ${
|
|
86
|
+
hasOrJoins ?
|
|
87
|
+
getQuerySourceSQL({ expression: q.table.escaped, alias: q.source.alias })
|
|
88
|
+
: tableExpression
|
|
89
|
+
}`,
|
|
84
90
|
...(q.where ? [` ${q.where}`] : []),
|
|
85
91
|
`) ${ROOT_TABLE_ALIAS}`,
|
|
86
92
|
...parsedJoins.flatMap((j) => j.joinLines),
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
DetailedJoinSelect,
|
|
3
|
+
JoinPath,
|
|
4
|
+
JoinSelect,
|
|
5
|
+
RawJoinPath,
|
|
6
|
+
SimpleJoinSelect,
|
|
7
|
+
} from "prostgles-types";
|
|
8
|
+
import { getKeys, includes } from "prostgles-types";
|
|
9
|
+
|
|
10
|
+
const JOIN_KEYS = ["$innerJoin", "$leftJoin"] as const;
|
|
11
|
+
const JOIN_PARAM_KEYS = getKeys({
|
|
12
|
+
$condition: 1,
|
|
13
|
+
filter: 1,
|
|
14
|
+
having: 1,
|
|
15
|
+
limit: 1,
|
|
16
|
+
offset: 1,
|
|
17
|
+
orderBy: 1,
|
|
18
|
+
select: 1,
|
|
19
|
+
} satisfies Record<keyof Omit<DetailedJoinSelect, (typeof JOIN_KEYS)[number]>, 1>);
|
|
20
|
+
|
|
21
|
+
export type ParsedJoin =
|
|
22
|
+
| {
|
|
23
|
+
type: "detailed";
|
|
24
|
+
params: DetailedJoinSelect & {
|
|
25
|
+
table: DetailedJoinSelect["$leftJoin"];
|
|
26
|
+
path: RawJoinPath;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
| { type: "simple"; params: SimpleJoinSelect };
|
|
30
|
+
|
|
31
|
+
export const parseJoinSelect = (joinParams: JoinSelect): ParsedJoin | string => {
|
|
32
|
+
if (!(joinParams as string)) {
|
|
33
|
+
return "Empty join params";
|
|
34
|
+
}
|
|
35
|
+
if (typeof joinParams === "string") {
|
|
36
|
+
if ((joinParams as string) !== "*") {
|
|
37
|
+
throw "Join select can be * or { field: 1 }";
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
type: "simple",
|
|
41
|
+
params: joinParams,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const [joinKey, ...otherKeys] = getKeys(joinParams).filter((k) => includes(JOIN_KEYS, k));
|
|
45
|
+
if (otherKeys.length) {
|
|
46
|
+
return "Cannot specify more than one join type ( $innerJoin OR $leftJoin )";
|
|
47
|
+
} else if (joinKey) {
|
|
48
|
+
/* Full option join { field_name: db.innerJoin.table_name(filter, select) } */
|
|
49
|
+
const invalidParams = Object.keys(joinParams).filter(
|
|
50
|
+
(k) => !includes([...JOIN_PARAM_KEYS, ...JOIN_KEYS], k),
|
|
51
|
+
);
|
|
52
|
+
if (invalidParams.length) {
|
|
53
|
+
throw "Invalid join params: " + invalidParams.join(", ");
|
|
54
|
+
}
|
|
55
|
+
const path = joinParams[joinKey] as string | JoinPath[];
|
|
56
|
+
if (Array.isArray(path) && !path.length) {
|
|
57
|
+
throw `Cannot have an empty join path/tableName ${joinKey}`;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
type: "detailed",
|
|
61
|
+
params: {
|
|
62
|
+
...(joinParams as DetailedJoinSelect),
|
|
63
|
+
path,
|
|
64
|
+
table: typeof path === "string" ? path : path.at(-1)!.table,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
type: "simple",
|
|
71
|
+
params: joinParams as SimpleJoinSelect,
|
|
72
|
+
};
|
|
73
|
+
};
|
|
@@ -19,11 +19,7 @@ import type {
|
|
|
19
19
|
import { getSyncBatchOptions } from "../../PubSubManager/SyncReplication/getSyncBatchOptions";
|
|
20
20
|
import type { TableDefinition } from "../../TableConfig/TableConfigTypes";
|
|
21
21
|
import type { DboBuilder, Filter, LocalParams, TableHandlers } from "../DboBuilder";
|
|
22
|
-
import {
|
|
23
|
-
getErrorAsObject,
|
|
24
|
-
getSerializedClientErrorFromPGError,
|
|
25
|
-
withUserRLS,
|
|
26
|
-
} from "../DboBuilder";
|
|
22
|
+
import { getErrorAsObject, getSerializedClientErrorFromPGError, withUserRLS } from "../DboBuilder";
|
|
27
23
|
import type { TableSchema } from "../DboBuilderTypes";
|
|
28
24
|
import { parseUpdateRules } from "../parseUpdateRules";
|
|
29
25
|
import { COMPUTED_FIELDS } from "../QueryBuilder/Functions/COMPUTED_FIELDS";
|
|
@@ -41,6 +37,7 @@ import { isApplicableHook } from "./isApplicableHook";
|
|
|
41
37
|
import type { TableConfigurator } from "../../TableConfig/TableConfigurator";
|
|
42
38
|
import type { TableHooksDefinition } from "../../TableHooks/TableHooks";
|
|
43
39
|
import type { TransactionCallbacks } from "../../PublishParser/publishTypesAndUtils";
|
|
40
|
+
import { prepareWhere } from "../ViewHandler/prepareWhere";
|
|
44
41
|
|
|
45
42
|
export type ValidatedParams = {
|
|
46
43
|
row: AnyObject;
|
|
@@ -359,7 +356,7 @@ export class TableHandler extends ViewHandler {
|
|
|
359
356
|
).then(async (data: AnyObject[]) => {
|
|
360
357
|
const { filterFields, forcedFilter } = table_rules.select || {};
|
|
361
358
|
const condition = (
|
|
362
|
-
await
|
|
359
|
+
await prepareWhere(this, {
|
|
363
360
|
select: undefined,
|
|
364
361
|
filter,
|
|
365
362
|
forcedFilter,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { getReturnTypeQuery } from "../ViewHandler/getReturnTypeQuery";
|
|
12
12
|
import type { TableHandler } from "./TableHandler";
|
|
13
13
|
import { executeAfterHooksCheckAndPostValidation } from "./executeAfterHooksCheckAndPostValidation";
|
|
14
|
+
import { prepareWhere } from "../ViewHandler/prepareWhere";
|
|
14
15
|
|
|
15
16
|
export async function _delete(
|
|
16
17
|
this: TableHandler,
|
|
@@ -86,7 +87,7 @@ export async function _delete(
|
|
|
86
87
|
|
|
87
88
|
let queryType: keyof pgPromise.ITask<{}> = "none";
|
|
88
89
|
let queryWithoutRLS = `DELETE FROM ${this.escapedName} `;
|
|
89
|
-
const filterOpts = await
|
|
90
|
+
const filterOpts = await prepareWhere(this, {
|
|
90
91
|
select: undefined,
|
|
91
92
|
filter,
|
|
92
93
|
forcedFilter,
|
|
@@ -6,6 +6,7 @@ import { rejectWithPGClientError, withUserRLS } from "../DboBuilder";
|
|
|
6
6
|
import type { TableHandler } from "./TableHandler";
|
|
7
7
|
import { getSelectItemQuery } from "./TableHandler";
|
|
8
8
|
import { executeAfterHooksCheckAndPostValidation } from "./executeAfterHooksCheckAndPostValidation";
|
|
9
|
+
import { prepareWhere } from "../ViewHandler/prepareWhere";
|
|
9
10
|
|
|
10
11
|
type RunInsertUpdateQueryArgs = {
|
|
11
12
|
tableHandler: TableHandler;
|
|
@@ -54,7 +55,7 @@ export const runInsertUpdateQuery = async (args: RunInsertUpdateQueryArgs) => {
|
|
|
54
55
|
// let checkCondition = "WHERE FALSE";
|
|
55
56
|
let checkCondition = "FALSE";
|
|
56
57
|
if (checkFilter) {
|
|
57
|
-
const checkCond = await
|
|
58
|
+
const checkCond = await prepareWhere(tableHandler, {
|
|
58
59
|
select: undefined,
|
|
59
60
|
localParams: undefined,
|
|
60
61
|
tableRule: undefined,
|
|
@@ -9,6 +9,7 @@ import { getReferenceColumnInserts } from "./insert/getReferenceColumnInserts";
|
|
|
9
9
|
import { runInsertUpdateQuery } from "./runInsertUpdateQuery";
|
|
10
10
|
import { lockFileForUpdate } from "./updateFile";
|
|
11
11
|
import type { TableHandler } from "./TableHandler";
|
|
12
|
+
import { prepareWhere } from "../ViewHandler/prepareWhere";
|
|
12
13
|
|
|
13
14
|
export async function update(
|
|
14
15
|
this: TableHandler,
|
|
@@ -66,7 +67,7 @@ export async function update(
|
|
|
66
67
|
);
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
const updateFilter = await
|
|
70
|
+
const updateFilter = await prepareWhere(this, {
|
|
70
71
|
select: undefined,
|
|
71
72
|
filter,
|
|
72
73
|
forcedFilter,
|
|
@@ -13,26 +13,25 @@ import type { TableEvent } from "../../Logging";
|
|
|
13
13
|
import type { DB } from "../../Prostgles";
|
|
14
14
|
import type { Join } from "../../ProstglesTypes";
|
|
15
15
|
import type { ParsedTableRule } from "../../PublishParser/PublishParser";
|
|
16
|
-
import type {
|
|
16
|
+
import type { VoidFunction } from "../../SchemaWatch/SchemaWatch";
|
|
17
|
+
import type { TableDefinition } from "../../TableConfig/TableConfigTypes";
|
|
18
|
+
import type { TableHooksDefinition } from "../../TableHooks/TableHooks";
|
|
19
|
+
import { escapeTSNames } from "../../utils/utils";
|
|
17
20
|
import type { DboBuilder, Filter, LocalParams, TableHandlers } from "../DboBuilder";
|
|
18
21
|
import { getSerializedClientErrorFromPGError } from "../DboBuilder";
|
|
19
22
|
import type { TableSchema } from "../DboBuilderTypes";
|
|
20
23
|
import { getValidatedTableRules } from "../TableRules/getValidatedTableRules";
|
|
21
24
|
import { getColumns } from "../getColumns";
|
|
25
|
+
import type { Graph } from "../joins/shortestPath";
|
|
22
26
|
import { count } from "./count";
|
|
23
27
|
import { find, type Param3 } from "./find";
|
|
28
|
+
import { getDbHandlerWithAbort } from "./getDbHandlerWithAbort";
|
|
24
29
|
import { getInfo } from "./getInfo";
|
|
25
30
|
import { parseFieldFilter } from "./parseFieldFilter";
|
|
26
|
-
import { prepareWhere } from "./prepareWhere";
|
|
27
31
|
import { size } from "./size";
|
|
28
32
|
import type { OnData } from "./subscribe";
|
|
29
33
|
import { subscribe } from "./subscribe";
|
|
30
34
|
import { validateViewRules } from "./validateViewRules";
|
|
31
|
-
import { escapeTSNames } from "../../utils/utils";
|
|
32
|
-
import type { TableDefinition } from "../../TableConfig/TableConfigTypes";
|
|
33
|
-
import { getDbHandlerWithAbort } from "./getDbHandlerWithAbort";
|
|
34
|
-
import type { VoidFunction } from "../../SchemaWatch/SchemaWatch";
|
|
35
|
-
import type { TableHooksDefinition } from "../../TableHooks/TableHooks";
|
|
36
35
|
|
|
37
36
|
export type JoinPaths = {
|
|
38
37
|
t1: string;
|
|
@@ -338,11 +337,6 @@ export class ViewHandler {
|
|
|
338
337
|
return col_names;
|
|
339
338
|
}
|
|
340
339
|
|
|
341
|
-
/**
|
|
342
|
-
* Parses group or simple filter
|
|
343
|
-
*/
|
|
344
|
-
prepareWhere = prepareWhere.bind(this);
|
|
345
|
-
|
|
346
340
|
intersectColumns(
|
|
347
341
|
allowedFields: FieldFilter,
|
|
348
342
|
disallowedFields: FieldFilter,
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { EXISTS_KEYS
|
|
3
|
-
import type { LocalParams, ExistsFilterConfig } from "../DboBuilder";
|
|
4
|
-
import type { ViewHandler } from "./ViewHandler";
|
|
1
|
+
import type { EXISTS_KEY } from "prostgles-types";
|
|
2
|
+
import { EXISTS_KEYS } from "prostgles-types";
|
|
5
3
|
import type { ParsedTableRule } from "../../PublishParser/PublishParser";
|
|
6
|
-
import type {
|
|
7
|
-
import {
|
|
4
|
+
import type { ExistsFilterConfig, LocalParams } from "../DboBuilder";
|
|
5
|
+
import { getQuerySourceSQL } from "../QueryBuilder/getQuerySource";
|
|
6
|
+
import { getTableJoinAlias, getTableJoinQuery } from "./getTableJoinQuery";
|
|
7
|
+
import type { ViewHandler } from "./ViewHandler";
|
|
8
|
+
import { prepareWhere } from "./prepareWhere";
|
|
8
9
|
|
|
9
10
|
export async function getExistsCondition(
|
|
10
11
|
this: ViewHandler,
|
|
@@ -25,17 +26,22 @@ export async function getExistsCondition(
|
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
let t2Rules: ParsedTableRule | undefined = undefined,
|
|
29
|
-
forcedFilter: AnyObject | undefined,
|
|
30
|
-
filterFields: FieldFilter | undefined;
|
|
31
|
-
|
|
32
29
|
/* Check if allowed to view data - forcedFilters will bypass this check through isForcedFilterBypass */
|
|
33
30
|
if (localParams?.isRemoteRequest && !localParams.clientReq) {
|
|
34
31
|
throw "Unexpected: localParams isRemoteRequest and missing clientReq";
|
|
35
32
|
}
|
|
33
|
+
|
|
34
|
+
let targetTableRules: ParsedTableRule | undefined = undefined;
|
|
36
35
|
const targetTable = eConfig.isJoined ? eConfig.parsedPath.at(-1)!.table : eConfig.targetTable;
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const tableHandler = this.dboBuilder.dboMap.get(targetTable);
|
|
37
|
+
if (!tableHandler) {
|
|
38
|
+
throw `Table handler for ${targetTable} not found`;
|
|
39
|
+
}
|
|
40
|
+
if (localParams?.clientReq) {
|
|
41
|
+
if (!this.dboBuilder.publishParser) {
|
|
42
|
+
throw "Unexpected: missing publishParser";
|
|
43
|
+
}
|
|
44
|
+
targetTableRules = await this.dboBuilder.publishParser.getValidatedRequestRuleWusr(
|
|
39
45
|
{
|
|
40
46
|
tableName: targetTable,
|
|
41
47
|
command: "find",
|
|
@@ -44,27 +50,27 @@ export async function getExistsCondition(
|
|
|
44
50
|
localParams.scope,
|
|
45
51
|
);
|
|
46
52
|
|
|
47
|
-
if (!
|
|
48
|
-
({ forcedFilter, filterFields } = t2Rules.select);
|
|
53
|
+
if (!targetTableRules.select) throw "Disallowed";
|
|
49
54
|
}
|
|
50
55
|
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
)
|
|
56
|
+
const targetAlias =
|
|
57
|
+
eConfig.isJoined ? getTableJoinAlias(targetTable, eConfig.parsedPath.length - 1) : undefined;
|
|
58
|
+
const whereOpts = await prepareWhere(tableHandler, {
|
|
59
|
+
select: undefined,
|
|
60
|
+
selectParams: {},
|
|
61
|
+
filter: targetTableFilter,
|
|
62
|
+
forcedFilter: targetTableRules?.select?.forcedFilter,
|
|
63
|
+
filterFields: targetTableRules?.select?.filterFields,
|
|
64
|
+
tableRule: targetTableRules,
|
|
65
|
+
addWhere: false,
|
|
66
|
+
tableAlias: targetAlias,
|
|
67
|
+
localParams,
|
|
68
|
+
});
|
|
69
|
+
const { source: targetSource, where: finalWhere } = whereOpts;
|
|
64
70
|
|
|
65
71
|
let innerQuery = [
|
|
66
72
|
`SELECT 1`,
|
|
67
|
-
`FROM ${
|
|
73
|
+
`FROM ${getQuerySourceSQL(targetSource)}`,
|
|
68
74
|
`${finalWhere ? `WHERE ${finalWhere}` : ""}`,
|
|
69
75
|
].join("\n");
|
|
70
76
|
|
|
@@ -74,6 +80,7 @@ export async function getExistsCondition(
|
|
|
74
80
|
rootTableAlias: rootTableAlias ?? rootTable,
|
|
75
81
|
type: "EXISTS",
|
|
76
82
|
finalWhere,
|
|
83
|
+
finalTableExpression: targetSource.expression,
|
|
77
84
|
});
|
|
78
85
|
innerQuery = query;
|
|
79
86
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { asName } from "prostgles-types";
|
|
2
|
+
import type { PGIdentifier } from "../DboBuilder";
|
|
2
3
|
import type { ParsedJoinPath } from "./parseJoinPath";
|
|
3
4
|
|
|
4
5
|
type getTableJoinsArgs = {
|
|
5
6
|
rootTableAlias: string;
|
|
6
7
|
type: "INNER" | "LEFT" | "EXISTS";
|
|
7
8
|
finalWhere?: string;
|
|
9
|
+
finalTableExpression?: string;
|
|
8
10
|
path: ParsedJoinPath[];
|
|
9
11
|
};
|
|
10
12
|
export const getTableJoinQuery = ({
|
|
@@ -12,14 +14,14 @@ export const getTableJoinQuery = ({
|
|
|
12
14
|
type,
|
|
13
15
|
rootTableAlias,
|
|
14
16
|
finalWhere,
|
|
17
|
+
finalTableExpression,
|
|
15
18
|
}: getTableJoinsArgs): { targetAlias: string; query: string } => {
|
|
16
19
|
const [firstPath] = path;
|
|
17
20
|
if (!firstPath) {
|
|
18
21
|
throw `Cannot create join query for empty path`;
|
|
19
22
|
}
|
|
20
|
-
const aliasSufix = "jd";
|
|
21
23
|
const getTableAlias = (table: string, pathIndex: number) =>
|
|
22
|
-
|
|
24
|
+
getTableJoinAlias(table, pathIndex).escaped;
|
|
23
25
|
|
|
24
26
|
const query = path
|
|
25
27
|
.map(({ table, on }, i) => {
|
|
@@ -45,19 +47,19 @@ export const getTableJoinQuery = ({
|
|
|
45
47
|
*/
|
|
46
48
|
const whereJoinCondition =
|
|
47
49
|
isLast && isExists ?
|
|
48
|
-
`WHERE (${
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
`WHERE (${[
|
|
51
|
+
getJoinOnCondition({
|
|
52
|
+
on: firstPath.on,
|
|
53
|
+
leftAlias: rootTableAlias,
|
|
54
|
+
rightAlias: getTableAlias(firstPath.table, 0),
|
|
55
|
+
}),
|
|
56
|
+
finalWhere,
|
|
57
|
+
]
|
|
58
|
+
.filter(Boolean)
|
|
59
|
+
.join(") AND (")})`
|
|
53
60
|
: "";
|
|
54
61
|
|
|
55
|
-
const tableSelect =
|
|
56
|
-
isExists && isLast ?
|
|
57
|
-
[`(`, ` SELECT *`, ` FROM ${tableName}`, finalWhere ? ` WHERE ${finalWhere}` : "", `)`]
|
|
58
|
-
.filter((v) => v)
|
|
59
|
-
.join("\n")
|
|
60
|
-
: tableName;
|
|
62
|
+
const tableSelect = isLast ? (finalTableExpression ?? tableName) : tableName;
|
|
61
63
|
if (isExists && isFirst) {
|
|
62
64
|
return [`SELECT 1`, `FROM ${tableSelect} ${tableAlias}`, whereJoinCondition]
|
|
63
65
|
.filter((v) => v)
|
|
@@ -76,6 +78,12 @@ export const getTableJoinQuery = ({
|
|
|
76
78
|
};
|
|
77
79
|
};
|
|
78
80
|
|
|
81
|
+
export const getTableJoinAlias = (table: string, pathIndex: number): PGIdentifier => {
|
|
82
|
+
const prefix = "jd";
|
|
83
|
+
const raw = `${prefix}_${pathIndex}_${table}`;
|
|
84
|
+
return { raw, escaped: asName(raw) };
|
|
85
|
+
};
|
|
86
|
+
|
|
79
87
|
type GetJoinOnConditionArgs = {
|
|
80
88
|
on: Record<string, string>[];
|
|
81
89
|
leftAlias: string;
|
|
@@ -95,7 +103,7 @@ export const getJoinOnConditions = ({
|
|
|
95
103
|
.map(([leftCol, rightCol]) => {
|
|
96
104
|
return `${leftAlias}.${getLeftColName(leftCol)} = ${rightAlias}.${getRightColName(rightCol)}`;
|
|
97
105
|
})
|
|
98
|
-
.join(" AND ")
|
|
106
|
+
.join(" AND "),
|
|
99
107
|
);
|
|
100
108
|
};
|
|
101
109
|
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { AnyObject, FieldFilter } from "prostgles-types/dist";
|
|
1
|
+
import type { AnyObject, FieldFilter, SelectParams } from "prostgles-types/dist";
|
|
2
2
|
import { getKeys, isDefined, isObject } from "prostgles-types/dist";
|
|
3
3
|
import type { ParsedTableRule } from "../../PublishParser/PublishParser";
|
|
4
4
|
import type { ExistsFilterConfig, Filter, LocalParams, PGIdentifier } from "../DboBuilder";
|
|
5
5
|
import { getCondition } from "../getCondition";
|
|
6
6
|
import { type SelectItemValidated } from "../QueryBuilder/QueryBuilder";
|
|
7
|
+
import { getQuerySource, type QuerySource } from "../QueryBuilder/getQuerySource";
|
|
7
8
|
import type { ViewHandler } from "./ViewHandler";
|
|
8
9
|
|
|
9
10
|
export type PrepareWhereParams = {
|
|
@@ -16,46 +17,61 @@ export type PrepareWhereParams = {
|
|
|
16
17
|
localParams: LocalParams | undefined;
|
|
17
18
|
tableRule: ParsedTableRule | undefined;
|
|
18
19
|
isHaving?: boolean;
|
|
20
|
+
selectParams?: SelectParams;
|
|
19
21
|
};
|
|
20
22
|
|
|
21
|
-
export
|
|
22
|
-
this: ViewHandler,
|
|
23
|
-
params: PrepareWhereParams,
|
|
24
|
-
): Promise<{
|
|
23
|
+
export type WhereOptions = {
|
|
25
24
|
columnsUsed: string[];
|
|
26
25
|
condition: string;
|
|
27
26
|
where: string;
|
|
28
27
|
filter: AnyObject;
|
|
29
28
|
exists: ExistsFilterConfig[];
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
source: QuerySource;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export const prepareWhere = async (
|
|
33
|
+
viewHandler: ViewHandler,
|
|
34
|
+
{
|
|
32
35
|
filter,
|
|
33
36
|
select,
|
|
34
37
|
forcedFilter,
|
|
35
|
-
filterFields: ff,
|
|
36
38
|
addWhere: addKeywords = true,
|
|
37
39
|
tableAlias,
|
|
38
40
|
localParams,
|
|
39
41
|
tableRule,
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
/* Local update allow all. TODO: tidy all calls */
|
|
43
|
+
filterFields = !tableRule ? "*" : undefined,
|
|
44
|
+
isHaving,
|
|
45
|
+
selectParams,
|
|
46
|
+
}: PrepareWhereParams,
|
|
47
|
+
): Promise<WhereOptions> => {
|
|
48
|
+
const { $and: $and_key, $or: $or_key } = viewHandler.dboBuilder.prostgles.keywords;
|
|
49
|
+
|
|
50
|
+
if (localParams?.isRemoteRequest && !tableRule) {
|
|
51
|
+
throw "Unexpected: localParams isRemoteRequest and missing tableRule";
|
|
52
|
+
}
|
|
42
53
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
const source = await getQuerySource(
|
|
55
|
+
viewHandler,
|
|
56
|
+
selectParams ? tableRule : undefined,
|
|
57
|
+
filter ?? {},
|
|
58
|
+
selectParams ?? {},
|
|
59
|
+
tableAlias,
|
|
60
|
+
);
|
|
46
61
|
|
|
47
62
|
const exists: ExistsFilterConfig[] = [];
|
|
48
63
|
|
|
49
64
|
type FilterItemResult = { condition: string; columnsUsed: string[] };
|
|
50
65
|
const parseFullFilter = async (
|
|
51
|
-
|
|
66
|
+
fullFilter: any,
|
|
52
67
|
parentFilter: AnyObject | null = null,
|
|
53
68
|
isForcedFilterBypass: boolean,
|
|
54
69
|
): Promise<FilterItemResult | undefined> => {
|
|
55
|
-
if (!
|
|
56
|
-
if (!isObject(
|
|
70
|
+
if (!fullFilter) throw "Invalid/missing group filter provided";
|
|
71
|
+
if (!isObject(fullFilter))
|
|
72
|
+
throw "\nInvalid filter\nExpecting an object but got -> " + JSON.stringify(fullFilter);
|
|
57
73
|
|
|
58
|
-
const keys = getKeys(
|
|
74
|
+
const keys = getKeys(fullFilter);
|
|
59
75
|
if (!keys.length) {
|
|
60
76
|
return;
|
|
61
77
|
}
|
|
@@ -66,8 +82,8 @@ export async function prepareWhere(
|
|
|
66
82
|
throw "group filter ($and/$or) can only be placed at the root or within another group filter";
|
|
67
83
|
}
|
|
68
84
|
|
|
69
|
-
const { [$and_key]: $and, [$or_key]: $or } =
|
|
70
|
-
|
|
85
|
+
const { [$and_key]: $and, [$or_key]: $or } = fullFilter;
|
|
86
|
+
const group = ($and || $or) as AnyObject[] | undefined;
|
|
71
87
|
|
|
72
88
|
if (group && group.length) {
|
|
73
89
|
const operand = $and ? " AND " : " OR ";
|
|
@@ -82,20 +98,24 @@ export async function prepareWhere(
|
|
|
82
98
|
if (conditionItems.length) {
|
|
83
99
|
const conditions = conditionItems.map((c) => c.condition);
|
|
84
100
|
const columnsUsed = conditionItems.map((c) => c.columnsUsed).flat();
|
|
85
|
-
if (conditions.length === 1)
|
|
86
|
-
|
|
101
|
+
if (conditions.length === 1) {
|
|
102
|
+
return { columnsUsed, condition: conditions.join(operand) };
|
|
103
|
+
}
|
|
104
|
+
return { columnsUsed, condition: ` ( ${conditions.sort().join(operand)} ) ` };
|
|
87
105
|
}
|
|
88
106
|
} else if (!group) {
|
|
89
107
|
/** forcedFilters do not get checked against publish and are treated as server-side requests */
|
|
90
|
-
const itemInfo = await getCondition.bind(
|
|
91
|
-
filter: { ...
|
|
108
|
+
const itemInfo = await getCondition.bind(viewHandler)({
|
|
109
|
+
filter: { ...fullFilter },
|
|
92
110
|
select,
|
|
93
111
|
allowed_colnames:
|
|
94
|
-
isForcedFilterBypass ?
|
|
95
|
-
|
|
112
|
+
isForcedFilterBypass ?
|
|
113
|
+
viewHandler.column_names.slice(0)
|
|
114
|
+
: viewHandler.parseFieldFilter(filterFields),
|
|
115
|
+
tableAlias: source.alias,
|
|
96
116
|
localParams: isForcedFilterBypass ? undefined : localParams,
|
|
97
117
|
tableRules: isForcedFilterBypass ? undefined : tableRule,
|
|
98
|
-
isHaving
|
|
118
|
+
isHaving,
|
|
99
119
|
});
|
|
100
120
|
exists.push(...itemInfo.exists);
|
|
101
121
|
return {
|
|
@@ -135,5 +155,6 @@ export async function prepareWhere(
|
|
|
135
155
|
where: combinedConditions || "",
|
|
136
156
|
filter: finalFilter,
|
|
137
157
|
exists,
|
|
158
|
+
source,
|
|
138
159
|
};
|
|
139
|
-
}
|
|
160
|
+
};
|