@payloadcms/db-postgres 3.0.0-canary.7660f90 → 3.0.0-canary.79e92af

Sign up to get free protection for your applications and to get access to all the features.
Files changed (344) hide show
  1. package/dist/connect.d.ts.map +1 -1
  2. package/dist/connect.js +10 -6
  3. package/dist/connect.js.map +1 -1
  4. package/dist/index.d.ts +0 -1
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +30 -66
  7. package/dist/index.js.map +1 -1
  8. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts +3 -2
  9. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.d.ts.map +1 -1
  10. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js +1 -1
  11. package/dist/predefinedMigrations/v2-v3/fetchAndResave/index.js.map +1 -1
  12. package/dist/predefinedMigrations/v2-v3/index.d.ts.map +1 -1
  13. package/dist/predefinedMigrations/v2-v3/index.js +2 -2
  14. package/dist/predefinedMigrations/v2-v3/index.js.map +1 -1
  15. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts +3 -2
  16. package/dist/predefinedMigrations/v2-v3/migrateRelationships.d.ts.map +1 -1
  17. package/dist/predefinedMigrations/v2-v3/migrateRelationships.js.map +1 -1
  18. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts +3 -2
  19. package/dist/predefinedMigrations/v2-v3/traverseFields.d.ts.map +1 -1
  20. package/dist/predefinedMigrations/v2-v3/traverseFields.js.map +1 -1
  21. package/dist/types.d.ts +42 -78
  22. package/dist/types.d.ts.map +1 -1
  23. package/dist/types.js.map +1 -1
  24. package/package.json +10 -10
  25. package/dist/count.d.ts +0 -3
  26. package/dist/count.d.ts.map +0 -1
  27. package/dist/count.js +0 -41
  28. package/dist/count.js.map +0 -1
  29. package/dist/create.d.ts +0 -3
  30. package/dist/create.d.ts.map +0 -1
  31. package/dist/create.js +0 -19
  32. package/dist/create.js.map +0 -1
  33. package/dist/createGlobal.d.ts +0 -4
  34. package/dist/createGlobal.d.ts.map +0 -1
  35. package/dist/createGlobal.js +0 -19
  36. package/dist/createGlobal.js.map +0 -1
  37. package/dist/createGlobalVersion.d.ts +0 -5
  38. package/dist/createGlobalVersion.d.ts.map +0 -1
  39. package/dist/createGlobalVersion.js +0 -33
  40. package/dist/createGlobalVersion.js.map +0 -1
  41. package/dist/createMigration.d.ts +0 -3
  42. package/dist/createMigration.d.ts.map +0 -1
  43. package/dist/createMigration.js +0 -102
  44. package/dist/createMigration.js.map +0 -1
  45. package/dist/createVersion.d.ts +0 -4
  46. package/dist/createVersion.d.ts.map +0 -1
  47. package/dist/createVersion.js +0 -40
  48. package/dist/createVersion.js.map +0 -1
  49. package/dist/deleteMany.d.ts +0 -3
  50. package/dist/deleteMany.d.ts.map +0 -1
  51. package/dist/deleteMany.js +0 -28
  52. package/dist/deleteMany.js.map +0 -1
  53. package/dist/deleteOne.d.ts +0 -3
  54. package/dist/deleteOne.d.ts.map +0 -1
  55. package/dist/deleteOne.js +0 -59
  56. package/dist/deleteOne.js.map +0 -1
  57. package/dist/deleteVersions.d.ts +0 -3
  58. package/dist/deleteVersions.d.ts.map +0 -1
  59. package/dist/deleteVersions.js +0 -31
  60. package/dist/deleteVersions.js.map +0 -1
  61. package/dist/destroy.d.ts +0 -3
  62. package/dist/destroy.d.ts.map +0 -1
  63. package/dist/destroy.js +0 -15
  64. package/dist/destroy.js.map +0 -1
  65. package/dist/find/buildFindManyArgs.d.ts +0 -17
  66. package/dist/find/buildFindManyArgs.d.ts.map +0 -1
  67. package/dist/find/buildFindManyArgs.js +0 -65
  68. package/dist/find/buildFindManyArgs.js.map +0 -1
  69. package/dist/find/chainMethods.d.ts +0 -16
  70. package/dist/find/chainMethods.d.ts.map +0 -1
  71. package/dist/find/chainMethods.js +0 -12
  72. package/dist/find/chainMethods.js.map +0 -1
  73. package/dist/find/findMany.d.ts +0 -21
  74. package/dist/find/findMany.d.ts.map +0 -1
  75. package/dist/find/findMany.js +0 -152
  76. package/dist/find/findMany.js.map +0 -1
  77. package/dist/find/traverseFields.d.ts +0 -17
  78. package/dist/find/traverseFields.d.ts.map +0 -1
  79. package/dist/find/traverseFields.js +0 -156
  80. package/dist/find/traverseFields.js.map +0 -1
  81. package/dist/find.d.ts +0 -3
  82. package/dist/find.d.ts.map +0 -1
  83. package/dist/find.js +0 -21
  84. package/dist/find.js.map +0 -1
  85. package/dist/findGlobal.d.ts +0 -3
  86. package/dist/findGlobal.d.ts.map +0 -1
  87. package/dist/findGlobal.js +0 -23
  88. package/dist/findGlobal.js.map +0 -1
  89. package/dist/findGlobalVersions.d.ts +0 -3
  90. package/dist/findGlobalVersions.d.ts.map +0 -1
  91. package/dist/findGlobalVersions.js +0 -24
  92. package/dist/findGlobalVersions.js.map +0 -1
  93. package/dist/findOne.d.ts +0 -4
  94. package/dist/findOne.d.ts.map +0 -1
  95. package/dist/findOne.js +0 -21
  96. package/dist/findOne.js.map +0 -1
  97. package/dist/findVersions.d.ts +0 -3
  98. package/dist/findVersions.d.ts.map +0 -1
  99. package/dist/findVersions.js +0 -24
  100. package/dist/findVersions.js.map +0 -1
  101. package/dist/init.d.ts +0 -3
  102. package/dist/init.d.ts.map +0 -1
  103. package/dist/init.js +0 -91
  104. package/dist/init.js.map +0 -1
  105. package/dist/migrate.d.ts +0 -3
  106. package/dist/migrate.d.ts.map +0 -1
  107. package/dist/migrate.js +0 -99
  108. package/dist/migrate.js.map +0 -1
  109. package/dist/migrateDown.d.ts +0 -3
  110. package/dist/migrateDown.d.ts.map +0 -1
  111. package/dist/migrateDown.js +0 -63
  112. package/dist/migrateDown.js.map +0 -1
  113. package/dist/migrateFresh.d.ts +0 -8
  114. package/dist/migrateFresh.d.ts.map +0 -1
  115. package/dist/migrateFresh.js +0 -72
  116. package/dist/migrateFresh.js.map +0 -1
  117. package/dist/migrateRefresh.d.ts +0 -6
  118. package/dist/migrateRefresh.d.ts.map +0 -1
  119. package/dist/migrateRefresh.js +0 -102
  120. package/dist/migrateRefresh.js.map +0 -1
  121. package/dist/migrateReset.d.ts +0 -6
  122. package/dist/migrateReset.d.ts.map +0 -1
  123. package/dist/migrateReset.js +0 -82
  124. package/dist/migrateReset.js.map +0 -1
  125. package/dist/migrateStatus.d.ts +0 -3
  126. package/dist/migrateStatus.d.ts.map +0 -1
  127. package/dist/migrateStatus.js +0 -44
  128. package/dist/migrateStatus.js.map +0 -1
  129. package/dist/queries/buildAndOrConditions.d.ts +0 -16
  130. package/dist/queries/buildAndOrConditions.d.ts.map +0 -1
  131. package/dist/queries/buildAndOrConditions.js +0 -28
  132. package/dist/queries/buildAndOrConditions.js.map +0 -1
  133. package/dist/queries/buildQuery.d.ts +0 -30
  134. package/dist/queries/buildQuery.d.ts.map +0 -1
  135. package/dist/queries/buildQuery.js +0 -72
  136. package/dist/queries/buildQuery.js.map +0 -1
  137. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts +0 -2
  138. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.d.ts.map +0 -1
  139. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js +0 -14
  140. package/dist/queries/createJSONQuery/convertPathToJSONTraversal.js.map +0 -1
  141. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts +0 -2
  142. package/dist/queries/createJSONQuery/formatJSONPathSegment.d.ts.map +0 -1
  143. package/dist/queries/createJSONQuery/formatJSONPathSegment.js +0 -5
  144. package/dist/queries/createJSONQuery/formatJSONPathSegment.js.map +0 -1
  145. package/dist/queries/createJSONQuery/index.d.ts +0 -10
  146. package/dist/queries/createJSONQuery/index.d.ts.map +0 -1
  147. package/dist/queries/createJSONQuery/index.js +0 -54
  148. package/dist/queries/createJSONQuery/index.js.map +0 -1
  149. package/dist/queries/getTableColumnFromPath.d.ts +0 -50
  150. package/dist/queries/getTableColumnFromPath.d.ts.map +0 -1
  151. package/dist/queries/getTableColumnFromPath.js +0 -516
  152. package/dist/queries/getTableColumnFromPath.js.map +0 -1
  153. package/dist/queries/operatorMap.d.ts +0 -18
  154. package/dist/queries/operatorMap.d.ts.map +0 -1
  155. package/dist/queries/operatorMap.js +0 -24
  156. package/dist/queries/operatorMap.js.map +0 -1
  157. package/dist/queries/parseParams.d.ts +0 -16
  158. package/dist/queries/parseParams.d.ts.map +0 -1
  159. package/dist/queries/parseParams.js +0 -183
  160. package/dist/queries/parseParams.js.map +0 -1
  161. package/dist/queries/sanitizeQueryValue.d.ts +0 -15
  162. package/dist/queries/sanitizeQueryValue.d.ts.map +0 -1
  163. package/dist/queries/sanitizeQueryValue.js +0 -89
  164. package/dist/queries/sanitizeQueryValue.js.map +0 -1
  165. package/dist/queries/selectDistinct.d.ts +0 -22
  166. package/dist/queries/selectDistinct.d.ts.map +0 -1
  167. package/dist/queries/selectDistinct.js +0 -30
  168. package/dist/queries/selectDistinct.js.map +0 -1
  169. package/dist/queryDrafts.d.ts +0 -3
  170. package/dist/queryDrafts.d.ts.map +0 -1
  171. package/dist/queryDrafts.js +0 -40
  172. package/dist/queryDrafts.js.map +0 -1
  173. package/dist/schema/build.d.ts +0 -34
  174. package/dist/schema/build.d.ts.map +0 -1
  175. package/dist/schema/build.js +0 -369
  176. package/dist/schema/build.js.map +0 -1
  177. package/dist/schema/createIndex.d.ts +0 -12
  178. package/dist/schema/createIndex.d.ts.map +0 -1
  179. package/dist/schema/createIndex.js +0 -18
  180. package/dist/schema/createIndex.js.map +0 -1
  181. package/dist/schema/createTableName.d.ts +0 -30
  182. package/dist/schema/createTableName.d.ts.map +0 -1
  183. package/dist/schema/createTableName.js +0 -31
  184. package/dist/schema/createTableName.js.map +0 -1
  185. package/dist/schema/idToUUID.d.ts +0 -3
  186. package/dist/schema/idToUUID.d.ts.map +0 -1
  187. package/dist/schema/idToUUID.js +0 -11
  188. package/dist/schema/idToUUID.js.map +0 -1
  189. package/dist/schema/parentIDColumnMap.d.ts +0 -4
  190. package/dist/schema/parentIDColumnMap.d.ts.map +0 -1
  191. package/dist/schema/parentIDColumnMap.js +0 -9
  192. package/dist/schema/parentIDColumnMap.js.map +0 -1
  193. package/dist/schema/setColumnID.d.ts +0 -11
  194. package/dist/schema/setColumnID.d.ts.map +0 -1
  195. package/dist/schema/setColumnID.js +0 -24
  196. package/dist/schema/setColumnID.js.map +0 -1
  197. package/dist/schema/traverseFields.d.ts +0 -36
  198. package/dist/schema/traverseFields.d.ts.map +0 -1
  199. package/dist/schema/traverseFields.js +0 -614
  200. package/dist/schema/traverseFields.js.map +0 -1
  201. package/dist/schema/validateExistingBlockIsIdentical.d.ts +0 -12
  202. package/dist/schema/validateExistingBlockIsIdentical.d.ts.map +0 -1
  203. package/dist/schema/validateExistingBlockIsIdentical.js +0 -76
  204. package/dist/schema/validateExistingBlockIsIdentical.js.map +0 -1
  205. package/dist/transactions/beginTransaction.d.ts +0 -3
  206. package/dist/transactions/beginTransaction.d.ts.map +0 -1
  207. package/dist/transactions/beginTransaction.js +0 -51
  208. package/dist/transactions/beginTransaction.js.map +0 -1
  209. package/dist/transactions/commitTransaction.d.ts +0 -3
  210. package/dist/transactions/commitTransaction.d.ts.map +0 -1
  211. package/dist/transactions/commitTransaction.js +0 -14
  212. package/dist/transactions/commitTransaction.js.map +0 -1
  213. package/dist/transactions/rollbackTransaction.d.ts +0 -3
  214. package/dist/transactions/rollbackTransaction.d.ts.map +0 -1
  215. package/dist/transactions/rollbackTransaction.js +0 -13
  216. package/dist/transactions/rollbackTransaction.js.map +0 -1
  217. package/dist/transform/read/hasManyNumber.d.ts +0 -10
  218. package/dist/transform/read/hasManyNumber.d.ts.map +0 -1
  219. package/dist/transform/read/hasManyNumber.js +0 -10
  220. package/dist/transform/read/hasManyNumber.js.map +0 -1
  221. package/dist/transform/read/hasManyText.d.ts +0 -10
  222. package/dist/transform/read/hasManyText.d.ts.map +0 -1
  223. package/dist/transform/read/hasManyText.js +0 -10
  224. package/dist/transform/read/hasManyText.js.map +0 -1
  225. package/dist/transform/read/index.d.ts +0 -13
  226. package/dist/transform/read/index.d.ts.map +0 -1
  227. package/dist/transform/read/index.js +0 -44
  228. package/dist/transform/read/index.js.map +0 -1
  229. package/dist/transform/read/relationship.d.ts +0 -10
  230. package/dist/transform/read/relationship.d.ts.map +0 -1
  231. package/dist/transform/read/relationship.js +0 -60
  232. package/dist/transform/read/relationship.js.map +0 -1
  233. package/dist/transform/read/traverseFields.d.ts +0 -57
  234. package/dist/transform/read/traverseFields.d.ts.map +0 -1
  235. package/dist/transform/read/traverseFields.js +0 -435
  236. package/dist/transform/read/traverseFields.js.map +0 -1
  237. package/dist/transform/write/array.d.ts +0 -26
  238. package/dist/transform/write/array.d.ts.map +0 -1
  239. package/dist/transform/write/array.js +0 -58
  240. package/dist/transform/write/array.js.map +0 -1
  241. package/dist/transform/write/blocks.d.ts +0 -25
  242. package/dist/transform/write/blocks.d.ts.map +0 -1
  243. package/dist/transform/write/blocks.js +0 -54
  244. package/dist/transform/write/blocks.js.map +0 -1
  245. package/dist/transform/write/index.d.ts +0 -13
  246. package/dist/transform/write/index.d.ts.map +0 -1
  247. package/dist/transform/write/index.js +0 -41
  248. package/dist/transform/write/index.js.map +0 -1
  249. package/dist/transform/write/numbers.d.ts +0 -8
  250. package/dist/transform/write/numbers.d.ts.map +0 -1
  251. package/dist/transform/write/numbers.js +0 -11
  252. package/dist/transform/write/numbers.js.map +0 -1
  253. package/dist/transform/write/relationships.d.ts +0 -10
  254. package/dist/transform/write/relationships.d.ts.map +0 -1
  255. package/dist/transform/write/relationships.js +0 -23
  256. package/dist/transform/write/relationships.js.map +0 -1
  257. package/dist/transform/write/selects.d.ts +0 -8
  258. package/dist/transform/write/selects.d.ts.map +0 -1
  259. package/dist/transform/write/selects.js +0 -20
  260. package/dist/transform/write/selects.js.map +0 -1
  261. package/dist/transform/write/texts.d.ts +0 -8
  262. package/dist/transform/write/texts.d.ts.map +0 -1
  263. package/dist/transform/write/texts.js +0 -11
  264. package/dist/transform/write/texts.js.map +0 -1
  265. package/dist/transform/write/traverseFields.d.ts +0 -50
  266. package/dist/transform/write/traverseFields.d.ts.map +0 -1
  267. package/dist/transform/write/traverseFields.js +0 -445
  268. package/dist/transform/write/traverseFields.js.map +0 -1
  269. package/dist/transform/write/types.d.ts +0 -43
  270. package/dist/transform/write/types.d.ts.map +0 -1
  271. package/dist/transform/write/types.js +0 -3
  272. package/dist/transform/write/types.js.map +0 -1
  273. package/dist/update.d.ts +0 -3
  274. package/dist/update.d.ts.map +0 -1
  275. package/dist/update.js +0 -54
  276. package/dist/update.js.map +0 -1
  277. package/dist/updateGlobal.d.ts +0 -4
  278. package/dist/updateGlobal.d.ts.map +0 -1
  279. package/dist/updateGlobal.js +0 -25
  280. package/dist/updateGlobal.js.map +0 -1
  281. package/dist/updateGlobalVersion.d.ts +0 -4
  282. package/dist/updateGlobalVersion.d.ts.map +0 -1
  283. package/dist/updateGlobalVersion.js +0 -36
  284. package/dist/updateGlobalVersion.js.map +0 -1
  285. package/dist/updateVersion.d.ts +0 -4
  286. package/dist/updateVersion.d.ts.map +0 -1
  287. package/dist/updateVersion.js +0 -36
  288. package/dist/updateVersion.js.map +0 -1
  289. package/dist/upsertRow/deleteExistingArrayRows.d.ts +0 -10
  290. package/dist/upsertRow/deleteExistingArrayRows.d.ts.map +0 -1
  291. package/dist/upsertRow/deleteExistingArrayRows.js +0 -10
  292. package/dist/upsertRow/deleteExistingArrayRows.js.map +0 -1
  293. package/dist/upsertRow/deleteExistingRowsByPath.d.ts +0 -14
  294. package/dist/upsertRow/deleteExistingRowsByPath.d.ts.map +0 -1
  295. package/dist/upsertRow/deleteExistingRowsByPath.js +0 -33
  296. package/dist/upsertRow/deleteExistingRowsByPath.js.map +0 -1
  297. package/dist/upsertRow/index.d.ts +0 -4
  298. package/dist/upsertRow/index.d.ts.map +0 -1
  299. package/dist/upsertRow/index.js +0 -281
  300. package/dist/upsertRow/index.js.map +0 -1
  301. package/dist/upsertRow/insertArrays.d.ts +0 -13
  302. package/dist/upsertRow/insertArrays.d.ts.map +0 -1
  303. package/dist/upsertRow/insertArrays.js +0 -68
  304. package/dist/upsertRow/insertArrays.js.map +0 -1
  305. package/dist/upsertRow/types.d.ts +0 -32
  306. package/dist/upsertRow/types.d.ts.map +0 -1
  307. package/dist/upsertRow/types.js +0 -3
  308. package/dist/upsertRow/types.js.map +0 -1
  309. package/dist/utilities/appendPrefixToKeys.d.ts +0 -2
  310. package/dist/utilities/appendPrefixToKeys.d.ts.map +0 -1
  311. package/dist/utilities/appendPrefixToKeys.js +0 -6
  312. package/dist/utilities/appendPrefixToKeys.js.map +0 -1
  313. package/dist/utilities/createBlocksMap.d.ts +0 -5
  314. package/dist/utilities/createBlocksMap.d.ts.map +0 -1
  315. package/dist/utilities/createBlocksMap.js +0 -29
  316. package/dist/utilities/createBlocksMap.js.map +0 -1
  317. package/dist/utilities/createMigrationTable.d.ts +0 -3
  318. package/dist/utilities/createMigrationTable.d.ts.map +0 -1
  319. package/dist/utilities/createMigrationTable.js +0 -13
  320. package/dist/utilities/createMigrationTable.js.map +0 -1
  321. package/dist/utilities/createRelationshipMap.d.ts +0 -2
  322. package/dist/utilities/createRelationshipMap.d.ts.map +0 -1
  323. package/dist/utilities/createRelationshipMap.js +0 -19
  324. package/dist/utilities/createRelationshipMap.js.map +0 -1
  325. package/dist/utilities/hasLocalesTable.d.ts +0 -3
  326. package/dist/utilities/hasLocalesTable.d.ts.map +0 -1
  327. package/dist/utilities/hasLocalesTable.js +0 -11
  328. package/dist/utilities/hasLocalesTable.js.map +0 -1
  329. package/dist/utilities/isArrayOfRows.d.ts +0 -2
  330. package/dist/utilities/isArrayOfRows.d.ts.map +0 -1
  331. package/dist/utilities/isArrayOfRows.js +0 -5
  332. package/dist/utilities/isArrayOfRows.js.map +0 -1
  333. package/dist/utilities/migrationTableExists.d.ts +0 -3
  334. package/dist/utilities/migrationTableExists.d.ts.map +0 -1
  335. package/dist/utilities/migrationTableExists.js +0 -9
  336. package/dist/utilities/migrationTableExists.js.map +0 -1
  337. package/dist/utilities/parseError.d.ts +0 -5
  338. package/dist/utilities/parseError.d.ts.map +0 -1
  339. package/dist/utilities/parseError.js +0 -17
  340. package/dist/utilities/parseError.js.map +0 -1
  341. package/dist/utilities/pushDevSchema.d.ts +0 -9
  342. package/dist/utilities/pushDevSchema.d.ts.map +0 -1
  343. package/dist/utilities/pushDevSchema.js +0 -58
  344. package/dist/utilities/pushDevSchema.js.map +0 -1
@@ -1,516 +0,0 @@
1
- /* eslint-disable no-param-reassign */ import { and, eq, like, sql } from 'drizzle-orm';
2
- import { alias } from 'drizzle-orm/pg-core';
3
- import { APIError, flattenTopLevelFields } from 'payload';
4
- import { fieldAffectsData, tabHasName } from 'payload/shared';
5
- import toSnakeCase from 'to-snake-case';
6
- import { v4 as uuid } from 'uuid';
7
- /**
8
- * Transforms path to table and column name
9
- * Adds tables to `join`
10
- * @returns TableColumn
11
- */ export const getTableColumnFromPath = ({ adapter, aliasTable, collectionPath, columnPrefix = '', constraintPath: incomingConstraintPath, constraints = [], fields, joins, locale: incomingLocale, pathSegments: incomingSegments, rootTableName: incomingRootTableName, selectFields, tableName, tableNameSuffix = '', value })=>{
12
- const fieldPath = incomingSegments[0];
13
- let locale = incomingLocale;
14
- const rootTableName = incomingRootTableName || tableName;
15
- let constraintPath = incomingConstraintPath || '';
16
- const field = flattenTopLevelFields(fields).find((fieldToFind)=>fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath);
17
- let newTableName = tableName;
18
- if (!field && fieldPath === 'id') {
19
- selectFields.id = adapter.tables[newTableName].id;
20
- return {
21
- columnName: 'id',
22
- constraints,
23
- field: {
24
- name: 'id',
25
- type: adapter.idType === 'uuid' ? 'text' : 'number'
26
- },
27
- table: adapter.tables[newTableName]
28
- };
29
- }
30
- if (field) {
31
- const pathSegments = [
32
- ...incomingSegments
33
- ];
34
- // If next segment is a locale,
35
- // we need to take it out and use it as the locale from this point on
36
- if ('localized' in field && field.localized && adapter.payload.config.localization) {
37
- const matchedLocale = adapter.payload.config.localization.localeCodes.find((locale)=>locale === pathSegments[1]);
38
- if (matchedLocale) {
39
- locale = matchedLocale;
40
- pathSegments.splice(1, 1);
41
- }
42
- }
43
- switch(field.type){
44
- case 'tabs':
45
- {
46
- return getTableColumnFromPath({
47
- adapter,
48
- aliasTable,
49
- collectionPath,
50
- columnPrefix,
51
- constraintPath,
52
- constraints,
53
- fields: field.tabs.map((tab)=>({
54
- ...tab,
55
- type: 'tab'
56
- })),
57
- joins,
58
- locale,
59
- pathSegments: pathSegments.slice(1),
60
- rootTableName,
61
- selectFields,
62
- tableName: newTableName,
63
- tableNameSuffix,
64
- value
65
- });
66
- }
67
- case 'tab':
68
- {
69
- if (tabHasName(field)) {
70
- return getTableColumnFromPath({
71
- adapter,
72
- aliasTable,
73
- collectionPath,
74
- columnPrefix: `${columnPrefix}${field.name}_`,
75
- constraintPath: `${constraintPath}${field.name}.`,
76
- constraints,
77
- fields: field.fields,
78
- joins,
79
- locale,
80
- pathSegments: pathSegments.slice(1),
81
- rootTableName,
82
- selectFields,
83
- tableName: newTableName,
84
- tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
85
- value
86
- });
87
- }
88
- return getTableColumnFromPath({
89
- adapter,
90
- aliasTable,
91
- collectionPath,
92
- columnPrefix,
93
- constraintPath,
94
- constraints,
95
- fields: field.fields,
96
- joins,
97
- locale,
98
- pathSegments: pathSegments.slice(1),
99
- rootTableName,
100
- selectFields,
101
- tableName: newTableName,
102
- tableNameSuffix,
103
- value
104
- });
105
- }
106
- case 'group':
107
- {
108
- if (locale && field.localized && adapter.payload.config.localization) {
109
- newTableName = `${tableName}${adapter.localesSuffix}`;
110
- joins.push({
111
- condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),
112
- table: adapter.tables[newTableName]
113
- });
114
- if (locale !== 'all') {
115
- constraints.push({
116
- columnName: '_locale',
117
- table: adapter.tables[newTableName],
118
- value: locale
119
- });
120
- }
121
- }
122
- return getTableColumnFromPath({
123
- adapter,
124
- aliasTable,
125
- collectionPath,
126
- columnPrefix: `${columnPrefix}${field.name}_`,
127
- constraintPath: `${constraintPath}${field.name}.`,
128
- constraints,
129
- fields: field.fields,
130
- joins,
131
- locale,
132
- pathSegments: pathSegments.slice(1),
133
- rootTableName,
134
- selectFields,
135
- tableName: newTableName,
136
- tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,
137
- value
138
- });
139
- }
140
- case 'select':
141
- {
142
- if (field.hasMany) {
143
- const newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
144
- if (locale && field.localized && adapter.payload.config.localization) {
145
- joins.push({
146
- condition: and(eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent), eq(adapter.tables[newTableName]._locale, locale)),
147
- table: adapter.tables[newTableName]
148
- });
149
- if (locale !== 'all') {
150
- constraints.push({
151
- columnName: '_locale',
152
- table: adapter.tables[newTableName],
153
- value: locale
154
- });
155
- }
156
- } else {
157
- joins.push({
158
- condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
159
- table: adapter.tables[newTableName]
160
- });
161
- }
162
- return {
163
- columnName: 'value',
164
- constraints,
165
- field,
166
- table: adapter.tables[newTableName]
167
- };
168
- }
169
- break;
170
- }
171
- case 'text':
172
- case 'number':
173
- {
174
- if (field.hasMany) {
175
- let tableType = 'texts';
176
- let columnName = 'text';
177
- if (field.type === 'number') {
178
- tableType = 'numbers';
179
- columnName = 'number';
180
- }
181
- newTableName = `${tableName}_${tableType}`;
182
- const joinConstraints = [
183
- eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),
184
- eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`)
185
- ];
186
- if (locale && field.localized && adapter.payload.config.localization) {
187
- joins.push({
188
- condition: and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale)),
189
- table: adapter.tables[newTableName]
190
- });
191
- if (locale !== 'all') {
192
- constraints.push({
193
- columnName: 'locale',
194
- table: adapter.tables[newTableName],
195
- value: locale
196
- });
197
- }
198
- } else {
199
- joins.push({
200
- condition: and(...joinConstraints),
201
- table: adapter.tables[newTableName]
202
- });
203
- }
204
- return {
205
- columnName,
206
- constraints,
207
- field,
208
- table: adapter.tables[newTableName]
209
- };
210
- }
211
- break;
212
- }
213
- case 'array':
214
- {
215
- newTableName = adapter.tableNameMap.get(`${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`);
216
- constraintPath = `${constraintPath}${field.name}.%.`;
217
- if (locale && field.localized && adapter.payload.config.localization) {
218
- joins.push({
219
- condition: and(eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale)),
220
- table: adapter.tables[newTableName]
221
- });
222
- if (locale !== 'all') {
223
- constraints.push({
224
- columnName: '_locale',
225
- table: adapter.tables[newTableName],
226
- value: locale
227
- });
228
- }
229
- } else {
230
- joins.push({
231
- condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),
232
- table: adapter.tables[newTableName]
233
- });
234
- }
235
- return getTableColumnFromPath({
236
- adapter,
237
- collectionPath,
238
- constraintPath,
239
- constraints,
240
- fields: field.fields,
241
- joins,
242
- locale,
243
- pathSegments: pathSegments.slice(1),
244
- rootTableName,
245
- selectFields,
246
- tableName: newTableName,
247
- value
248
- });
249
- }
250
- case 'blocks':
251
- {
252
- let blockTableColumn;
253
- let newTableName;
254
- // handle blockType queries
255
- if (pathSegments[1] === 'blockType') {
256
- // find the block config using the value
257
- const blockTypes = Array.isArray(value) ? value : [
258
- value
259
- ];
260
- blockTypes.forEach((blockType)=>{
261
- const block = field.blocks.find((block)=>block.slug === blockType);
262
- newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`);
263
- const newAliasTableName = toSnakeCase(uuid());
264
- const newAliasTable = alias(adapter.tables[newTableName], newAliasTableName);
265
- joins.push({
266
- condition: eq(adapter.tables[tableName].id, newAliasTable._parentID),
267
- table: newAliasTable
268
- });
269
- constraints.push({
270
- columnName: '_path',
271
- table: newAliasTable,
272
- value: pathSegments[0]
273
- });
274
- });
275
- return {
276
- constraints,
277
- field,
278
- getNotNullColumnByValue: ()=>'id',
279
- table: adapter.tables[tableName]
280
- };
281
- }
282
- const hasBlockField = field.blocks.some((block)=>{
283
- newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`);
284
- constraintPath = `${constraintPath}${field.name}.%.`;
285
- let result;
286
- const blockConstraints = [];
287
- const blockSelectFields = {};
288
- try {
289
- result = getTableColumnFromPath({
290
- adapter,
291
- collectionPath,
292
- constraintPath,
293
- constraints: blockConstraints,
294
- fields: block.fields,
295
- joins,
296
- locale,
297
- pathSegments: pathSegments.slice(1),
298
- rootTableName,
299
- selectFields: blockSelectFields,
300
- tableName: newTableName,
301
- value
302
- });
303
- } catch (error) {
304
- // this is fine, not every block will have the field
305
- }
306
- if (!result) {
307
- return;
308
- }
309
- blockTableColumn = result;
310
- constraints = constraints.concat(blockConstraints);
311
- selectFields = {
312
- ...selectFields,
313
- ...blockSelectFields
314
- };
315
- if (field.localized && adapter.payload.config.localization) {
316
- joins.push({
317
- condition: and(eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID), eq(adapter.tables[newTableName]._locale, locale)),
318
- table: adapter.tables[newTableName]
319
- });
320
- if (locale) {
321
- constraints.push({
322
- columnName: '_locale',
323
- table: adapter.tables[newTableName],
324
- value: locale
325
- });
326
- }
327
- } else {
328
- joins.push({
329
- condition: eq((aliasTable || adapter.tables[tableName]).id, adapter.tables[newTableName]._parentID),
330
- table: adapter.tables[newTableName]
331
- });
332
- }
333
- return true;
334
- });
335
- if (hasBlockField) {
336
- return {
337
- columnName: blockTableColumn.columnName,
338
- constraints,
339
- field: blockTableColumn.field,
340
- pathSegments: pathSegments.slice(1),
341
- rawColumn: blockTableColumn.rawColumn,
342
- table: blockTableColumn.table
343
- };
344
- }
345
- break;
346
- }
347
- case 'relationship':
348
- case 'upload':
349
- {
350
- const newCollectionPath = pathSegments.slice(1).join('.');
351
- if (Array.isArray(field.relationTo) || field.type === 'relationship' && field.hasMany) {
352
- let relationshipFields;
353
- const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`;
354
- const aliasRelationshipTableName = uuid();
355
- const aliasRelationshipTable = alias(adapter.tables[relationTableName], aliasRelationshipTableName);
356
- // Join in the relationships table
357
- if (locale && field.localized && adapter.payload.config.localization) {
358
- joins.push({
359
- condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), eq(aliasRelationshipTable.locale, locale), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
360
- table: aliasRelationshipTable
361
- });
362
- if (locale !== 'all') {
363
- constraints.push({
364
- columnName: 'locale',
365
- table: aliasRelationshipTable,
366
- value: locale
367
- });
368
- }
369
- } else {
370
- // Join in the relationships table
371
- joins.push({
372
- condition: and(eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent), like(aliasRelationshipTable.path, `${constraintPath}${field.name}`)),
373
- table: aliasRelationshipTable
374
- });
375
- }
376
- selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path;
377
- let newAliasTable;
378
- if (typeof field.relationTo === 'string') {
379
- const relationshipConfig = adapter.payload.collections[field.relationTo].config;
380
- newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug));
381
- // parent to relationship join table
382
- relationshipFields = relationshipConfig.fields;
383
- newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()));
384
- joins.push({
385
- condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),
386
- table: newAliasTable
387
- });
388
- if (newCollectionPath === '' || newCollectionPath === 'id') {
389
- return {
390
- columnName: `${field.relationTo}ID`,
391
- constraints,
392
- field,
393
- table: aliasRelationshipTable
394
- };
395
- }
396
- } else if (newCollectionPath === 'value') {
397
- const tableColumnsNames = field.relationTo.map((relationTo)=>{
398
- const relationTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[relationTo].config.slug));
399
- return `"${aliasRelationshipTableName}"."${relationTableName}_id"`;
400
- });
401
- return {
402
- constraints,
403
- field,
404
- rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),
405
- table: aliasRelationshipTable
406
- };
407
- } else if (newCollectionPath === 'relationTo') {
408
- const relationTo = Array.isArray(field.relationTo) ? field.relationTo : [
409
- field.relationTo
410
- ];
411
- return {
412
- constraints,
413
- field,
414
- getNotNullColumnByValue: (val)=>{
415
- const matchedRelation = relationTo.find((relation)=>relation === val);
416
- if (matchedRelation) return `${matchedRelation}ID`;
417
- return undefined;
418
- },
419
- table: aliasRelationshipTable
420
- };
421
- } else {
422
- throw new APIError('Not supported');
423
- }
424
- return getTableColumnFromPath({
425
- adapter,
426
- aliasTable: newAliasTable,
427
- collectionPath: newCollectionPath,
428
- constraints,
429
- fields: relationshipFields,
430
- joins,
431
- locale,
432
- pathSegments: pathSegments.slice(1),
433
- rootTableName: newTableName,
434
- selectFields,
435
- tableName: newTableName,
436
- value
437
- });
438
- } else if (pathSegments.length > 1 && !(pathSegments.length === 2 && pathSegments[1] === 'id')) {
439
- // simple relationships
440
- const columnName = `${columnPrefix}${field.name}`;
441
- const newTableName = adapter.tableNameMap.get(toSnakeCase(adapter.payload.collections[field.relationTo].config.slug));
442
- const aliasTableName = uuid();
443
- const newAliasTable = alias(adapter.tables[newTableName], aliasTableName);
444
- if (field.localized && adapter.payload.config.localization) {
445
- const aliasLocaleTableName = uuid();
446
- const aliasLocaleTable = alias(adapter.tables[`${rootTableName}${adapter.localesSuffix}`], aliasLocaleTableName);
447
- joins.push({
448
- condition: and(eq(aliasLocaleTable._parentID, adapter.tables[rootTableName].id), eq(aliasLocaleTable._locale, locale)),
449
- table: aliasLocaleTable
450
- });
451
- joins.push({
452
- condition: eq(aliasLocaleTable[columnName], newAliasTable.id),
453
- table: newAliasTable
454
- });
455
- } else {
456
- joins.push({
457
- condition: eq(newAliasTable.id, aliasTable ? aliasTable[columnName] : adapter.tables[tableName][columnName]),
458
- table: newAliasTable
459
- });
460
- }
461
- return getTableColumnFromPath({
462
- adapter,
463
- aliasTable: newAliasTable,
464
- collectionPath: newCollectionPath,
465
- constraintPath: '',
466
- constraints,
467
- fields: adapter.payload.collections[field.relationTo].config.fields,
468
- joins,
469
- locale,
470
- pathSegments: pathSegments.slice(1),
471
- selectFields,
472
- tableName: newTableName,
473
- value
474
- });
475
- }
476
- break;
477
- }
478
- default:
479
- {
480
- break;
481
- }
482
- }
483
- if (fieldAffectsData(field)) {
484
- if (field.localized && adapter.payload.config.localization) {
485
- // If localized, we go to localized table and set aliasTable to undefined
486
- // so it is not picked up below to be used as targetTable
487
- const parentTable = aliasTable || adapter.tables[tableName];
488
- newTableName = `${tableName}${adapter.localesSuffix}`;
489
- joins.push({
490
- condition: eq(parentTable.id, adapter.tables[newTableName]._parentID),
491
- table: adapter.tables[newTableName]
492
- });
493
- aliasTable = undefined;
494
- if (locale !== 'all') {
495
- constraints.push({
496
- columnName: '_locale',
497
- table: adapter.tables[newTableName],
498
- value: locale
499
- });
500
- }
501
- }
502
- const targetTable = aliasTable || adapter.tables[newTableName];
503
- selectFields[`${newTableName}.${columnPrefix}${field.name}`] = targetTable[`${columnPrefix}${field.name}`];
504
- return {
505
- columnName: `${columnPrefix}${field.name}`,
506
- constraints,
507
- field,
508
- pathSegments,
509
- table: targetTable
510
- };
511
- }
512
- }
513
- throw new APIError(`Cannot find field for path at ${fieldPath}`);
514
- };
515
-
516
- //# sourceMappingURL=getTableColumnFromPath.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/getTableColumnFromPath.ts"],"sourcesContent":["/* eslint-disable no-param-reassign */\nimport type { SQL } from 'drizzle-orm'\nimport type { PgTableWithColumns } from 'drizzle-orm/pg-core'\nimport type { Field, FieldAffectingData, NumberField, TabAsField, TextField } from 'payload'\n\nimport { and, eq, like, sql } from 'drizzle-orm'\nimport { alias } from 'drizzle-orm/pg-core'\nimport { APIError, flattenTopLevelFields } from 'payload'\nimport { fieldAffectsData, tabHasName } from 'payload/shared'\nimport toSnakeCase from 'to-snake-case'\nimport { v4 as uuid } from 'uuid'\n\nimport type { GenericColumn, GenericTable, PostgresAdapter } from '../types.js'\nimport type { BuildQueryJoinAliases } from './buildQuery.js'\n\ntype Constraint = {\n columnName: string\n table: GenericTable | PgTableWithColumns<any>\n value: unknown\n}\n\ntype TableColumn = {\n columnName?: string\n constraints: Constraint[]\n field: FieldAffectingData\n getNotNullColumnByValue?: (val: unknown) => string\n pathSegments?: string[]\n rawColumn?: SQL\n table: GenericTable | PgTableWithColumns<any>\n}\n\ntype Args = {\n adapter: PostgresAdapter\n aliasTable?: GenericTable | PgTableWithColumns<any>\n collectionPath: string\n columnPrefix?: string\n constraintPath?: string\n constraints?: Constraint[]\n fields: (Field | TabAsField)[]\n joins: BuildQueryJoinAliases\n locale?: string\n pathSegments: string[]\n rootTableName?: string\n selectFields: Record<string, GenericColumn>\n tableName: string\n /**\n * If creating a new table name for arrays and blocks, this suffix should be appended to the table name\n */\n tableNameSuffix?: string\n /**\n * The raw value of the query before sanitization\n */\n value: unknown\n}\n/**\n * Transforms path to table and column name\n * Adds tables to `join`\n * @returns TableColumn\n */\nexport const getTableColumnFromPath = ({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix = '',\n constraintPath: incomingConstraintPath,\n constraints = [],\n fields,\n joins,\n locale: incomingLocale,\n pathSegments: incomingSegments,\n rootTableName: incomingRootTableName,\n selectFields,\n tableName,\n tableNameSuffix = '',\n value,\n}: Args): TableColumn => {\n const fieldPath = incomingSegments[0]\n let locale = incomingLocale\n const rootTableName = incomingRootTableName || tableName\n let constraintPath = incomingConstraintPath || ''\n\n const field = flattenTopLevelFields(fields as Field[]).find(\n (fieldToFind) => fieldAffectsData(fieldToFind) && fieldToFind.name === fieldPath,\n ) as Field | TabAsField\n let newTableName = tableName\n\n if (!field && fieldPath === 'id') {\n selectFields.id = adapter.tables[newTableName].id\n return {\n columnName: 'id',\n constraints,\n field: {\n name: 'id',\n type: adapter.idType === 'uuid' ? 'text' : 'number',\n } as NumberField | TextField,\n table: adapter.tables[newTableName],\n }\n }\n\n if (field) {\n const pathSegments = [...incomingSegments]\n\n // If next segment is a locale,\n // we need to take it out and use it as the locale from this point on\n if ('localized' in field && field.localized && adapter.payload.config.localization) {\n const matchedLocale = adapter.payload.config.localization.localeCodes.find(\n (locale) => locale === pathSegments[1],\n )\n\n if (matchedLocale) {\n locale = matchedLocale\n pathSegments.splice(1, 1)\n }\n }\n\n switch (field.type) {\n case 'tabs': {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.tabs.map((tab) => ({\n ...tab,\n type: 'tab',\n })),\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n case 'tab': {\n if (tabHasName(field)) {\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix,\n constraintPath,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix,\n value,\n })\n }\n\n case 'group': {\n if (locale && field.localized && adapter.payload.config.localization) {\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n joins.push({\n condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n return getTableColumnFromPath({\n adapter,\n aliasTable,\n collectionPath,\n columnPrefix: `${columnPrefix}${field.name}_`,\n constraintPath: `${constraintPath}${field.name}.`,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n tableNameSuffix: `${tableNameSuffix}${toSnakeCase(field.name)}_`,\n value,\n })\n }\n\n case 'select': {\n if (field.hasMany) {\n const newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName]._locale, locale),\n ),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n table: adapter.tables[newTableName],\n })\n }\n\n return {\n columnName: 'value',\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'text':\n case 'number': {\n if (field.hasMany) {\n let tableType = 'texts'\n let columnName = 'text'\n if (field.type === 'number') {\n tableType = 'numbers'\n columnName = 'number'\n }\n newTableName = `${tableName}_${tableType}`\n const joinConstraints = [\n eq(adapter.tables[tableName].id, adapter.tables[newTableName].parent),\n eq(adapter.tables[newTableName].path, `${constraintPath}${field.name}`),\n ]\n\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(...joinConstraints, eq(adapter.tables[newTableName]._locale, locale)),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: and(...joinConstraints),\n table: adapter.tables[newTableName],\n })\n }\n\n return {\n columnName,\n constraints,\n field,\n table: adapter.tables[newTableName],\n }\n }\n break\n }\n\n case 'array': {\n newTableName = adapter.tableNameMap.get(\n `${tableName}_${tableNameSuffix}${toSnakeCase(field.name)}`,\n )\n\n constraintPath = `${constraintPath}${field.name}.%.`\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n eq(adapter.tables[newTableName]._locale, locale),\n ),\n table: adapter.tables[newTableName],\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: eq(adapter.tables[tableName].id, adapter.tables[newTableName]._parentID),\n table: adapter.tables[newTableName],\n })\n }\n return getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints,\n fields: field.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n\n case 'blocks': {\n let blockTableColumn: TableColumn\n let newTableName: string\n\n // handle blockType queries\n if (pathSegments[1] === 'blockType') {\n // find the block config using the value\n const blockTypes = Array.isArray(value) ? value : [value]\n blockTypes.forEach((blockType) => {\n const block = field.blocks.find((block) => block.slug === blockType)\n newTableName = adapter.tableNameMap.get(\n `${tableName}_blocks_${toSnakeCase(block.slug)}`,\n )\n const newAliasTableName = toSnakeCase(uuid())\n const newAliasTable = alias(adapter.tables[newTableName], newAliasTableName)\n\n joins.push({\n condition: eq(adapter.tables[tableName].id, newAliasTable._parentID),\n table: newAliasTable,\n })\n constraints.push({\n columnName: '_path',\n table: newAliasTable,\n value: pathSegments[0],\n })\n })\n return {\n constraints,\n field,\n getNotNullColumnByValue: () => 'id',\n table: adapter.tables[tableName],\n }\n }\n\n const hasBlockField = field.blocks.some((block) => {\n newTableName = adapter.tableNameMap.get(`${tableName}_blocks_${toSnakeCase(block.slug)}`)\n constraintPath = `${constraintPath}${field.name}.%.`\n\n let result\n const blockConstraints = []\n const blockSelectFields = {}\n try {\n result = getTableColumnFromPath({\n adapter,\n collectionPath,\n constraintPath,\n constraints: blockConstraints,\n fields: block.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName,\n selectFields: blockSelectFields,\n tableName: newTableName,\n value,\n })\n } catch (error) {\n // this is fine, not every block will have the field\n }\n if (!result) {\n return\n }\n blockTableColumn = result\n constraints = constraints.concat(blockConstraints)\n selectFields = { ...selectFields, ...blockSelectFields }\n if (field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq(\n (aliasTable || adapter.tables[tableName]).id,\n adapter.tables[newTableName]._parentID,\n ),\n eq(adapter.tables[newTableName]._locale, locale),\n ),\n table: adapter.tables[newTableName],\n })\n if (locale) {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n } else {\n joins.push({\n condition: eq(\n (aliasTable || adapter.tables[tableName]).id,\n adapter.tables[newTableName]._parentID,\n ),\n table: adapter.tables[newTableName],\n })\n }\n return true\n })\n if (hasBlockField) {\n return {\n columnName: blockTableColumn.columnName,\n constraints,\n field: blockTableColumn.field,\n pathSegments: pathSegments.slice(1),\n rawColumn: blockTableColumn.rawColumn,\n table: blockTableColumn.table,\n }\n }\n break\n }\n\n case 'relationship':\n case 'upload': {\n const newCollectionPath = pathSegments.slice(1).join('.')\n if (Array.isArray(field.relationTo) || (field.type === 'relationship' && field.hasMany)) {\n let relationshipFields\n const relationTableName = `${rootTableName}${adapter.relationshipsSuffix}`\n const aliasRelationshipTableName = uuid()\n const aliasRelationshipTable = alias(\n adapter.tables[relationTableName],\n aliasRelationshipTableName,\n )\n\n // Join in the relationships table\n if (locale && field.localized && adapter.payload.config.localization) {\n joins.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n eq(aliasRelationshipTable.locale, locale),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n if (locale !== 'all') {\n constraints.push({\n columnName: 'locale',\n table: aliasRelationshipTable,\n value: locale,\n })\n }\n } else {\n // Join in the relationships table\n joins.push({\n condition: and(\n eq((aliasTable || adapter.tables[rootTableName]).id, aliasRelationshipTable.parent),\n like(aliasRelationshipTable.path, `${constraintPath}${field.name}`),\n ),\n table: aliasRelationshipTable,\n })\n }\n\n selectFields[`${relationTableName}.path`] = aliasRelationshipTable.path\n\n let newAliasTable\n\n if (typeof field.relationTo === 'string') {\n const relationshipConfig = adapter.payload.collections[field.relationTo].config\n\n newTableName = adapter.tableNameMap.get(toSnakeCase(relationshipConfig.slug))\n\n // parent to relationship join table\n relationshipFields = relationshipConfig.fields\n\n newAliasTable = alias(adapter.tables[newTableName], toSnakeCase(uuid()))\n\n joins.push({\n condition: eq(newAliasTable.id, aliasRelationshipTable[`${field.relationTo}ID`]),\n table: newAliasTable,\n })\n\n if (newCollectionPath === '' || newCollectionPath === 'id') {\n return {\n columnName: `${field.relationTo}ID`,\n constraints,\n field,\n table: aliasRelationshipTable,\n }\n }\n } else if (newCollectionPath === 'value') {\n const tableColumnsNames = field.relationTo.map((relationTo) => {\n const relationTableName = adapter.tableNameMap.get(\n toSnakeCase(adapter.payload.collections[relationTo].config.slug),\n )\n\n return `\"${aliasRelationshipTableName}\".\"${relationTableName}_id\"`\n })\n return {\n constraints,\n field,\n rawColumn: sql.raw(`COALESCE(${tableColumnsNames.join(', ')})`),\n table: aliasRelationshipTable,\n }\n } else if (newCollectionPath === 'relationTo') {\n const relationTo = Array.isArray(field.relationTo)\n ? field.relationTo\n : [field.relationTo]\n\n return {\n constraints,\n field,\n getNotNullColumnByValue: (val) => {\n const matchedRelation = relationTo.find((relation) => relation === val)\n if (matchedRelation) return `${matchedRelation}ID`\n return undefined\n },\n table: aliasRelationshipTable,\n }\n } else {\n throw new APIError('Not supported')\n }\n\n return getTableColumnFromPath({\n adapter,\n aliasTable: newAliasTable,\n collectionPath: newCollectionPath,\n constraints,\n fields: relationshipFields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n rootTableName: newTableName,\n selectFields,\n tableName: newTableName,\n value,\n })\n } else if (\n pathSegments.length > 1 &&\n !(pathSegments.length === 2 && pathSegments[1] === 'id')\n ) {\n // simple relationships\n const columnName = `${columnPrefix}${field.name}`\n const newTableName = adapter.tableNameMap.get(\n toSnakeCase(adapter.payload.collections[field.relationTo].config.slug),\n )\n const aliasTableName = uuid()\n const newAliasTable = alias(adapter.tables[newTableName], aliasTableName)\n\n if (field.localized && adapter.payload.config.localization) {\n const aliasLocaleTableName = uuid()\n const aliasLocaleTable = alias(\n adapter.tables[`${rootTableName}${adapter.localesSuffix}`],\n aliasLocaleTableName,\n )\n joins.push({\n condition: and(\n eq(aliasLocaleTable._parentID, adapter.tables[rootTableName].id),\n eq(aliasLocaleTable._locale, locale),\n ),\n table: aliasLocaleTable,\n })\n joins.push({\n condition: eq(aliasLocaleTable[columnName], newAliasTable.id),\n table: newAliasTable,\n })\n } else {\n joins.push({\n condition: eq(\n newAliasTable.id,\n aliasTable ? aliasTable[columnName] : adapter.tables[tableName][columnName],\n ),\n table: newAliasTable,\n })\n }\n\n return getTableColumnFromPath({\n adapter,\n aliasTable: newAliasTable,\n collectionPath: newCollectionPath,\n constraintPath: '',\n constraints,\n fields: adapter.payload.collections[field.relationTo].config.fields,\n joins,\n locale,\n pathSegments: pathSegments.slice(1),\n selectFields,\n tableName: newTableName,\n value,\n })\n }\n break\n }\n\n default: {\n // fall through\n break\n }\n }\n\n if (fieldAffectsData(field)) {\n if (field.localized && adapter.payload.config.localization) {\n // If localized, we go to localized table and set aliasTable to undefined\n // so it is not picked up below to be used as targetTable\n const parentTable = aliasTable || adapter.tables[tableName]\n newTableName = `${tableName}${adapter.localesSuffix}`\n\n joins.push({\n condition: eq(parentTable.id, adapter.tables[newTableName]._parentID),\n table: adapter.tables[newTableName],\n })\n\n aliasTable = undefined\n\n if (locale !== 'all') {\n constraints.push({\n columnName: '_locale',\n table: adapter.tables[newTableName],\n value: locale,\n })\n }\n }\n\n const targetTable = aliasTable || adapter.tables[newTableName]\n\n selectFields[`${newTableName}.${columnPrefix}${field.name}`] =\n targetTable[`${columnPrefix}${field.name}`]\n\n return {\n columnName: `${columnPrefix}${field.name}`,\n constraints,\n field,\n pathSegments,\n table: targetTable,\n }\n }\n }\n\n throw new APIError(`Cannot find field for path at ${fieldPath}`)\n}\n"],"names":["and","eq","like","sql","alias","APIError","flattenTopLevelFields","fieldAffectsData","tabHasName","toSnakeCase","v4","uuid","getTableColumnFromPath","adapter","aliasTable","collectionPath","columnPrefix","constraintPath","incomingConstraintPath","constraints","fields","joins","locale","incomingLocale","pathSegments","incomingSegments","rootTableName","incomingRootTableName","selectFields","tableName","tableNameSuffix","value","fieldPath","field","find","fieldToFind","name","newTableName","id","tables","columnName","type","idType","table","localized","payload","config","localization","matchedLocale","localeCodes","splice","tabs","map","tab","slice","localesSuffix","push","condition","_parentID","hasMany","tableNameMap","get","parent","_locale","tableType","joinConstraints","path","blockTableColumn","blockTypes","Array","isArray","forEach","blockType","block","blocks","slug","newAliasTableName","newAliasTable","getNotNullColumnByValue","hasBlockField","some","result","blockConstraints","blockSelectFields","error","concat","rawColumn","newCollectionPath","join","relationTo","relationshipFields","relationTableName","relationshipsSuffix","aliasRelationshipTableName","aliasRelationshipTable","relationshipConfig","collections","tableColumnsNames","raw","val","matchedRelation","relation","undefined","length","aliasTableName","aliasLocaleTableName","aliasLocaleTable","parentTable","targetTable"],"mappings":"AAAA,oCAAoC,GAKpC,SAASA,GAAG,EAAEC,EAAE,EAAEC,IAAI,EAAEC,GAAG,QAAQ,cAAa;AAChD,SAASC,KAAK,QAAQ,sBAAqB;AAC3C,SAASC,QAAQ,EAAEC,qBAAqB,QAAQ,UAAS;AACzD,SAASC,gBAAgB,EAAEC,UAAU,QAAQ,iBAAgB;AAC7D,OAAOC,iBAAiB,gBAAe;AACvC,SAASC,MAAMC,IAAI,QAAQ,OAAM;AA4CjC;;;;CAIC,GACD,OAAO,MAAMC,yBAAyB,CAAC,EACrCC,OAAO,EACPC,UAAU,EACVC,cAAc,EACdC,eAAe,EAAE,EACjBC,gBAAgBC,sBAAsB,EACtCC,cAAc,EAA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F;oBACA;gBACF;YAEA;gBAAS;oBAEP;gBACF;QACF;QAEA,IAAIxB,iBAAiB0B,QAAQ;YAC3B,IAAIA,MAAMW,SAAS,IAAI/B,QAAQgC,OAAO,CAACC,MAAM,CAACC,YAAY,EAAE;gBAC1D,yEAAyE;gBACzE,yDAAyD;gBACzD,MAAM4D,cAAc7F,cAAcD,QAAQ0B,MAAM,CAACV,UAAU;gBAC3DQ,eAAe,CAAC,EAAER,UAAU,EAAEhB,QAAQ0C,aAAa,CAAC,CAAC;gBAErDlC,MAAMmC,IAAI,CAAC;oBACTC,WAAWxD,GAAG0G,YAAYrE,EAAE,EAAEzB,QAAQ0B,MAAM,CAACF,aAAa,CAACqB,SAAS;oBACpEf,OAAO9B,QAAQ0B,MAAM,CAACF,aAAa;gBACrC;gBAEAvB,aAAawF;gBAEb,IAAIhF,WAAW,OAAO;oBACpBH,YAAYqC,IAAI,CAAC;wBACfhB,YAAY;wBACZG,OAAO9B,QAAQ0B,MAAM,CAACF,aAAa;wBACnCN,OAAOT;oBACT;gBACF;YACF;YAEA,MAAMsF,cAAc9F,cAAcD,QAAQ0B,MAAM,CAACF,aAAa;YAE9DT,YAAY,CAAC,CAAC,EAAES,aAAa,CAAC,EAAErB,aAAa,EAAEiB,MAAMG,IAAI,CAAC,CAAC,CAAC,GAC1DwE,WAAW,CAAC,CAAC,EAAE5F,aAAa,EAAEiB,MAAMG,IAAI,CAAC,CAAC,CAAC;YAE7C,OAAO;gBACLI,YAAY,CAAC,EAAExB,aAAa,EAAEiB,MAAMG,IAAI,CAAC,CAAC;gBAC1CjB;gBACAc;gBACAT;gBACAmB,OAAOiE;YACT;QACF;IACF;IAEA,MAAM,IAAIvG,SAAS,CAAC,8BAA8B,EAAE2B,UAAU,CAAC;AACjE,EAAC"}
@@ -1,18 +0,0 @@
1
- import { and, ilike, inArray, isNotNull, isNull, notInArray, or } from 'drizzle-orm';
2
- export declare const operatorMap: {
3
- and: typeof and;
4
- contains: typeof ilike;
5
- equals: import("drizzle-orm").BinaryOperator;
6
- exists: typeof isNotNull;
7
- greater_than: import("drizzle-orm").BinaryOperator;
8
- greater_than_equal: import("drizzle-orm").BinaryOperator;
9
- in: typeof inArray;
10
- isNull: typeof isNull;
11
- less_than: import("drizzle-orm").BinaryOperator;
12
- less_than_equal: import("drizzle-orm").BinaryOperator;
13
- like: typeof ilike;
14
- not_equals: import("drizzle-orm").BinaryOperator;
15
- not_in: typeof notInArray;
16
- or: typeof or;
17
- };
18
- //# sourceMappingURL=operatorMap.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"operatorMap.d.ts","sourceRoot":"","sources":["../../src/queries/operatorMap.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,GAAG,EAIH,KAAK,EACL,OAAO,EACP,SAAS,EACT,MAAM,EAIN,UAAU,EACV,EAAE,EACH,MAAM,aAAa,CAAA;AAEpB,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;CAoBvB,CAAA"}
@@ -1,24 +0,0 @@
1
- import { and, eq, gt, gte, ilike, inArray, isNotNull, isNull, lt, lte, ne, notInArray, or } from 'drizzle-orm';
2
- export const operatorMap = {
3
- // intersects: intersects,
4
- and,
5
- contains: ilike,
6
- equals: eq,
7
- exists: isNotNull,
8
- greater_than: gt,
9
- greater_than_equal: gte,
10
- in: inArray,
11
- isNull,
12
- less_than: lt,
13
- less_than_equal: lte,
14
- like: ilike,
15
- not_equals: ne,
16
- // TODO: geojson queries
17
- // near: near,
18
- // within: within,
19
- // all: all,
20
- not_in: notInArray,
21
- or
22
- };
23
-
24
- //# sourceMappingURL=operatorMap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/queries/operatorMap.ts"],"sourcesContent":["import {\n and,\n eq,\n gt,\n gte,\n ilike,\n inArray,\n isNotNull,\n isNull,\n lt,\n lte,\n ne,\n notInArray,\n or,\n} from 'drizzle-orm'\n\nexport const operatorMap = {\n // intersects: intersects,\n and,\n contains: ilike,\n equals: eq,\n exists: isNotNull,\n greater_than: gt,\n greater_than_equal: gte,\n in: inArray,\n isNull, // handles exists: false\n less_than: lt,\n less_than_equal: lte,\n like: ilike,\n not_equals: ne,\n // TODO: geojson queries\n // near: near,\n // within: within,\n // all: all,\n not_in: notInArray,\n or,\n}\n"],"names":["and","eq","gt","gte","ilike","inArray","isNotNull","isNull","lt","lte","ne","notInArray","or","operatorMap","contains","equals","exists","greater_than","greater_than_equal","in","less_than","less_than_equal","like","not_equals","not_in"],"mappings":"AAAA,SACEA,GAAG,EACHC,EAAE,EACFC,EAAE,EACFC,GAAG,EACHC,KAAK,EACLC,OAAO,EACPC,SAAS,EACTC,MAAM,EACNC,EAAE,EACFC,GAAG,EACHC,EAAE,EACFC,UAAU,EACVC,EAAE,QACG,cAAa;AAEpB,OAAO,MAAMC,cAAc;IACzB,0BAA0B;IAC1Bb;IACAc,UAAUV;IACVW,QAAQd;IACRe,QAAQV;IACRW,cAAcf;IACdgB,oBAAoBf;IACpBgB,IAAId;IACJE;IACAa,WAAWZ;IACXa,iBAAiBZ;IACjBa,MAAMlB;IACNmB,YAAYb;IACZ,wBAAwB;IACxB,cAAc;IACd,kBAAkB;IAClB,YAAY;IACZc,QAAQb;IACRC;AACF,EAAC"}