@payloadcms/drizzle 3.0.0-canary.f1f97ff → 3.0.0-canary.fb04843
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/count.d.ts.map +1 -1
- package/dist/count.js +1 -1
- package/dist/count.js.map +1 -1
- package/dist/countGlobalVersions.d.ts +3 -0
- package/dist/countGlobalVersions.d.ts.map +1 -0
- package/dist/countGlobalVersions.js +27 -0
- package/dist/countGlobalVersions.js.map +1 -0
- package/dist/countVersions.d.ts +3 -0
- package/dist/countVersions.d.ts.map +1 -0
- package/dist/countVersions.js +27 -0
- package/dist/countVersions.js.map +1 -0
- package/dist/create.d.ts.map +1 -1
- package/dist/create.js +2 -1
- package/dist/create.js.map +1 -1
- package/dist/createGlobalVersion.d.ts +1 -1
- package/dist/createGlobalVersion.d.ts.map +1 -1
- package/dist/createGlobalVersion.js +7 -2
- package/dist/createGlobalVersion.js.map +1 -1
- package/dist/createTableName.d.ts.map +1 -1
- package/dist/createTableName.js +6 -2
- package/dist/createTableName.js.map +1 -1
- package/dist/createVersion.d.ts +1 -1
- package/dist/createVersion.d.ts.map +1 -1
- package/dist/createVersion.js +22 -14
- package/dist/createVersion.js.map +1 -1
- package/dist/deleteOne.d.ts.map +1 -1
- package/dist/deleteOne.js +6 -3
- package/dist/deleteOne.js.map +1 -1
- package/dist/deleteVersions.js +1 -1
- package/dist/deleteVersions.js.map +1 -1
- package/dist/destroy.d.ts.map +1 -1
- package/dist/destroy.js +3 -1
- package/dist/destroy.js.map +1 -1
- package/dist/exports/postgres.d.ts +15 -0
- package/dist/exports/postgres.d.ts.map +1 -0
- package/dist/exports/postgres.js +16 -0
- package/dist/exports/postgres.js.map +1 -0
- package/dist/find/buildFindManyArgs.d.ts +15 -7
- package/dist/find/buildFindManyArgs.d.ts.map +1 -1
- package/dist/find/buildFindManyArgs.js +40 -17
- package/dist/find/buildFindManyArgs.js.map +1 -1
- package/dist/find/findMany.d.ts +2 -1
- package/dist/find/findMany.d.ts.map +1 -1
- package/dist/find/findMany.js +12 -7
- package/dist/find/findMany.js.map +1 -1
- package/dist/find/traverseFields.d.ts +18 -4
- package/dist/find/traverseFields.d.ts.map +1 -1
- package/dist/find/traverseFields.js +359 -69
- package/dist/find/traverseFields.js.map +1 -1
- package/dist/find.d.ts.map +1 -1
- package/dist/find.js +4 -2
- package/dist/find.js.map +1 -1
- package/dist/findGlobal.d.ts.map +1 -1
- package/dist/findGlobal.js +2 -1
- package/dist/findGlobal.js.map +1 -1
- package/dist/findGlobalVersions.d.ts.map +1 -1
- package/dist/findGlobalVersions.js +4 -3
- package/dist/findGlobalVersions.js.map +1 -1
- package/dist/findMigrationDir.d.ts.map +1 -1
- package/dist/findMigrationDir.js +3 -1
- package/dist/findMigrationDir.js.map +1 -1
- package/dist/findOne.d.ts +1 -1
- package/dist/findOne.d.ts.map +1 -1
- package/dist/findOne.js +3 -1
- package/dist/findOne.js.map +1 -1
- package/dist/findVersions.d.ts.map +1 -1
- package/dist/findVersions.js +4 -3
- package/dist/findVersions.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/migrate.d.ts +1 -1
- package/dist/migrate.d.ts.map +1 -1
- package/dist/migrate.js +8 -10
- package/dist/migrate.js.map +1 -1
- package/dist/migrateDown.d.ts.map +1 -1
- package/dist/migrateDown.js +1 -1
- package/dist/migrateDown.js.map +1 -1
- package/dist/migrateFresh.d.ts.map +1 -1
- package/dist/migrateFresh.js +4 -0
- package/dist/migrateFresh.js.map +1 -1
- package/dist/migrateRefresh.d.ts.map +1 -1
- package/dist/migrateRefresh.js +2 -1
- package/dist/migrateRefresh.js.map +1 -1
- package/dist/migrateReset.d.ts.map +1 -1
- package/dist/migrateReset.js +5 -3
- package/dist/migrateReset.js.map +1 -1
- package/dist/migrateStatus.js +0 -1
- package/dist/migrateStatus.js.map +1 -1
- package/dist/postgres/countDistinct.d.ts +3 -0
- package/dist/postgres/countDistinct.d.ts.map +1 -0
- package/dist/postgres/countDistinct.js +23 -0
- package/dist/postgres/countDistinct.js.map +1 -0
- package/dist/postgres/createDatabase.d.ts +14 -0
- package/dist/postgres/createDatabase.d.ts.map +1 -0
- package/dist/postgres/createDatabase.js +76 -0
- package/dist/postgres/createDatabase.js.map +1 -0
- package/dist/postgres/createExtensions.d.ts +3 -0
- package/dist/postgres/createExtensions.d.ts.map +1 -0
- package/dist/postgres/createExtensions.js +16 -0
- package/dist/postgres/createExtensions.js.map +1 -0
- package/dist/postgres/createJSONQuery/index.d.ts +3 -0
- package/dist/postgres/createJSONQuery/index.d.ts.map +1 -0
- package/dist/postgres/createJSONQuery/index.js +42 -0
- package/dist/postgres/createJSONQuery/index.js.map +1 -0
- package/dist/postgres/createMigration.d.ts +3 -0
- package/dist/postgres/createMigration.d.ts.map +1 -0
- package/dist/postgres/createMigration.js +88 -0
- package/dist/postgres/createMigration.js.map +1 -0
- package/dist/postgres/defaultSnapshot.d.ts +3 -0
- package/dist/postgres/defaultSnapshot.d.ts.map +1 -0
- package/dist/postgres/defaultSnapshot.js +20 -0
- package/dist/postgres/defaultSnapshot.js.map +1 -0
- package/dist/postgres/deleteWhere.d.ts +3 -0
- package/dist/postgres/deleteWhere.d.ts.map +1 -0
- package/dist/postgres/deleteWhere.js +6 -0
- package/dist/postgres/deleteWhere.js.map +1 -0
- package/dist/postgres/dropDatabase.d.ts +3 -0
- package/dist/postgres/dropDatabase.d.ts.map +1 -0
- package/dist/postgres/dropDatabase.js +9 -0
- package/dist/postgres/dropDatabase.js.map +1 -0
- package/dist/postgres/execute.d.ts +3 -0
- package/dist/postgres/execute.d.ts.map +1 -0
- package/dist/postgres/execute.js +11 -0
- package/dist/postgres/execute.js.map +1 -0
- package/dist/postgres/getMigrationTemplate.d.ts +4 -0
- package/dist/postgres/getMigrationTemplate.d.ts.map +1 -0
- package/dist/postgres/getMigrationTemplate.js +13 -0
- package/dist/postgres/getMigrationTemplate.js.map +1 -0
- package/dist/postgres/init.d.ts +3 -0
- package/dist/postgres/init.d.ts.map +1 -0
- package/dist/postgres/init.js +104 -0
- package/dist/postgres/init.js.map +1 -0
- package/dist/postgres/insert.d.ts +3 -0
- package/dist/postgres/insert.d.ts.map +1 -0
- package/dist/postgres/insert.js +12 -0
- package/dist/postgres/insert.js.map +1 -0
- package/dist/postgres/requireDrizzleKit.d.ts +3 -0
- package/dist/postgres/requireDrizzleKit.d.ts.map +1 -0
- package/dist/postgres/requireDrizzleKit.js +5 -0
- package/dist/postgres/requireDrizzleKit.js.map +1 -0
- package/dist/postgres/schema/build.d.ts +42 -0
- package/dist/postgres/schema/build.d.ts.map +1 -0
- package/dist/postgres/schema/build.js +404 -0
- package/dist/postgres/schema/build.js.map +1 -0
- package/dist/postgres/schema/createIndex.d.ts +11 -0
- package/dist/postgres/schema/createIndex.d.ts.map +1 -0
- package/dist/postgres/schema/createIndex.js +20 -0
- package/dist/postgres/schema/createIndex.js.map +1 -0
- package/dist/postgres/schema/geometryColumn.d.ts +12 -0
- package/dist/postgres/schema/geometryColumn.d.ts.map +1 -0
- package/dist/postgres/schema/geometryColumn.js +18 -0
- package/dist/postgres/schema/geometryColumn.js.map +1 -0
- package/dist/postgres/schema/idToUUID.d.ts +3 -0
- package/dist/postgres/schema/idToUUID.d.ts.map +1 -0
- package/dist/postgres/schema/idToUUID.js +11 -0
- package/dist/postgres/schema/idToUUID.js.map +1 -0
- package/dist/postgres/schema/parentIDColumnMap.d.ts +4 -0
- package/dist/postgres/schema/parentIDColumnMap.d.ts.map +1 -0
- package/dist/postgres/schema/parentIDColumnMap.js +9 -0
- package/dist/postgres/schema/parentIDColumnMap.js.map +1 -0
- package/dist/postgres/schema/setColumnID.d.ts +11 -0
- package/dist/postgres/schema/setColumnID.d.ts.map +1 -0
- package/dist/postgres/schema/setColumnID.js +24 -0
- package/dist/postgres/schema/setColumnID.js.map +1 -0
- package/dist/postgres/schema/traverseFields.d.ts +42 -0
- package/dist/postgres/schema/traverseFields.d.ts.map +1 -0
- package/dist/postgres/schema/traverseFields.js +743 -0
- package/dist/postgres/schema/traverseFields.js.map +1 -0
- package/dist/postgres/schema/withDefault.d.ts +4 -0
- package/dist/postgres/schema/withDefault.d.ts.map +1 -0
- package/dist/postgres/schema/withDefault.js +15 -0
- package/dist/postgres/schema/withDefault.js.map +1 -0
- package/dist/postgres/types.d.ts +142 -0
- package/dist/postgres/types.d.ts.map +1 -0
- package/dist/postgres/types.js +3 -0
- package/dist/postgres/types.js.map +1 -0
- package/dist/queries/addJoinTable.d.ts +11 -0
- package/dist/queries/addJoinTable.d.ts.map +1 -0
- package/dist/queries/addJoinTable.js +13 -0
- package/dist/queries/addJoinTable.js.map +1 -0
- package/dist/queries/buildAndOrConditions.d.ts +1 -1
- package/dist/queries/buildAndOrConditions.d.ts.map +1 -1
- package/dist/queries/buildAndOrConditions.js +2 -4
- package/dist/queries/buildAndOrConditions.js.map +1 -1
- package/dist/queries/buildOrderBy.d.ts +18 -0
- package/dist/queries/buildOrderBy.d.ts.map +1 -0
- package/dist/queries/buildOrderBy.js +56 -0
- package/dist/queries/buildOrderBy.js.map +1 -0
- package/dist/queries/buildQuery.d.ts +8 -7
- package/dist/queries/buildQuery.d.ts.map +1 -1
- package/dist/queries/buildQuery.js +12 -47
- package/dist/queries/buildQuery.js.map +1 -1
- package/dist/queries/getTableColumnFromPath.d.ts +6 -2
- package/dist/queries/getTableColumnFromPath.d.ts.map +1 -1
- package/dist/queries/getTableColumnFromPath.js +271 -224
- package/dist/queries/getTableColumnFromPath.js.map +1 -1
- package/dist/queries/operatorMap.d.ts.map +1 -1
- package/dist/queries/operatorMap.js +0 -4
- package/dist/queries/operatorMap.js.map +1 -1
- package/dist/queries/parseParams.d.ts +1 -1
- package/dist/queries/parseParams.d.ts.map +1 -1
- package/dist/queries/parseParams.js +85 -6
- package/dist/queries/parseParams.js.map +1 -1
- package/dist/queries/sanitizeQueryValue.d.ts +12 -1
- package/dist/queries/sanitizeQueryValue.d.ts.map +1 -1
- package/dist/queries/sanitizeQueryValue.js +89 -25
- package/dist/queries/sanitizeQueryValue.js.map +1 -1
- package/dist/queries/selectDistinct.d.ts +3 -4
- package/dist/queries/selectDistinct.d.ts.map +1 -1
- package/dist/queries/selectDistinct.js.map +1 -1
- package/dist/queryDrafts.d.ts.map +1 -1
- package/dist/queryDrafts.js +6 -6
- package/dist/queryDrafts.js.map +1 -1
- package/dist/transactions/beginTransaction.d.ts.map +1 -1
- package/dist/transactions/beginTransaction.js +5 -1
- package/dist/transactions/beginTransaction.js.map +1 -1
- package/dist/transactions/commitTransaction.d.ts.map +1 -1
- package/dist/transactions/commitTransaction.js +3 -1
- package/dist/transactions/commitTransaction.js.map +1 -1
- package/dist/transform/read/hasManyNumber.d.ts +2 -1
- package/dist/transform/read/hasManyNumber.d.ts.map +1 -1
- package/dist/transform/read/hasManyNumber.js +12 -2
- package/dist/transform/read/hasManyNumber.js.map +1 -1
- package/dist/transform/read/hasManyText.d.ts +2 -1
- package/dist/transform/read/hasManyText.d.ts.map +1 -1
- package/dist/transform/read/hasManyText.js +12 -2
- package/dist/transform/read/hasManyText.js.map +1 -1
- package/dist/transform/read/index.d.ts +3 -2
- package/dist/transform/read/index.d.ts.map +1 -1
- package/dist/transform/read/index.js +3 -2
- package/dist/transform/read/index.js.map +1 -1
- package/dist/transform/read/relationship.d.ts +2 -1
- package/dist/transform/read/relationship.d.ts.map +1 -1
- package/dist/transform/read/relationship.js +15 -6
- package/dist/transform/read/relationship.js.map +1 -1
- package/dist/transform/read/traverseFields.d.ts +10 -2
- package/dist/transform/read/traverseFields.d.ts.map +1 -1
- package/dist/transform/read/traverseFields.js +185 -71
- package/dist/transform/read/traverseFields.js.map +1 -1
- package/dist/transform/write/array.d.ts +6 -1
- package/dist/transform/write/array.d.ts.map +1 -1
- package/dist/transform/write/array.js +7 -3
- package/dist/transform/write/array.js.map +1 -1
- package/dist/transform/write/blocks.d.ts +8 -3
- package/dist/transform/write/blocks.d.ts.map +1 -1
- package/dist/transform/write/blocks.js +19 -7
- package/dist/transform/write/blocks.js.map +1 -1
- package/dist/transform/write/index.d.ts.map +1 -1
- package/dist/transform/write/index.js +1 -1
- package/dist/transform/write/index.js.map +1 -1
- package/dist/transform/write/relationships.d.ts.map +1 -1
- package/dist/transform/write/relationships.js +6 -2
- package/dist/transform/write/relationships.js.map +1 -1
- package/dist/transform/write/selects.d.ts.map +1 -1
- package/dist/transform/write/selects.js +1 -1
- package/dist/transform/write/selects.js.map +1 -1
- package/dist/transform/write/traverseFields.d.ts +6 -1
- package/dist/transform/write/traverseFields.d.ts.map +1 -1
- package/dist/transform/write/traverseFields.js +62 -19
- package/dist/transform/write/traverseFields.js.map +1 -1
- package/dist/types.d.ts +8 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/update.d.ts.map +1 -1
- package/dist/update.js +4 -2
- package/dist/update.js.map +1 -1
- package/dist/updateGlobal.d.ts +1 -1
- package/dist/updateGlobal.d.ts.map +1 -1
- package/dist/updateGlobal.js +2 -1
- package/dist/updateGlobal.js.map +1 -1
- package/dist/updateGlobalVersion.d.ts +1 -1
- package/dist/updateGlobalVersion.d.ts.map +1 -1
- package/dist/updateGlobalVersion.js +4 -3
- package/dist/updateGlobalVersion.js.map +1 -1
- package/dist/updateVersion.d.ts +1 -1
- package/dist/updateVersion.d.ts.map +1 -1
- package/dist/updateVersion.js +4 -3
- package/dist/updateVersion.js.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +1 -1
- package/dist/upsertRow/deleteExistingRowsByPath.js +6 -2
- package/dist/upsertRow/deleteExistingRowsByPath.js.map +1 -1
- package/dist/upsertRow/index.d.ts +1 -1
- package/dist/upsertRow/index.d.ts.map +1 -1
- package/dist/upsertRow/index.js +51 -12
- package/dist/upsertRow/index.js.map +1 -1
- package/dist/upsertRow/insertArrays.d.ts.map +1 -1
- package/dist/upsertRow/insertArrays.js +5 -2
- package/dist/upsertRow/insertArrays.js.map +1 -1
- package/dist/upsertRow/types.d.ts +10 -5
- package/dist/upsertRow/types.d.ts.map +1 -1
- package/dist/upsertRow/types.js.map +1 -1
- package/dist/utilities/buildIndexName.d.ts +7 -0
- package/dist/utilities/buildIndexName.d.ts.map +1 -0
- package/dist/utilities/buildIndexName.js +14 -0
- package/dist/utilities/buildIndexName.js.map +1 -0
- package/dist/utilities/createBlocksMap.d.ts.map +1 -1
- package/dist/utilities/createBlocksMap.js +4 -2
- package/dist/utilities/createBlocksMap.js.map +1 -1
- package/dist/utilities/createRelationshipMap.d.ts.map +1 -1
- package/dist/utilities/createRelationshipMap.js +3 -1
- package/dist/utilities/createRelationshipMap.js.map +1 -1
- package/dist/utilities/executeSchemaHooks.d.ts +24 -0
- package/dist/utilities/executeSchemaHooks.d.ts.map +1 -0
- package/dist/utilities/executeSchemaHooks.js +21 -0
- package/dist/utilities/executeSchemaHooks.js.map +1 -0
- package/dist/utilities/extendDrizzleTable.d.ts +19 -0
- package/dist/utilities/extendDrizzleTable.d.ts.map +1 -0
- package/dist/utilities/extendDrizzleTable.js +38 -0
- package/dist/utilities/extendDrizzleTable.js.map +1 -0
- package/dist/utilities/getCollectionIdType.d.ts +7 -0
- package/dist/utilities/getCollectionIdType.d.ts.map +1 -0
- package/dist/utilities/getCollectionIdType.js +11 -0
- package/dist/utilities/getCollectionIdType.js.map +1 -0
- package/dist/utilities/getNameFromDrizzleTable.d.ts +3 -0
- package/dist/utilities/getNameFromDrizzleTable.d.ts.map +1 -0
- package/dist/utilities/getNameFromDrizzleTable.js +6 -0
- package/dist/utilities/getNameFromDrizzleTable.js.map +1 -0
- package/dist/utilities/hasLocalesTable.d.ts.map +1 -1
- package/dist/utilities/hasLocalesTable.js +13 -3
- package/dist/utilities/hasLocalesTable.js.map +1 -1
- package/dist/utilities/isPolymorphicRelationship.d.ts +6 -0
- package/dist/utilities/isPolymorphicRelationship.d.ts.map +1 -0
- package/dist/utilities/isPolymorphicRelationship.js +5 -0
- package/dist/utilities/isPolymorphicRelationship.js.map +1 -0
- package/dist/utilities/pushDevSchema.d.ts.map +1 -1
- package/dist/utilities/pushDevSchema.js +5 -0
- package/dist/utilities/pushDevSchema.js.map +1 -1
- package/license.md +22 -0
- package/package.json +26 -10
|
@@ -2,9 +2,12 @@ import { and, eq, like, sql } from 'drizzle-orm';
|
|
|
2
2
|
import { APIError, flattenTopLevelFields } from 'payload';
|
|
3
3
|
import { fieldAffectsData, tabHasName } from 'payload/shared';
|
|
4
4
|
import toSnakeCase from 'to-snake-case';
|
|
5
|
+
import { validate as uuidValidate } from 'uuid';
|
|
6
|
+
import { isPolymorphicRelationship } from '../utilities/isPolymorphicRelationship.js';
|
|
7
|
+
import { addJoinTable } from './addJoinTable.js';
|
|
5
8
|
import { getTableAlias } from './getTableAlias.js';
|
|
6
9
|
/**
|
|
7
|
-
* Transforms path to table and column name
|
|
10
|
+
* Transforms path to table and column name or to a list of OR columns
|
|
8
11
|
* Adds tables to `join`
|
|
9
12
|
* @returns TableColumn
|
|
10
13
|
*/ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix = '', value })=>{
|
|
@@ -40,194 +43,27 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
45
|
switch(field.type){
|
|
43
|
-
case 'tabs':
|
|
44
|
-
{
|
|
45
|
-
return getTableColumnFromPath({
|
|
46
|
-
adapter,
|
|
47
|
-
aliasTable,
|
|
48
|
-
collectionPath,
|
|
49
|
-
columnPrefix,
|
|
50
|
-
constraintPath,
|
|
51
|
-
constraints,
|
|
52
|
-
fields: field.tabs.map((tab)=>({
|
|
53
|
-
...tab,
|
|
54
|
-
type: 'tab'
|
|
55
|
-
})),
|
|
56
|
-
joins,
|
|
57
|
-
locale,
|
|
58
|
-
pathSegments: pathSegments.slice(1),
|
|
59
|
-
rootTableName,
|
|
60
|
-
selectFields,
|
|
61
|
-
tableName: newTableName,
|
|
62
|
-
tableNameSuffix,
|
|
63
|
-
value
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
case 'tab':
|
|
67
|
-
{
|
|
68
|
-
if (tabHasName(field)) {
|
|
69
|
-
return getTableColumnFromPath({
|
|
70
|
-
adapter,
|
|
71
|
-
aliasTable,
|
|
72
|
-
collectionPath,
|
|
73
|
-
columnPrefix: `${columnPrefix}${field.name}_`,
|
|
74
|
-
constraintPath: `${constraintPath}${field.name}.`,
|
|
75
|
-
constraints,
|
|
76
|
-
fields: field.fields,
|
|
77
|
-
joins,
|
|
78
|
-
locale,
|
|
79
|
-
pathSegments: pathSegments.slice(1),
|
|
80
|
-
rootTableName,
|
|
81
|
-
selectFields,
|
|
82
|
-
tableName: newTableName,
|
|
83
|
-
tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
|
|
84
|
-
value
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
return getTableColumnFromPath({
|
|
88
|
-
adapter,
|
|
89
|
-
aliasTable,
|
|
90
|
-
collectionPath,
|
|
91
|
-
columnPrefix,
|
|
92
|
-
constraintPath,
|
|
93
|
-
constraints,
|
|
94
|
-
fields: field.fields,
|
|
95
|
-
joins,
|
|
96
|
-
locale,
|
|
97
|
-
pathSegments: pathSegments.slice(1),
|
|
98
|
-
rootTableName,
|
|
99
|
-
selectFields,
|
|
100
|
-
tableName: newTableName,
|
|
101
|
-
tableNameSuffix,
|
|
102
|
-
value
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
case 'group':
|
|
106
|
-
{
|
|
107
|
-
if (locale && field.localized && adapter.payload.config.localization) {
|
|
108
|
-
newTableName = `${tableName}${adapter.localesSuffix}`;
|
|
109
|
-
joins.push({
|
|
110
|
-
condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),
|
|
111
|
-
table: adapter.tables[newTableName]
|
|
112
|
-
});
|
|
113
|
-
if (locale !== 'all') {
|
|
114
|
-
constraints.push({
|
|
115
|
-
columnName: '_locale',
|
|
116
|
-
table: adapter.tables[newTableName],
|
|
117
|
-
value: locale
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return getTableColumnFromPath({
|
|
122
|
-
adapter,
|
|
123
|
-
aliasTable,
|
|
124
|
-
collectionPath,
|
|
125
|
-
columnPrefix: `${columnPrefix}${field.name}_`,
|
|
126
|
-
constraintPath: `${constraintPath}${field.name}.`,
|
|
127
|
-
constraints,
|
|
128
|
-
fields: field.fields,
|
|
129
|
-
joins,
|
|
130
|
-
locale,
|
|
131
|
-
pathSegments: pathSegments.slice(1),
|
|
132
|
-
rootTableName,
|
|
133
|
-
selectFields,
|
|
134
|
-
tableName: newTableName,
|
|
135
|
-
tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
|
|
136
|
-
value
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
case 'select':
|
|
140
|
-
{
|
|
141
|
-
if (field.hasMany) {
|
|
142
|
-
const newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
|
|
143
|
-
if (locale && field.localized && adapter.payload.config.localization) {
|
|
144
|
-
joins.push({
|
|
145
|
-
condition: and(eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent), eq(adapter.tables[newTableName]._locale, locale)),
|
|
146
|
-
table: adapter.tables[newTableName]
|
|
147
|
-
});
|
|
148
|
-
if (locale !== 'all') {
|
|
149
|
-
constraints.push({
|
|
150
|
-
columnName: '_locale',
|
|
151
|
-
table: adapter.tables[newTableName],
|
|
152
|
-
value: locale
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
} else {
|
|
156
|
-
joins.push({
|
|
157
|
-
condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
|
|
158
|
-
table: adapter.tables[newTableName]
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
return {
|
|
162
|
-
columnName: 'value',
|
|
163
|
-
constraints,
|
|
164
|
-
field,
|
|
165
|
-
table: adapter.tables[newTableName]
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
case 'text':
|
|
171
|
-
case 'number':
|
|
172
|
-
{
|
|
173
|
-
if (field.hasMany) {
|
|
174
|
-
let tableType = 'texts';
|
|
175
|
-
let columnName = 'text';
|
|
176
|
-
if (field.type === 'number') {
|
|
177
|
-
tableType = 'numbers';
|
|
178
|
-
columnName = 'number';
|
|
179
|
-
}
|
|
180
|
-
newTableName = `${tableName}_${tableType}`;
|
|
181
|
-
const joinConstraints = [
|
|
182
|
-
eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
|
|
183
|
-
eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`)
|
|
184
|
-
];
|
|
185
|
-
if (locale && field.localized && adapter.payload.config.localization) {
|
|
186
|
-
joins.push({
|
|
187
|
-
condition: and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale)),
|
|
188
|
-
table: adapter.tables[newTableName]
|
|
189
|
-
});
|
|
190
|
-
if (locale !== 'all') {
|
|
191
|
-
constraints.push({
|
|
192
|
-
columnName: 'locale',
|
|
193
|
-
table: adapter.tables[newTableName],
|
|
194
|
-
value: locale
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
joins.push({
|
|
199
|
-
condition: and(...joinConstraints),
|
|
200
|
-
table: adapter.tables[newTableName]
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
columnName,
|
|
205
|
-
constraints,
|
|
206
|
-
field,
|
|
207
|
-
table: adapter.tables[newTableName]
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
break;
|
|
211
|
-
}
|
|
212
46
|
case 'array':
|
|
213
47
|
{
|
|
214
48
|
newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
|
|
49
|
+
const arrayParentTable = aliasTable || adapter.tables[tableName];
|
|
215
50
|
constraintPath = `${constraintPath}${field.name}.%.`;
|
|
216
51
|
if (locale && field.localized && adapter.payload.config.localization) {
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
});
|
|
52
|
+
const conditions = [
|
|
53
|
+
eq(arrayParentTable.id, adapter.tables[newTableName]._parentID)
|
|
54
|
+
];
|
|
221
55
|
if (locale !== 'all') {
|
|
222
|
-
|
|
223
|
-
columnName: '_locale',
|
|
224
|
-
table: adapter.tables[newTableName],
|
|
225
|
-
value: locale
|
|
226
|
-
});
|
|
56
|
+
conditions.push(eq(adapter.tables[newTableName]._locale, locale));
|
|
227
57
|
}
|
|
58
|
+
addJoinTable({
|
|
59
|
+
condition: and(...conditions),
|
|
60
|
+
joins,
|
|
61
|
+
table: adapter.tables[newTableName]
|
|
62
|
+
});
|
|
228
63
|
} else {
|
|
229
|
-
|
|
230
|
-
condition: eq(
|
|
64
|
+
addJoinTable({
|
|
65
|
+
condition: eq(arrayParentTable.id, adapter.tables[newTableName]._parentID),
|
|
66
|
+
joins,
|
|
231
67
|
table: adapter.tables[newTableName]
|
|
232
68
|
});
|
|
233
69
|
}
|
|
@@ -314,17 +150,16 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
314
150
|
...blockSelectFields
|
|
315
151
|
};
|
|
316
152
|
if (field.localized && adapter.payload.config.localization) {
|
|
153
|
+
const conditions = [
|
|
154
|
+
eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID)
|
|
155
|
+
];
|
|
156
|
+
if (locale !== 'all') {
|
|
157
|
+
conditions.push(eq(adapter.tables[newTableName]._locale, locale));
|
|
158
|
+
}
|
|
317
159
|
joins.push({
|
|
318
|
-
condition: and(
|
|
160
|
+
condition: and(...conditions),
|
|
319
161
|
table: adapter.tables[newTableName]
|
|
320
162
|
});
|
|
321
|
-
if (locale) {
|
|
322
|
-
constraints.push({
|
|
323
|
-
columnName: '_locale',
|
|
324
|
-
table: adapter.tables[newTableName],
|
|
325
|
-
value: locale
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
163
|
} else {
|
|
329
164
|
joins.push({
|
|
330
165
|
condition: eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID),
|
|
@@ -345,11 +180,86 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
345
180
|
}
|
|
346
181
|
break;
|
|
347
182
|
}
|
|
183
|
+
case 'group':
|
|
184
|
+
{
|
|
185
|
+
if (locale && field.localized && adapter.payload.config.localization) {
|
|
186
|
+
newTableName = `${tableName}${adapter.localesSuffix}`;
|
|
187
|
+
let condition = eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID);
|
|
188
|
+
if (locale !== 'all') {
|
|
189
|
+
condition = and(condition, eq(adapter.tables[newTableName]._locale, locale));
|
|
190
|
+
}
|
|
191
|
+
addJoinTable({
|
|
192
|
+
condition,
|
|
193
|
+
joins,
|
|
194
|
+
table: adapter.tables[newTableName]
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
return getTableColumnFromPath({
|
|
198
|
+
adapter,
|
|
199
|
+
aliasTable,
|
|
200
|
+
collectionPath,
|
|
201
|
+
columnPrefix: `${columnPrefix}${field.name}_`,
|
|
202
|
+
constraintPath: `${constraintPath}${field.name}.`,
|
|
203
|
+
constraints,
|
|
204
|
+
fields: field.fields,
|
|
205
|
+
joins,
|
|
206
|
+
locale,
|
|
207
|
+
pathSegments: pathSegments.slice(1),
|
|
208
|
+
rootTableName,
|
|
209
|
+
selectFields,
|
|
210
|
+
tableName: newTableName,
|
|
211
|
+
tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
|
|
212
|
+
value
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
case 'number':
|
|
216
|
+
case 'text':
|
|
217
|
+
{
|
|
218
|
+
if (field.hasMany) {
|
|
219
|
+
let tableType = 'texts';
|
|
220
|
+
let columnName = 'text';
|
|
221
|
+
if (field.type === 'number') {
|
|
222
|
+
tableType = 'numbers';
|
|
223
|
+
columnName = 'number';
|
|
224
|
+
}
|
|
225
|
+
newTableName = `${rootTableName}_${tableType}`;
|
|
226
|
+
const joinConstraints = [
|
|
227
|
+
eq(adapter.tables[rootTableName].id, adapter.tables[newTableName].parent),
|
|
228
|
+
like(adapter.tables[newTableName].path, `${constraintPath}${field.name}`)
|
|
229
|
+
];
|
|
230
|
+
if (locale && field.localized && adapter.payload.config.localization) {
|
|
231
|
+
const conditions = [
|
|
232
|
+
...joinConstraints
|
|
233
|
+
];
|
|
234
|
+
if (locale !== 'all') {
|
|
235
|
+
conditions.push(eq(adapter.tables[newTableName]._locale, locale));
|
|
236
|
+
}
|
|
237
|
+
addJoinTable({
|
|
238
|
+
condition: and(...conditions),
|
|
239
|
+
joins,
|
|
240
|
+
table: adapter.tables[newTableName]
|
|
241
|
+
});
|
|
242
|
+
} else {
|
|
243
|
+
addJoinTable({
|
|
244
|
+
condition: and(...joinConstraints),
|
|
245
|
+
joins,
|
|
246
|
+
table: adapter.tables[newTableName]
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
return {
|
|
250
|
+
columnName,
|
|
251
|
+
constraints,
|
|
252
|
+
field,
|
|
253
|
+
table: adapter.tables[newTableName]
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
348
258
|
case 'relationship':
|
|
349
259
|
case 'upload':
|
|
350
260
|
{
|
|
351
261
|
const newCollectionPath = pathSegments.slice(1).join('.');
|
|
352
|
-
if (Array.isArray(field.relationTo) || field.
|
|
262
|
+
if (Array.isArray(field.relationTo) || field.hasMany) {
|
|
353
263
|
let relationshipFields;
|
|
354
264
|
const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`;
|
|
355
265
|
const { newAliasTable: aliasRelationshipTable, newAliasTableName: aliasRelationshipTableName } = getTableAlias({
|
|
@@ -358,17 +268,17 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
358
268
|
});
|
|
359
269
|
// Join in the relationships table
|
|
360
270
|
if (locale && field.localized && adapter.payload.config.localization) {
|
|
271
|
+
const conditions = [
|
|
272
|
+
eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),
|
|
273
|
+
like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)
|
|
274
|
+
];
|
|
275
|
+
if (locale !== 'all') {
|
|
276
|
+
conditions.push(eq(aliasRelationshipTable.locale, locale));
|
|
277
|
+
}
|
|
361
278
|
joins.push({
|
|
362
|
-
condition: and(
|
|
279
|
+
condition: and(...conditions),
|
|
363
280
|
table: aliasRelationshipTable
|
|
364
281
|
});
|
|
365
|
-
if (locale !== 'all') {
|
|
366
|
-
constraints.push({
|
|
367
|
-
columnName: 'locale',
|
|
368
|
-
table: aliasRelationshipTable,
|
|
369
|
-
value: locale
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
282
|
} else {
|
|
373
283
|
// Join in the relationships table
|
|
374
284
|
joins.push({
|
|
@@ -400,20 +310,43 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
400
310
|
};
|
|
401
311
|
}
|
|
402
312
|
} else if (newCollectionPath === 'value') {
|
|
403
|
-
const
|
|
313
|
+
const hasCustomCollectionWithCustomID = field.relationTo.some((relationTo)=>!!adapter.payload.collections[relationTo].customIDType);
|
|
314
|
+
const columns = field.relationTo.map((relationTo)=>{
|
|
315
|
+
let idType = adapter.idType === 'uuid' ? 'uuid' : 'number';
|
|
316
|
+
const { customIDType } = adapter.payload.collections[relationTo];
|
|
317
|
+
if (customIDType) {
|
|
318
|
+
idType = customIDType;
|
|
319
|
+
}
|
|
320
|
+
const idTypeTextOrUuid = idType === 'text' || idType === 'uuid';
|
|
321
|
+
// Do not add the column to OR if we know that it can't match by the type
|
|
322
|
+
// We can't do the same with idType: 'number' because `value` can be from the REST search query params
|
|
323
|
+
if (typeof value === 'number' && idTypeTextOrUuid) {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
if (Array.isArray(value) && value.every((val)=>typeof val === 'number') && idTypeTextOrUuid) {
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
// Do not add the UUID type column if incoming query value doesn't match UUID. If there aren't any collections with
|
|
330
|
+
// a custom ID type, we skip this check
|
|
331
|
+
// We need this because Postgres throws an error if querying by UUID column with a value that isn't a valid UUID.
|
|
332
|
+
if (value && !Array.isArray(value) && idType === 'uuid' && hasCustomCollectionWithCustomID) {
|
|
333
|
+
if (!uuidValidate(value)) {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
if (Array.isArray(value) && idType === 'uuid' && hasCustomCollectionWithCustomID && !value.some((val)=>uuidValidate(val))) {
|
|
338
|
+
return null;
|
|
339
|
+
}
|
|
404
340
|
const relationTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[relationTo].config.slug));
|
|
405
|
-
return
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
} else {
|
|
411
|
-
column = `COALESCE(${tableColumnsNames.join(', ')})`;
|
|
412
|
-
}
|
|
341
|
+
return {
|
|
342
|
+
idType,
|
|
343
|
+
rawColumn: sql.raw(`"${aliasRelationshipTableName}"."${relationTableName}_id"`)
|
|
344
|
+
};
|
|
345
|
+
}).filter(Boolean);
|
|
413
346
|
return {
|
|
347
|
+
columns,
|
|
414
348
|
constraints,
|
|
415
349
|
field,
|
|
416
|
-
rawColumn: sql.raw(`${column}`),
|
|
417
350
|
table: aliasRelationshipTable
|
|
418
351
|
};
|
|
419
352
|
} else if (newCollectionPath === 'relationTo') {
|
|
@@ -425,11 +358,22 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
425
358
|
field,
|
|
426
359
|
getNotNullColumnByValue: (val)=>{
|
|
427
360
|
const matchedRelation = relationTo.find((relation)=>relation === val);
|
|
428
|
-
if (matchedRelation)
|
|
361
|
+
if (matchedRelation) {
|
|
362
|
+
return `${matchedRelation}ID`;
|
|
363
|
+
}
|
|
429
364
|
return undefined;
|
|
430
365
|
},
|
|
431
366
|
table: aliasRelationshipTable
|
|
432
367
|
};
|
|
368
|
+
} else if (isPolymorphicRelationship(value)) {
|
|
369
|
+
const { relationTo } = value;
|
|
370
|
+
const relationTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[relationTo].config.slug));
|
|
371
|
+
return {
|
|
372
|
+
constraints,
|
|
373
|
+
field,
|
|
374
|
+
rawColumn: sql.raw(`"${aliasRelationshipTableName}"."${relationTableName}_id"`),
|
|
375
|
+
table: aliasRelationshipTable
|
|
376
|
+
};
|
|
433
377
|
} else {
|
|
434
378
|
throw new APIError('Not supported');
|
|
435
379
|
}
|
|
@@ -460,12 +404,20 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
460
404
|
adapter,
|
|
461
405
|
tableName: `${rootTableName}${adapter.localesSuffix}`
|
|
462
406
|
});
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
407
|
+
const condtions = [
|
|
408
|
+
eq(aliasLocaleTable._parentID, adapter.tables[rootTableName].id)
|
|
409
|
+
];
|
|
410
|
+
if (locale !== 'all') {
|
|
411
|
+
condtions.push(eq(aliasLocaleTable._locale, locale));
|
|
412
|
+
}
|
|
413
|
+
const localesTable = adapter.tables[`${rootTableName}${adapter.localesSuffix}`];
|
|
414
|
+
addJoinTable({
|
|
415
|
+
condition: and(...condtions),
|
|
416
|
+
joins,
|
|
417
|
+
table: localesTable
|
|
466
418
|
});
|
|
467
419
|
joins.push({
|
|
468
|
-
condition: eq(
|
|
420
|
+
condition: eq(localesTable[columnName], newAliasTable.id),
|
|
469
421
|
table: newAliasTable
|
|
470
422
|
});
|
|
471
423
|
} else {
|
|
@@ -491,31 +443,126 @@ import { getTableAlias } from './getTableAlias.js';
|
|
|
491
443
|
}
|
|
492
444
|
break;
|
|
493
445
|
}
|
|
446
|
+
case 'select':
|
|
447
|
+
{
|
|
448
|
+
if (field.hasMany) {
|
|
449
|
+
const newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
|
|
450
|
+
if (locale && field.localized && adapter.payload.config.localization) {
|
|
451
|
+
const conditions = [
|
|
452
|
+
eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
|
|
453
|
+
eq(adapter.tables[newTableName]._locale, locale)
|
|
454
|
+
];
|
|
455
|
+
if (locale !== 'all') {
|
|
456
|
+
conditions.push(eq(adapter.tables[newTableName]._locale, locale));
|
|
457
|
+
}
|
|
458
|
+
addJoinTable({
|
|
459
|
+
condition: and(...conditions),
|
|
460
|
+
joins,
|
|
461
|
+
table: adapter.tables[newTableName]
|
|
462
|
+
});
|
|
463
|
+
} else {
|
|
464
|
+
addJoinTable({
|
|
465
|
+
condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
|
|
466
|
+
joins,
|
|
467
|
+
table: adapter.tables[newTableName]
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
return {
|
|
471
|
+
columnName: 'value',
|
|
472
|
+
constraints,
|
|
473
|
+
field,
|
|
474
|
+
table: adapter.tables[newTableName]
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
break;
|
|
478
|
+
}
|
|
479
|
+
case 'tab':
|
|
480
|
+
{
|
|
481
|
+
if (tabHasName(field)) {
|
|
482
|
+
return getTableColumnFromPath({
|
|
483
|
+
adapter,
|
|
484
|
+
aliasTable,
|
|
485
|
+
collectionPath,
|
|
486
|
+
columnPrefix: `${columnPrefix}${field.name}_`,
|
|
487
|
+
constraintPath: `${constraintPath}${field.name}.`,
|
|
488
|
+
constraints,
|
|
489
|
+
fields: field.fields,
|
|
490
|
+
joins,
|
|
491
|
+
locale,
|
|
492
|
+
pathSegments: pathSegments.slice(1),
|
|
493
|
+
rootTableName,
|
|
494
|
+
selectFields,
|
|
495
|
+
tableName: newTableName,
|
|
496
|
+
tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
|
|
497
|
+
value
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
return getTableColumnFromPath({
|
|
501
|
+
adapter,
|
|
502
|
+
aliasTable,
|
|
503
|
+
collectionPath,
|
|
504
|
+
columnPrefix,
|
|
505
|
+
constraintPath,
|
|
506
|
+
constraints,
|
|
507
|
+
fields: field.fields,
|
|
508
|
+
joins,
|
|
509
|
+
locale,
|
|
510
|
+
pathSegments: pathSegments.slice(1),
|
|
511
|
+
rootTableName,
|
|
512
|
+
selectFields,
|
|
513
|
+
tableName: newTableName,
|
|
514
|
+
tableNameSuffix,
|
|
515
|
+
value
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
case 'tabs':
|
|
519
|
+
{
|
|
520
|
+
return getTableColumnFromPath({
|
|
521
|
+
adapter,
|
|
522
|
+
aliasTable,
|
|
523
|
+
collectionPath,
|
|
524
|
+
columnPrefix,
|
|
525
|
+
constraintPath,
|
|
526
|
+
constraints,
|
|
527
|
+
fields: field.tabs.map((tab)=>({
|
|
528
|
+
...tab,
|
|
529
|
+
type: 'tab'
|
|
530
|
+
})),
|
|
531
|
+
joins,
|
|
532
|
+
locale,
|
|
533
|
+
pathSegments: pathSegments.slice(1),
|
|
534
|
+
rootTableName,
|
|
535
|
+
selectFields,
|
|
536
|
+
tableName: newTableName,
|
|
537
|
+
tableNameSuffix,
|
|
538
|
+
value
|
|
539
|
+
});
|
|
540
|
+
}
|
|
494
541
|
default:
|
|
495
542
|
{
|
|
496
543
|
break;
|
|
497
544
|
}
|
|
498
545
|
}
|
|
499
546
|
if (fieldAffectsData(field)) {
|
|
547
|
+
let newTable = adapter.tables[newTableName];
|
|
500
548
|
if (field.localized && adapter.payload.config.localization) {
|
|
501
549
|
// If localized, we go to localized table and set aliasTable to undefined
|
|
502
550
|
// so it is not picked up below to be used as targetTable
|
|
503
551
|
const parentTable = aliasTable || adapter.tables[tableName];
|
|
504
552
|
newTableName = `${tableName}${adapter.localesSuffix}`;
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
table: adapter.tables[newTableName]
|
|
508
|
-
});
|
|
509
|
-
aliasTable = undefined;
|
|
553
|
+
newTable = adapter.tables[newTableName];
|
|
554
|
+
let condition = eq(parentTable.id, newTable._parentID);
|
|
510
555
|
if (locale !== 'all') {
|
|
511
|
-
|
|
512
|
-
columnName: '_locale',
|
|
513
|
-
table: adapter.tables[newTableName],
|
|
514
|
-
value: locale
|
|
515
|
-
});
|
|
556
|
+
condition = and(condition, eq(newTable._locale, locale));
|
|
516
557
|
}
|
|
558
|
+
addJoinTable({
|
|
559
|
+
condition,
|
|
560
|
+
joins,
|
|
561
|
+
table: newTable
|
|
562
|
+
});
|
|
563
|
+
aliasTable = undefined;
|
|
517
564
|
}
|
|
518
|
-
const targetTable = aliasTable ||
|
|
565
|
+
const targetTable = aliasTable || newTable;
|
|
519
566
|
selectFields[`${newTableName}.${columnPrefix}${field.name}`] = targetTable[`${columnPrefix}${field.name}`];
|
|
520
567
|
return {
|
|
521
568
|
columnName: `${columnPrefix}${field.name}`,
|