@payloadcms/drizzle 3.24.0-canary.4c8cafd → 3.24.0-canary.58e9eb5
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/dist/find/traverseFields.d.ts +2 -2
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +216 -89
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/postgres/countDistinct.d.ts.map +1 -1
- package/dist/postgres/countDistinct.js +14 -13
- package/dist/postgres/countDistinct.js.map +1 -1
- package/dist/queries/buildAndOrConditions.d.ts +2 -1
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +2 -1
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildOrderBy.d.ts +2 -1
- package/dist/queries/buildOrderBy.d.ts.map +1 -1
- package/dist/queries/buildOrderBy.js +2 -1
- package/dist/queries/buildOrderBy.js.map +1 -1
- package/dist/queries/buildQuery.d.ts +2 -1
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +3 -1
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +2 -1
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +52 -27
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/parseParams.d.ts +2 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +3 -1
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/schema/build.d.ts +2 -1
- package/dist/schema/build.d.ts.map +1 -1
- package/dist/schema/build.js +2 -1
- package/dist/schema/build.js.map +1 -1
- package/dist/schema/buildRawSchema.d.ts.map +1 -1
- package/dist/schema/buildRawSchema.js +4 -0
- package/dist/schema/buildRawSchema.js.map +1 -1
- package/dist/schema/traverseFields.d.ts +2 -1
- package/dist/schema/traverseFields.d.ts.map +1 -1
- package/dist/schema/traverseFields.js +30 -15
- package/dist/schema/traverseFields.js.map +1 -1
- package/dist/transform/read/index.d.ts +2 -1
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +2 -1
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +2 -1
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +33 -16
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +2 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +7 -2
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +2 -1
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +7 -2
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts +2 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +2 -1
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +2 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +22 -12
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/utilities/hasLocalesTable.d.ts +7 -1
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.js +14 -5
- package/dist/utilities/hasLocalesTable.js.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts +5 -1
- package/dist/utilities/validateExistingBlockIsIdentical.d.ts.map +1 -1
- package/dist/utilities/validateExistingBlockIsIdentical.js +22 -7
- package/dist/utilities/validateExistingBlockIsIdentical.js.map +1 -1
- package/package.json +4 -4
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import { count, sql } from 'drizzle-orm';
|
|
2
2
|
import { chainMethods } from '../find/chainMethods.js';
|
|
3
3
|
export const countDistinct = async function countDistinct({ db, joins, tableName, where }) {
|
|
4
|
+
// When we don't have any joins - use a simple COUNT(*) query.
|
|
5
|
+
if (joins.length === 0) {
|
|
6
|
+
const countResult = await db.select({
|
|
7
|
+
count: count()
|
|
8
|
+
}).from(this.tables[tableName]).where(where);
|
|
9
|
+
return Number(countResult[0].count);
|
|
10
|
+
}
|
|
4
11
|
const chainedMethods = [];
|
|
5
|
-
|
|
6
|
-
const visitedPaths = new Set([]);
|
|
7
|
-
let useDistinct = false;
|
|
8
|
-
joins.forEach(({ condition, queryPath, table })=>{
|
|
9
|
-
if (!useDistinct && queryPath) {
|
|
10
|
-
if (visitedPaths.has(queryPath)) {
|
|
11
|
-
useDistinct = true;
|
|
12
|
-
} else {
|
|
13
|
-
visitedPaths.add(queryPath);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
12
|
+
joins.forEach(({ condition, table })=>{
|
|
16
13
|
chainedMethods.push({
|
|
17
14
|
args: [
|
|
18
15
|
table,
|
|
@@ -21,11 +18,15 @@ export const countDistinct = async function countDistinct({ db, joins, tableName
|
|
|
21
18
|
method: 'leftJoin'
|
|
22
19
|
});
|
|
23
20
|
});
|
|
21
|
+
// When we have any joins, we need to count each individual ID only once.
|
|
22
|
+
// COUNT(*) doesn't work for this well in this case, as it also counts joined tables.
|
|
23
|
+
// SELECT (COUNT DISTINCT id) has a very slow performance on large tables.
|
|
24
|
+
// Instead, COUNT (GROUP BY id) can be used which is still slower than COUNT(*) but acceptable.
|
|
24
25
|
const countResult = await chainMethods({
|
|
25
26
|
methods: chainedMethods,
|
|
26
27
|
query: db.select({
|
|
27
|
-
count:
|
|
28
|
-
}).from(this.tables[tableName]).where(where)
|
|
28
|
+
count: sql`COUNT(1) OVER()`
|
|
29
|
+
}).from(this.tables[tableName]).where(where).groupBy(this.tables[tableName].id).limit(1)
|
|
29
30
|
});
|
|
30
31
|
return Number(countResult[0].count);
|
|
31
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/postgres/countDistinct.ts"],"sourcesContent":["import { count, sql } from 'drizzle-orm'\n\nimport type { ChainedMethods
|
|
1
|
+
{"version":3,"sources":["../../src/postgres/countDistinct.ts"],"sourcesContent":["import { count, sql } from 'drizzle-orm'\n\nimport type { ChainedMethods } from '../types.js'\nimport type { BasePostgresAdapter, CountDistinct } from './types.js'\n\nimport { chainMethods } from '../find/chainMethods.js'\n\nexport const countDistinct: CountDistinct = async function countDistinct(\n this: BasePostgresAdapter,\n { db, joins, tableName, where },\n) {\n // When we don't have any joins - use a simple COUNT(*) query.\n if (joins.length === 0) {\n const countResult = await db\n .select({\n count: count(),\n })\n .from(this.tables[tableName])\n .where(where)\n return Number(countResult[0].count)\n }\n\n const chainedMethods: ChainedMethods = []\n\n joins.forEach(({ condition, table }) => {\n chainedMethods.push({\n args: [table, condition],\n method: 'leftJoin',\n })\n })\n\n // When we have any joins, we need to count each individual ID only once.\n // COUNT(*) doesn't work for this well in this case, as it also counts joined tables.\n // SELECT (COUNT DISTINCT id) has a very slow performance on large tables.\n // Instead, COUNT (GROUP BY id) can be used which is still slower than COUNT(*) but acceptable.\n const countResult = await chainMethods({\n methods: chainedMethods,\n query: db\n .select({\n count: sql`COUNT(1) OVER()`,\n })\n .from(this.tables[tableName])\n .where(where)\n .groupBy(this.tables[tableName].id)\n .limit(1),\n })\n\n return Number(countResult[0].count)\n}\n"],"names":["count","sql","chainMethods","countDistinct","db","joins","tableName","where","length","countResult","select","from","tables","Number","chainedMethods","forEach","condition","table","push","args","method","methods","query","groupBy","id","limit"],"mappings":"AAAA,SAASA,KAAK,EAAEC,GAAG,QAAQ,cAAa;AAKxC,SAASC,YAAY,QAAQ,0BAAyB;AAEtD,OAAO,MAAMC,gBAA+B,eAAeA,cAEzD,EAAEC,EAAE,EAAEC,KAAK,EAAEC,SAAS,EAAEC,KAAK,EAAE;IAE/B,8DAA8D;IAC9D,IAAIF,MAAMG,MAAM,KAAK,GAAG;QACtB,MAAMC,cAAc,MAAML,GACvBM,MAAM,CAAC;YACNV,OAAOA;QACT,GACCW,IAAI,CAAC,IAAI,CAACC,MAAM,CAACN,UAAU,EAC3BC,KAAK,CAACA;QACT,OAAOM,OAAOJ,WAAW,CAAC,EAAE,CAACT,KAAK;IACpC;IAEA,MAAMc,iBAAiC,EAAE;IAEzCT,MAAMU,OAAO,CAAC,CAAC,EAAEC,SAAS,EAAEC,KAAK,EAAE;QACjCH,eAAeI,IAAI,CAAC;YAClBC,MAAM;gBAACF;gBAAOD;aAAU;YACxBI,QAAQ;QACV;IACF;IAEA,yEAAyE;IACzE,qFAAqF;IACrF,0EAA0E;IAC1E,+FAA+F;IAC/F,MAAMX,cAAc,MAAMP,aAAa;QACrCmB,SAASP;QACTQ,OAAOlB,GACJM,MAAM,CAAC;YACNV,OAAOC,GAAG,CAAC,eAAe,CAAC;QAC7B,GACCU,IAAI,CAAC,IAAI,CAACC,MAAM,CAACN,UAAU,EAC3BC,KAAK,CAACA,OACNgB,OAAO,CAAC,IAAI,CAACX,MAAM,CAACN,UAAU,CAACkB,EAAE,EACjCC,KAAK,CAAC;IACX;IAEA,OAAOZ,OAAOJ,WAAW,CAAC,EAAE,CAACT,KAAK;AACpC,EAAC"}
|
|
@@ -2,7 +2,7 @@ import type { SQL, Table } from 'drizzle-orm';
|
|
|
2
2
|
import type { FlattenedField, Where } from 'payload';
|
|
3
3
|
import type { DrizzleAdapter, GenericColumn } from '../types.js';
|
|
4
4
|
import type { BuildQueryJoinAliases } from './buildQuery.js';
|
|
5
|
-
export declare function buildAndOrConditions({ adapter, aliasTable, fields, joins, locale, selectFields, selectLocale, tableName, where, }: {
|
|
5
|
+
export declare function buildAndOrConditions({ adapter, aliasTable, fields, joins, locale, parentIsLocalized, selectFields, selectLocale, tableName, where, }: {
|
|
6
6
|
adapter: DrizzleAdapter;
|
|
7
7
|
aliasTable?: Table;
|
|
8
8
|
collectionSlug?: string;
|
|
@@ -10,6 +10,7 @@ export declare function buildAndOrConditions({ adapter, aliasTable, fields, join
|
|
|
10
10
|
globalSlug?: string;
|
|
11
11
|
joins: BuildQueryJoinAliases;
|
|
12
12
|
locale?: string;
|
|
13
|
+
parentIsLocalized: boolean;
|
|
13
14
|
selectFields: Record<string, GenericColumn>;
|
|
14
15
|
selectLocale?: boolean;
|
|
15
16
|
tableName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAI5D,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EACN,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,GACN,EAAE;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,EAAE,CAAA;CACf,GAAG,GAAG,EAAE,
|
|
1
|
+
{"version":3,"file":"buildAndOrConditions.d.ts","sourceRoot":"","sources":["../../src/queries/buildAndOrConditions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAI5D,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,UAAU,EACV,MAAM,EACN,KAAK,EACL,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,KAAK,GACN,EAAE;IACD,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,EAAE,CAAA;CACf,GAAG,GAAG,EAAE,CA0BR"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseParams } from './parseParams.js';
|
|
2
|
-
export function buildAndOrConditions({ adapter, aliasTable, fields, joins, locale, selectFields, selectLocale, tableName, where }) {
|
|
2
|
+
export function buildAndOrConditions({ adapter, aliasTable, fields, joins, locale, parentIsLocalized, selectFields, selectLocale, tableName, where }) {
|
|
3
3
|
const completedConditions = [];
|
|
4
4
|
// Loop over all AND / OR operations and add them to the AND / OR query param
|
|
5
5
|
// Operations should come through as an array
|
|
@@ -12,6 +12,7 @@ export function buildAndOrConditions({ adapter, aliasTable, fields, joins, local
|
|
|
12
12
|
fields,
|
|
13
13
|
joins,
|
|
14
14
|
locale,
|
|
15
|
+
parentIsLocalized,
|
|
15
16
|
selectFields,
|
|
16
17
|
selectLocale,
|
|
17
18
|
tableName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { SQL, Table } from 'drizzle-orm'\nimport type { FlattenedField, Where } from 'payload'\n\nimport type { DrizzleAdapter, GenericColumn } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\nimport { parseParams } from './parseParams.js'\n\nexport function buildAndOrConditions({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n selectFields,\n selectLocale,\n tableName,\n where,\n}: {\n adapter: DrizzleAdapter\n aliasTable?: Table\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n joins: BuildQueryJoinAliases\n locale?: string\n selectFields: Record<string, GenericColumn>\n selectLocale?: boolean\n tableName: string\n where: Where[]\n}): SQL[] {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n const result = parseParams({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n selectFields,\n selectLocale,\n tableName,\n where: condition,\n })\n if (result && Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","adapter","aliasTable","fields","joins","locale","selectFields","selectLocale","tableName","where","completedConditions","condition","result","Object","keys","length","push"],"mappings":"AAMA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,KAAK,
|
|
1
|
+
{"version":3,"sources":["../../src/queries/buildAndOrConditions.ts"],"sourcesContent":["import type { SQL, Table } from 'drizzle-orm'\nimport type { FlattenedField, Where } from 'payload'\n\nimport type { DrizzleAdapter, GenericColumn } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\nimport { parseParams } from './parseParams.js'\n\nexport function buildAndOrConditions({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n parentIsLocalized,\n selectFields,\n selectLocale,\n tableName,\n where,\n}: {\n adapter: DrizzleAdapter\n aliasTable?: Table\n collectionSlug?: string\n fields: FlattenedField[]\n globalSlug?: string\n joins: BuildQueryJoinAliases\n locale?: string\n parentIsLocalized: boolean\n selectFields: Record<string, GenericColumn>\n selectLocale?: boolean\n tableName: string\n where: Where[]\n}): SQL[] {\n const completedConditions = []\n // Loop over all AND / OR operations and add them to the AND / OR query param\n // Operations should come through as an array\n\n for (const condition of where) {\n // If the operation is properly formatted as an object\n if (typeof condition === 'object') {\n const result = parseParams({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n parentIsLocalized,\n selectFields,\n selectLocale,\n tableName,\n where: condition,\n })\n if (result && Object.keys(result).length > 0) {\n completedConditions.push(result)\n }\n }\n }\n return completedConditions\n}\n"],"names":["parseParams","buildAndOrConditions","adapter","aliasTable","fields","joins","locale","parentIsLocalized","selectFields","selectLocale","tableName","where","completedConditions","condition","result","Object","keys","length","push"],"mappings":"AAMA,SAASA,WAAW,QAAQ,mBAAkB;AAE9C,OAAO,SAASC,qBAAqB,EACnCC,OAAO,EACPC,UAAU,EACVC,MAAM,EACNC,KAAK,EACLC,MAAM,EACNC,iBAAiB,EACjBC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,KAAK,EAcN;IACC,MAAMC,sBAAsB,EAAE;IAC9B,6EAA6E;IAC7E,6CAA6C;IAE7C,KAAK,MAAMC,aAAaF,MAAO;QAC7B,sDAAsD;QACtD,IAAI,OAAOE,cAAc,UAAU;YACjC,MAAMC,SAASd,YAAY;gBACzBE;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC;gBACAC,OAAOE;YACT;YACA,IAAIC,UAAUC,OAAOC,IAAI,CAACF,QAAQG,MAAM,GAAG,GAAG;gBAC5CL,oBAAoBM,IAAI,CAACJ;YAC3B;QACF;IACF;IACA,OAAOF;AACT"}
|
|
@@ -8,6 +8,7 @@ type Args = {
|
|
|
8
8
|
fields: FlattenedField[];
|
|
9
9
|
joins: BuildQueryJoinAliases;
|
|
10
10
|
locale?: string;
|
|
11
|
+
parentIsLocalized: boolean;
|
|
11
12
|
selectFields: Record<string, GenericColumn>;
|
|
12
13
|
sort?: Sort;
|
|
13
14
|
tableName: string;
|
|
@@ -15,6 +16,6 @@ type Args = {
|
|
|
15
16
|
/**
|
|
16
17
|
* Gets the order by column and direction constructed from the sort argument adds the column to the select fields and joins if necessary
|
|
17
18
|
*/
|
|
18
|
-
export declare const buildOrderBy: ({ adapter, aliasTable, fields, joins, locale, selectFields, sort, tableName, }: Args) => BuildQueryResult["orderBy"];
|
|
19
|
+
export declare const buildOrderBy: ({ adapter, aliasTable, fields, joins, locale, parentIsLocalized, selectFields, sort, tableName, }: Args) => BuildQueryResult["orderBy"];
|
|
19
20
|
export {};
|
|
20
21
|
//# sourceMappingURL=buildOrderBy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildOrderBy.d.ts","sourceRoot":"","sources":["../../src/queries/buildOrderBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAK9E,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"buildOrderBy.d.ts","sourceRoot":"","sources":["../../src/queries/buildOrderBy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAInD,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAK9E,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,YAAY,sGAUtB,IAAI,KAAG,gBAAgB,CAAC,SAAS,CAwDnC,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { getNameFromDrizzleTable } from '../utilities/getNameFromDrizzleTable.js
|
|
|
3
3
|
import { getTableColumnFromPath } from './getTableColumnFromPath.js';
|
|
4
4
|
/**
|
|
5
5
|
* Gets the order by column and direction constructed from the sort argument adds the column to the select fields and joins if necessary
|
|
6
|
-
*/ export const buildOrderBy = ({ adapter, aliasTable, fields, joins, locale, selectFields, sort, tableName })=>{
|
|
6
|
+
*/ export const buildOrderBy = ({ adapter, aliasTable, fields, joins, locale, parentIsLocalized, selectFields, sort, tableName })=>{
|
|
7
7
|
const orderBy = [];
|
|
8
8
|
if (!sort) {
|
|
9
9
|
const createdAt = adapter.tables[tableName]?.createdAt;
|
|
@@ -35,6 +35,7 @@ import { getTableColumnFromPath } from './getTableColumnFromPath.js';
|
|
|
35
35
|
fields,
|
|
36
36
|
joins,
|
|
37
37
|
locale,
|
|
38
|
+
parentIsLocalized,
|
|
38
39
|
pathSegments: sortProperty.replace(/__/g, '.').split('.'),
|
|
39
40
|
selectFields,
|
|
40
41
|
tableName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildOrderBy.ts"],"sourcesContent":["import type { Table } from 'drizzle-orm'\nimport type { FlattenedField, Sort } from 'payload'\n\nimport { asc, desc } from 'drizzle-orm'\n\nimport type { DrizzleAdapter, GenericColumn } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryResult } from './buildQuery.js'\n\nimport { getNameFromDrizzleTable } from '../utilities/getNameFromDrizzleTable.js'\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n aliasTable?: Table\n fields: FlattenedField[]\n joins: BuildQueryJoinAliases\n locale?: string\n selectFields: Record<string, GenericColumn>\n sort?: Sort\n tableName: string\n}\n\n/**\n * Gets the order by column and direction constructed from the sort argument adds the column to the select fields and joins if necessary\n */\nexport const buildOrderBy = ({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n selectFields,\n sort,\n tableName,\n}: Args): BuildQueryResult['orderBy'] => {\n const orderBy: BuildQueryResult['orderBy'] = []\n\n if (!sort) {\n const createdAt = adapter.tables[tableName]?.createdAt\n if (createdAt) {\n sort = '-createdAt'\n } else {\n sort = '-id'\n }\n }\n\n if (typeof sort === 'string') {\n sort = [sort]\n }\n\n for (const sortItem of sort) {\n let sortProperty: string\n let sortDirection: 'asc' | 'desc'\n if (sortItem[0] === '-') {\n sortProperty = sortItem.substring(1)\n sortDirection = 'desc'\n } else {\n sortProperty = sortItem\n sortDirection = 'asc'\n }\n try {\n const { columnName: sortTableColumnName, table: sortTable } = getTableColumnFromPath({\n adapter,\n collectionPath: sortProperty,\n fields,\n joins,\n locale,\n pathSegments: sortProperty.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: sortProperty,\n })\n if (sortTable?.[sortTableColumnName]) {\n orderBy.push({\n column:\n aliasTable && tableName === getNameFromDrizzleTable(sortTable)\n ? aliasTable[sortTableColumnName]\n : sortTable[sortTableColumnName],\n order: sortDirection === 'asc' ? asc : desc,\n })\n\n selectFields[sortTableColumnName] = sortTable[sortTableColumnName]\n }\n } catch (err) {\n // continue\n }\n }\n\n return orderBy\n}\n"],"names":["asc","desc","getNameFromDrizzleTable","getTableColumnFromPath","buildOrderBy","adapter","aliasTable","fields","joins","locale","selectFields","sort","tableName","orderBy","createdAt","tables","sortItem","sortProperty","sortDirection","substring","columnName","sortTableColumnName","table","sortTable","collectionPath","pathSegments","replace","split","value","push","column","order","err"],"mappings":"AAGA,SAASA,GAAG,EAAEC,IAAI,QAAQ,cAAa;AAKvC,SAASC,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,sBAAsB,QAAQ,8BAA6B;
|
|
1
|
+
{"version":3,"sources":["../../src/queries/buildOrderBy.ts"],"sourcesContent":["import type { Table } from 'drizzle-orm'\nimport type { FlattenedField, Sort } from 'payload'\n\nimport { asc, desc } from 'drizzle-orm'\n\nimport type { DrizzleAdapter, GenericColumn } from '../types.js'\nimport type { BuildQueryJoinAliases, BuildQueryResult } from './buildQuery.js'\n\nimport { getNameFromDrizzleTable } from '../utilities/getNameFromDrizzleTable.js'\nimport { getTableColumnFromPath } from './getTableColumnFromPath.js'\n\ntype Args = {\n adapter: DrizzleAdapter\n aliasTable?: Table\n fields: FlattenedField[]\n joins: BuildQueryJoinAliases\n locale?: string\n parentIsLocalized: boolean\n selectFields: Record<string, GenericColumn>\n sort?: Sort\n tableName: string\n}\n\n/**\n * Gets the order by column and direction constructed from the sort argument adds the column to the select fields and joins if necessary\n */\nexport const buildOrderBy = ({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n parentIsLocalized,\n selectFields,\n sort,\n tableName,\n}: Args): BuildQueryResult['orderBy'] => {\n const orderBy: BuildQueryResult['orderBy'] = []\n\n if (!sort) {\n const createdAt = adapter.tables[tableName]?.createdAt\n if (createdAt) {\n sort = '-createdAt'\n } else {\n sort = '-id'\n }\n }\n\n if (typeof sort === 'string') {\n sort = [sort]\n }\n\n for (const sortItem of sort) {\n let sortProperty: string\n let sortDirection: 'asc' | 'desc'\n if (sortItem[0] === '-') {\n sortProperty = sortItem.substring(1)\n sortDirection = 'desc'\n } else {\n sortProperty = sortItem\n sortDirection = 'asc'\n }\n try {\n const { columnName: sortTableColumnName, table: sortTable } = getTableColumnFromPath({\n adapter,\n collectionPath: sortProperty,\n fields,\n joins,\n locale,\n parentIsLocalized,\n pathSegments: sortProperty.replace(/__/g, '.').split('.'),\n selectFields,\n tableName,\n value: sortProperty,\n })\n if (sortTable?.[sortTableColumnName]) {\n orderBy.push({\n column:\n aliasTable && tableName === getNameFromDrizzleTable(sortTable)\n ? aliasTable[sortTableColumnName]\n : sortTable[sortTableColumnName],\n order: sortDirection === 'asc' ? asc : desc,\n })\n\n selectFields[sortTableColumnName] = sortTable[sortTableColumnName]\n }\n } catch (err) {\n // continue\n }\n }\n\n return orderBy\n}\n"],"names":["asc","desc","getNameFromDrizzleTable","getTableColumnFromPath","buildOrderBy","adapter","aliasTable","fields","joins","locale","parentIsLocalized","selectFields","sort","tableName","orderBy","createdAt","tables","sortItem","sortProperty","sortDirection","substring","columnName","sortTableColumnName","table","sortTable","collectionPath","pathSegments","replace","split","value","push","column","order","err"],"mapp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QACF,EAAE,OAAOW,KAAK;QACZ,WAAW;QACb;IACF;IAEA,OAAOnB;AACT,EAAC"}
|
|
@@ -14,6 +14,7 @@ type BuildQueryArgs = {
|
|
|
14
14
|
fields: FlattenedField[];
|
|
15
15
|
joins?: BuildQueryJoinAliases;
|
|
16
16
|
locale?: string;
|
|
17
|
+
parentIsLocalized?: boolean;
|
|
17
18
|
selectLocale?: boolean;
|
|
18
19
|
sort?: Sort;
|
|
19
20
|
tableName: string;
|
|
@@ -28,6 +29,6 @@ export type BuildQueryResult = {
|
|
|
28
29
|
selectFields: Record<string, GenericColumn>;
|
|
29
30
|
where: SQL;
|
|
30
31
|
};
|
|
31
|
-
declare const buildQuery: ({ adapter, aliasTable, fields, joins, locale, selectLocale, sort, tableName, where: incomingWhere, }: BuildQueryArgs) => BuildQueryResult;
|
|
32
|
+
declare const buildQuery: ({ adapter, aliasTable, fields, joins, locale, parentIsLocalized, selectLocale, sort, tableName, where: incomingWhere, }: BuildQueryArgs) => BuildQueryResult;
|
|
32
33
|
export default buildQuery;
|
|
33
34
|
//# sourceMappingURL=buildQuery.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildQuery.d.ts","sourceRoot":"","sources":["../../src/queries/buildQuery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAE1D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAK9E,MAAM,MAAM,qBAAqB,GAAG;IAClC,SAAS,EAAE,GAAG,CAAA;IACd,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,YAAY,GAA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SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,YAAY,GAAG,kBAAkB,CAAC,GAAG,CAAC,CAAA;IAC7C,IAAI,CAAC,EAAE,WAAW,GAAG,UAAU,GAAG,WAAW,CAAA;CAC9C,EAAE,CAAA;AAEH,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAA;IAClB,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,KAAK,CAAC,EAAE,qBAAqB,CAAA;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE,KAAK,CAAA;CACb,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,EAAE,qBAAqB,CAAA;IAC5B,OAAO,EAAE;QACP,MAAM,EAAE,aAAa,CAAA;QACrB,KAAK,EAAE,OAAO,GAAG,GAAG,OAAO,IAAI,CAAA;KAChC,EAAE,CAAA;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AACD,QAAA,MAAM,UAAU,4HAWb,cAAc,KAAG,gBAwCnB,CAAA;AAED,eAAe,UAAU,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildOrderBy } from './buildOrderBy.js';
|
|
2
2
|
import { parseParams } from './parseParams.js';
|
|
3
|
-
const buildQuery = function buildQuery({ adapter, aliasTable, fields, joins = [], locale, selectLocale, sort, tableName, where: incomingWhere }) {
|
|
3
|
+
const buildQuery = function buildQuery({ adapter, aliasTable, fields, joins = [], locale, parentIsLocalized, selectLocale, sort, tableName, where: incomingWhere }) {
|
|
4
4
|
const selectFields = {
|
|
5
5
|
id: adapter.tables[tableName].id
|
|
6
6
|
};
|
|
@@ -10,6 +10,7 @@ const buildQuery = function buildQuery({ adapter, aliasTable, fields, joins = []
|
|
|
10
10
|
fields,
|
|
11
11
|
joins,
|
|
12
12
|
locale,
|
|
13
|
+
parentIsLocalized,
|
|
13
14
|
selectFields,
|
|
14
15
|
sort,
|
|
15
16
|
tableName
|
|
@@ -22,6 +23,7 @@ const buildQuery = function buildQuery({ adapter, aliasTable, fields, joins = []
|
|
|
22
23
|
fields,
|
|
23
24
|
joins,
|
|
24
25
|
locale,
|
|
26
|
+
parentIsLocalized,
|
|
25
27
|
selectFields,
|
|
26
28
|
selectLocale,
|
|
27
29
|
tableName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { asc, desc, SQL, Table } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { FlattenedField, Sort, Where } from 'payload'\n\nimport type { DrizzleAdapter, GenericColumn, GenericTable } from '../types.js'\n\nimport { buildOrderBy } from './buildOrderBy.js'\nimport { parseParams } from './parseParams.js'\n\nexport type BuildQueryJoinAliases = {\n condition: SQL\n queryPath?: string\n table: GenericTable | PgTableWithColumns<any>\n type?: 'innerJoin' | 'leftJoin' | 'rightJoin'\n}[]\n\ntype BuildQueryArgs = {\n adapter: DrizzleAdapter\n aliasTable?: Table\n fields: FlattenedField[]\n joins?: BuildQueryJoinAliases\n locale?: string\n selectLocale?: boolean\n sort?: Sort\n tableName: string\n where: Where\n}\n\nexport type BuildQueryResult = {\n joins: BuildQueryJoinAliases\n orderBy: {\n column: GenericColumn\n order: typeof asc | typeof desc\n }[]\n selectFields: Record<string, GenericColumn>\n where: SQL\n}\nconst buildQuery = function buildQuery({\n adapter,\n aliasTable,\n fields,\n joins = [],\n locale,\n selectLocale,\n sort,\n tableName,\n where: incomingWhere,\n}: BuildQueryArgs): BuildQueryResult {\n const selectFields: Record<string, GenericColumn> = {\n id: adapter.tables[tableName].id,\n }\n\n const orderBy = buildOrderBy({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n selectFields,\n sort,\n tableName,\n })\n\n let where: SQL\n\n if (incomingWhere && Object.keys(incomingWhere).length > 0) {\n where = parseParams({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n selectFields,\n selectLocale,\n tableName,\n where: incomingWhere,\n })\n }\n\n return {\n joins,\n orderBy,\n selectFields,\n where,\n }\n}\n\nexport default buildQuery\n"],"names":["buildOrderBy","parseParams","buildQuery","adapter","aliasTable","fields","joins","locale","selectLocale","sort","tableName","where","incomingWhere","selectFields","id","tables","orderBy","Object","keys","length"],"mappings":"AAMA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,WAAW,QAAQ,mBAAkB;
|
|
1
|
+
{"version":3,"sources":["../../src/queries/buildQuery.ts"],"sourcesContent":["import type { asc, desc, SQL, Table } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { FlattenedField, Sort, Where } from 'payload'\n\nimport type { DrizzleAdapter, GenericColumn, GenericTable } from '../types.js'\n\nimport { buildOrderBy } from './buildOrderBy.js'\nimport { parseParams } from './parseParams.js'\n\nexport type BuildQueryJoinAliases = {\n condition: SQL\n queryPath?: string\n table: GenericTable | PgTableWithColumns<any>\n type?: 'innerJoin' | 'leftJoin' | 'rightJoin'\n}[]\n\ntype BuildQueryArgs = {\n adapter: DrizzleAdapter\n aliasTable?: Table\n fields: FlattenedField[]\n joins?: BuildQueryJoinAliases\n locale?: string\n parentIsLocalized?: boolean\n selectLocale?: boolean\n sort?: Sort\n tableName: string\n where: Where\n}\n\nexport type BuildQueryResult = {\n joins: BuildQueryJoinAliases\n orderBy: {\n column: GenericColumn\n order: typeof asc | typeof desc\n }[]\n selectFields: Record<string, GenericColumn>\n where: SQL\n}\nconst buildQuery = function buildQuery({\n adapter,\n aliasTable,\n fields,\n joins = [],\n locale,\n parentIsLocalized,\n selectLocale,\n sort,\n tableName,\n where: incomingWhere,\n}: BuildQueryArgs): BuildQueryResult {\n const selectFields: Record<string, GenericColumn> = {\n id: adapter.tables[tableName].id,\n }\n\n const orderBy = buildOrderBy({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n parentIsLocalized,\n selectFields,\n sort,\n tableName,\n })\n\n let where: SQL\n\n if (incomingWhere && Object.keys(incomingWhere).length > 0) {\n where = parseParams({\n adapter,\n aliasTable,\n fields,\n joins,\n locale,\n parentIsLocalized,\n selectFields,\n selectLocale,\n tableName,\n where: incomingWhere,\n })\n }\n\n return {\n joins,\n orderBy,\n selectFields,\n where,\n }\n}\n\nexport default buildQuery\n"],"names":["buildOrderBy","parseParams","buildQuery","adapter","aliasTable","fields","joins","locale","parentIsLocalized","selectLocale","sort","tableName","where","incomingWhere","selectFields","id","tables","orderBy","Object","keys","length"],"mappings":"AAMA,SAASA,YAAY,QAAQ,oBAAmB;AAChD,SAASC,WAAW,QAAQ,mBAAkB;AA+B9C,MAAMC,aAAa,SAASA,WAAW,EACrCC,OAAO,EACPC,UAAU,EACVC,MAAM,EACNC,QAAQ,EAAE,EACVC,MAAM,EACNC,iBAAiB,EACjBC,YAAY,EACZC,IAAI,EACJC,SAAS,EACTC,OAAOC,aAAa,EACL;IACf,MAAMC,eAA8C;QAClDC,IAAIZ,QAAQa,MAAM,CAACL,UAAU,CAACI,EAAE;IAClC;IAEA,MAAME,UAAUjB,aAAa;QAC3BG;QACAC;QACAC;QACAC;QACAC;QACAC;QACAM;QACAJ;QACAC;IACF;IAEA,IAAIC;IAEJ,IAAIC,iBAAiBK,OAAOC,IAAI,CAACN,eAAeO,MAAM,GAAG,GAAG;QAC1DR,QAAQX,YAAY;YAClBE;YACAC;YACAC;YACAC;YACAC;YACAC;YACAM;YACAL;YACAE;YACAC,OAAOC;QACT;IACF;IAEA,OAAO;QACLP;QACAW;QACAH;QACAF;IACF;AACF;AAEA,eAAeV,WAAU"}
|
|
@@ -32,6 +32,7 @@ type Args = {
|
|
|
32
32
|
fields: FlattenedField[];
|
|
33
33
|
joins: BuildQueryJoinAliases;
|
|
34
34
|
locale?: string;
|
|
35
|
+
parentIsLocalized: boolean;
|
|
35
36
|
pathSegments: string[];
|
|
36
37
|
rootTableName?: string;
|
|
37
38
|
selectFields: Record<string, GenericColumn>;
|
|
@@ -51,6 +52,6 @@ type Args = {
|
|
|
51
52
|
* Adds tables to `join`
|
|
52
53
|
* @returns TableColumn
|
|
53
54
|
*/
|
|
54
|
-
export declare const getTableColumnFromPath: ({ adapter, aliasTable, collectionPath, columnPrefix, constraintPath: incomingConstraintPath, constraints, fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, selectLocale, tableName, tableNameSuffix, value, }: Args) => TableColumn;
|
|
55
|
+
export declare const getTableColumnFromPath: ({ adapter, aliasTable, collectionPath, columnPrefix, constraintPath: incomingConstraintPath, constraints, fields, joins, locale: incomingLocale, parentIsLocalized, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, selectLocale, tableName, tableNameSuffix, value, }: Args) => TableColumn;
|
|
55
56
|
export {};
|
|
56
57
|
//# sourceMappingURL=getTableColumnFromPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTableColumnFromPath.d.ts","sourceRoot":"","sources":["../../src/queries/getTableColumnFromPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,KAAK,EAAkB,cAAc,EAA0B,MAAM,SAAS,CAAA;AAGrF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAM7D,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAChE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAM5D,KAAK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f,KAAK,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAA;CAC7D,CAAA;AAED,KAAK,IAAI,GAAG;IACV,OAAO,EAAE,cAAc,CAAA;IACvB,UAAU,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAA;IAClE,cAAc,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,WAAW,CAAC,EAAE,UAAU,EAAE,CAAA;IAC1B,MAAM,EAAE,cAAc,EAAE,CAAA;IACxB,KAAK,EAAE,qBAAqB,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,OAAO,CAAA;IAC1B,YAAY,EAAE,MAAM,EAAE,CAAA;IACtB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB;;OAEG;IACH,KAAK,EAAE,OAAO,CAAA;CACf,CAAA;AACD;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,+SAkBhC,IAAI,KAAG,WAwrBT,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { and, eq, like, sql } from 'drizzle-orm';
|
|
2
2
|
import { APIError } from 'payload';
|
|
3
|
-
import { tabHasName } from 'payload/shared';
|
|
3
|
+
import { fieldShouldBeLocalized, tabHasName } from 'payload/shared';
|
|
4
4
|
import toSnakeCase from 'to-snake-case';
|
|
5
5
|
import { validate as uuidValidate } from 'uuid';
|
|
6
6
|
import { isPolymorphicRelationship } from '../utilities/isPolymorphicRelationship.js';
|
|
@@ -10,7 +10,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
10
10
|
* Transforms path to table and column name or to a list of OR columns
|
|
11
11
|
* Adds tables to `join`
|
|
12
12
|
* @returns TableColumn
|
|
13
|
-
*/ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, selectLocale, tableName, tableNameSuffix = '', value })=>{
|
|
13
|
+
*/ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joins, locale: incomingLocale, parentIsLocalized, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, selectLocale, tableName, tableNameSuffix = '', value })=>{
|
|
14
14
|
const fieldPath = incomingSegments[0];
|
|
15
15
|
let locale = incomingLocale;
|
|
16
16
|
const rootTableName = incomingRootTableName || tableName;
|
|
@@ -33,9 +33,13 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
33
33
|
const pathSegments = [
|
|
34
34
|
...incomingSegments
|
|
35
35
|
];
|
|
36
|
+
const isFieldLocalized = fieldShouldBeLocalized({
|
|
37
|
+
field,
|
|
38
|
+
parentIsLocalized
|
|
39
|
+
});
|
|
36
40
|
// If next segment is a locale,
|
|
37
41
|
// we need to take it out and use it as the locale from this point on
|
|
38
|
-
if (
|
|
42
|
+
if (isFieldLocalized && adapter.payload.config.localization) {
|
|
39
43
|
const matchedLocale = adapter.payload.config.localization.localeCodes.find((locale)=>locale === pathSegments[1]);
|
|
40
44
|
if (matchedLocale) {
|
|
41
45
|
locale = matchedLocale;
|
|
@@ -48,7 +52,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
48
52
|
newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
|
|
49
53
|
const arrayParentTable = aliasTable || adapter.tables[tableName];
|
|
50
54
|
constraintPath = `${constraintPath}${field.name}.%.`;
|
|
51
|
-
if (locale &&
|
|
55
|
+
if (locale && isFieldLocalized && adapter.payload.config.localization) {
|
|
52
56
|
const conditions = [
|
|
53
57
|
eq(arrayParentTable.id, adapter.tables[newTableName]._parentID)
|
|
54
58
|
];
|
|
@@ -78,6 +82,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
78
82
|
fields: field.flattenedFields,
|
|
79
83
|
joins,
|
|
80
84
|
locale,
|
|
85
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
81
86
|
pathSegments: pathSegments.slice(1),
|
|
82
87
|
rootTableName,
|
|
83
88
|
selectFields,
|
|
@@ -127,6 +132,28 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
127
132
|
let result;
|
|
128
133
|
const blockConstraints = [];
|
|
129
134
|
const blockSelectFields = {};
|
|
135
|
+
let blockJoin;
|
|
136
|
+
if (isFieldLocalized && adapter.payload.config.localization) {
|
|
137
|
+
const conditions = [
|
|
138
|
+
eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID)
|
|
139
|
+
];
|
|
140
|
+
if (locale !== 'all') {
|
|
141
|
+
conditions.push(eq(adapter.tables[newTableName]._locale, locale));
|
|
142
|
+
}
|
|
143
|
+
blockJoin = {
|
|
144
|
+
condition: and(...conditions),
|
|
145
|
+
table: adapter.tables[newTableName]
|
|
146
|
+
};
|
|
147
|
+
} else {
|
|
148
|
+
blockJoin = {
|
|
149
|
+
condition: eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID),
|
|
150
|
+
table: adapter.tables[newTableName]
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
// Create a new reference for nested joins
|
|
154
|
+
const newJoins = [
|
|
155
|
+
...joins
|
|
156
|
+
];
|
|
130
157
|
try {
|
|
131
158
|
result = getTableColumnFromPath({
|
|
132
159
|
adapter,
|
|
@@ -134,8 +161,9 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
134
161
|
constraintPath,
|
|
135
162
|
constraints: blockConstraints,
|
|
136
163
|
fields: block.flattenedFields,
|
|
137
|
-
joins,
|
|
164
|
+
joins: newJoins,
|
|
138
165
|
locale,
|
|
166
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
139
167
|
pathSegments: pathSegments.slice(1),
|
|
140
168
|
rootTableName,
|
|
141
169
|
selectFields: blockSelectFields,
|
|
@@ -155,22 +183,13 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
155
183
|
...selectFields,
|
|
156
184
|
...blockSelectFields
|
|
157
185
|
};
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
186
|
+
const previousLength = joins.length;
|
|
187
|
+
joins.push(blockJoin);
|
|
188
|
+
// Append new joins AFTER the block join to prevent errors with missing FROM clause.
|
|
189
|
+
if (newJoins.length > previousLength) {
|
|
190
|
+
for(let i = previousLength; i < newJoins.length; i++){
|
|
191
|
+
joins.push(newJoins[i]);
|
|
164
192
|
}
|
|
165
|
-
joins.push({
|
|
166
|
-
condition: and(...conditions),
|
|
167
|
-
table: adapter.tables[newTableName]
|
|
168
|
-
});
|
|
169
|
-
} else {
|
|
170
|
-
joins.push({
|
|
171
|
-
condition: eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID),
|
|
172
|
-
table: adapter.tables[newTableName]
|
|
173
|
-
});
|
|
174
193
|
}
|
|
175
194
|
return true;
|
|
176
195
|
});
|
|
@@ -188,7 +207,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
188
207
|
}
|
|
189
208
|
case 'group':
|
|
190
209
|
{
|
|
191
|
-
if (locale &&
|
|
210
|
+
if (locale && isFieldLocalized && adapter.payload.config.localization) {
|
|
192
211
|
newTableName = `${tableName}${adapter.localesSuffix}`;
|
|
193
212
|
let condition = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
|
|
194
213
|
if (locale !== 'all') {
|
|
@@ -210,6 +229,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
210
229
|
fields: field.flattenedFields,
|
|
211
230
|
joins,
|
|
212
231
|
locale,
|
|
232
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
213
233
|
pathSegments: pathSegments.slice(1),
|
|
214
234
|
rootTableName,
|
|
215
235
|
selectFields,
|
|
@@ -234,7 +254,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
234
254
|
eq(adapter.tables[rootTableName].id, adapter.tables[newTableName].parent),
|
|
235
255
|
like(adapter.tables[newTableName].path, `${constraintPath}${field.name}`)
|
|
236
256
|
];
|
|
237
|
-
if (locale &&
|
|
257
|
+
if (locale && isFieldLocalized && adapter.payload.config.localization) {
|
|
238
258
|
const conditions = [
|
|
239
259
|
...joinConstraints
|
|
240
260
|
];
|
|
@@ -273,11 +293,11 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
273
293
|
adapter,
|
|
274
294
|
tableName: relationTableName
|
|
275
295
|
});
|
|
276
|
-
if (selectLocale &&
|
|
296
|
+
if (selectLocale && isFieldLocalized && adapter.payload.config.localization) {
|
|
277
297
|
selectFields._locale = aliasRelationshipTable.locale;
|
|
278
298
|
}
|
|
279
299
|
// Join in the relationships table
|
|
280
|
-
if (locale &&
|
|
300
|
+
if (locale && isFieldLocalized && adapter.payload.config.localization) {
|
|
281
301
|
const conditions = [
|
|
282
302
|
eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),
|
|
283
303
|
like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)
|
|
@@ -396,9 +416,11 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
396
416
|
aliasTable: newAliasTable,
|
|
397
417
|
collectionPath: newCollectionPath,
|
|
398
418
|
constraints,
|
|
419
|
+
// relationshipFields are fields from a different collection => no parentIsLocalized
|
|
399
420
|
fields: relationshipFields,
|
|
400
421
|
joins,
|
|
401
422
|
locale,
|
|
423
|
+
parentIsLocalized: false,
|
|
402
424
|
pathSegments: pathSegments.slice(1),
|
|
403
425
|
rootTableName: newTableName,
|
|
404
426
|
selectFields,
|
|
@@ -414,7 +436,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
414
436
|
adapter,
|
|
415
437
|
tableName: newTableName
|
|
416
438
|
});
|
|
417
|
-
if (
|
|
439
|
+
if (isFieldLocalized && adapter.payload.config.localization) {
|
|
418
440
|
const { newAliasTable: aliasLocaleTable } = getTableAlias({
|
|
419
441
|
adapter,
|
|
420
442
|
tableName: `${rootTableName}${adapter.localesSuffix}`
|
|
@@ -453,6 +475,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
453
475
|
fields: adapter.payload.collections[field.relationTo].config.flattenedFields,
|
|
454
476
|
joins,
|
|
455
477
|
locale,
|
|
478
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
456
479
|
pathSegments: pathSegments.slice(1),
|
|
457
480
|
selectFields,
|
|
458
481
|
tableName: newTableName,
|
|
@@ -465,7 +488,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
465
488
|
{
|
|
466
489
|
if (field.hasMany) {
|
|
467
490
|
const newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
|
|
468
|
-
if (locale &&
|
|
491
|
+
if (locale && isFieldLocalized && adapter.payload.config.localization) {
|
|
469
492
|
const conditions = [
|
|
470
493
|
eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
|
|
471
494
|
eq(adapter.tables[newTableName]._locale, locale)
|
|
@@ -507,6 +530,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
507
530
|
fields: field.flattenedFields,
|
|
508
531
|
joins,
|
|
509
532
|
locale,
|
|
533
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
510
534
|
pathSegments: pathSegments.slice(1),
|
|
511
535
|
rootTableName,
|
|
512
536
|
selectFields,
|
|
@@ -526,6 +550,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
526
550
|
fields: field.flattenedFields,
|
|
527
551
|
joins,
|
|
528
552
|
locale,
|
|
553
|
+
parentIsLocalized: parentIsLocalized || field.localized,
|
|
529
554
|
pathSegments: pathSegments.slice(1),
|
|
530
555
|
rootTableName,
|
|
531
556
|
selectFields,
|
|
@@ -541,7 +566,7 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
541
566
|
}
|
|
542
567
|
}
|
|
543
568
|
let newTable = adapter.tables[newTableName];
|
|
544
|
-
if (
|
|
569
|
+
if (isFieldLocalized && adapter.payload.config.localization) {
|
|
545
570
|
// If localized, we go to localized table and set aliasTable to undefined
|
|
546
571
|
// so it is not picked up below to be used as targetTable
|
|
547
572
|
const parentTable = aliasTable || adapter.tables[tableName];
|