uql-orm 0.20.2 → 0.22.0

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.
Files changed (775) hide show
  1. package/README.md +47 -110
  2. package/dist/browser/http/bus.d.ts +0 -1
  3. package/dist/browser/http/bus.js +0 -1
  4. package/dist/browser/http/http.d.ts +0 -1
  5. package/dist/browser/http/http.js +0 -1
  6. package/dist/browser/http/index.d.ts +0 -1
  7. package/dist/browser/http/index.js +0 -1
  8. package/dist/browser/index.d.ts +0 -1
  9. package/dist/browser/index.js +0 -1
  10. package/dist/browser/options.d.ts +0 -1
  11. package/dist/browser/options.js +0 -1
  12. package/dist/browser/querier/httpQuerier.d.ts +0 -1
  13. package/dist/browser/querier/httpQuerier.js +0 -1
  14. package/dist/browser/querier/index.d.ts +0 -1
  15. package/dist/browser/querier/index.js +0 -1
  16. package/dist/browser/type/clientQuerier.d.ts +0 -1
  17. package/dist/browser/type/clientQuerier.js +0 -1
  18. package/dist/browser/type/clientQuerierPool.d.ts +0 -1
  19. package/dist/browser/type/clientQuerierPool.js +0 -1
  20. package/dist/browser/type/index.d.ts +0 -1
  21. package/dist/browser/type/index.js +0 -1
  22. package/dist/browser/type/request.d.ts +0 -1
  23. package/dist/browser/type/request.js +0 -1
  24. package/dist/browser/uql-browser.min.js +2 -2
  25. package/dist/browser/uql-browser.min.js.map +1 -1
  26. package/dist/bunSql/bunSql.util.d.ts +0 -1
  27. package/dist/bunSql/bunSql.util.js +0 -1
  28. package/dist/bunSql/bunSqlCockroachDialect.d.ts +2 -3
  29. package/dist/bunSql/bunSqlCockroachDialect.js +4 -11
  30. package/dist/bunSql/bunSqlPostgresDialect.d.ts +2 -3
  31. package/dist/bunSql/bunSqlPostgresDialect.js +4 -11
  32. package/dist/bunSql/bunSqlQuerier.d.ts +0 -1
  33. package/dist/bunSql/bunSqlQuerier.js +0 -1
  34. package/dist/bunSql/bunSqlQuerierPool.d.ts +0 -1
  35. package/dist/bunSql/bunSqlQuerierPool.js +0 -1
  36. package/dist/bunSql/bunSqliteDialect.d.ts +0 -1
  37. package/dist/bunSql/bunSqliteDialect.js +0 -1
  38. package/dist/bunSql/index.d.ts +0 -1
  39. package/dist/bunSql/index.js +0 -1
  40. package/dist/cockroachdb/cockroachDialect.d.ts +20 -5
  41. package/dist/cockroachdb/cockroachDialect.js +33 -19
  42. package/dist/cockroachdb/crdbQuerier.d.ts +0 -1
  43. package/dist/cockroachdb/crdbQuerier.js +0 -1
  44. package/dist/cockroachdb/crdbQuerierPool.d.ts +0 -1
  45. package/dist/cockroachdb/crdbQuerierPool.js +0 -1
  46. package/dist/cockroachdb/index.d.ts +0 -1
  47. package/dist/cockroachdb/index.js +0 -1
  48. package/dist/context/context.browser.d.ts +0 -1
  49. package/dist/context/context.browser.js +0 -1
  50. package/dist/context/context.d.ts +0 -1
  51. package/dist/context/context.js +0 -1
  52. package/dist/context/securityError.d.ts +0 -1
  53. package/dist/context/securityError.js +0 -1
  54. package/dist/d1/d1Querier.d.ts +4 -4
  55. package/dist/d1/d1Querier.js +0 -4
  56. package/dist/d1/d1QuerierPool.d.ts +0 -1
  57. package/dist/d1/d1QuerierPool.js +0 -1
  58. package/dist/d1/d1SqliteDialect.d.ts +7 -1
  59. package/dist/d1/d1SqliteDialect.js +9 -1
  60. package/dist/d1/index.d.ts +0 -1
  61. package/dist/d1/index.js +0 -1
  62. package/dist/dialect/abstractDialect.d.ts +21 -5
  63. package/dist/dialect/abstractDialect.js +26 -5
  64. package/dist/dialect/abstractSqlDialect.d.ts +57 -17
  65. package/dist/dialect/abstractSqlDialect.js +182 -159
  66. package/dist/dialect/index.d.ts +1 -1
  67. package/dist/dialect/index.js +1 -1
  68. package/dist/dialect/indexSqlDialect.d.ts +57 -0
  69. package/dist/dialect/indexSqlDialect.js +101 -0
  70. package/dist/dialect/jsonArrayElemMatchUtils.d.ts +0 -1
  71. package/dist/dialect/jsonArrayElemMatchUtils.js +0 -1
  72. package/dist/dialect/jsonSql.d.ts +0 -1
  73. package/dist/dialect/jsonSql.js +1 -2
  74. package/dist/dialect/mysqlLikeSqlDialect.d.ts +16 -2
  75. package/dist/dialect/mysqlLikeSqlDialect.js +34 -5
  76. package/dist/dialect/pgLikeSqlDialect.d.ts +34 -16
  77. package/dist/dialect/pgLikeSqlDialect.js +94 -71
  78. package/dist/dialect/queryContext.d.ts +0 -1
  79. package/dist/dialect/queryContext.js +0 -1
  80. package/dist/dialect/vectorCast.d.ts +32 -0
  81. package/dist/dialect/vectorCast.js +41 -0
  82. package/dist/dialect/vectorSqlDialect.d.ts +11 -5
  83. package/dist/dialect/vectorSqlDialect.js +19 -9
  84. package/dist/entity/decorator/entity.d.ts +0 -1
  85. package/dist/entity/decorator/entity.js +0 -1
  86. package/dist/entity/decorator/field.d.ts +0 -1
  87. package/dist/entity/decorator/field.js +0 -1
  88. package/dist/entity/decorator/filter.d.ts +0 -1
  89. package/dist/entity/decorator/filter.js +0 -1
  90. package/dist/entity/decorator/hook.d.ts +0 -1
  91. package/dist/entity/decorator/hook.js +0 -1
  92. package/dist/entity/decorator/id.d.ts +0 -1
  93. package/dist/entity/decorator/id.js +0 -1
  94. package/dist/entity/decorator/index-decorator.d.ts +2 -10
  95. package/dist/entity/decorator/index-decorator.js +0 -1
  96. package/dist/entity/decorator/index.d.ts +0 -1
  97. package/dist/entity/decorator/index.js +0 -1
  98. package/dist/entity/decorator/relation.d.ts +0 -1
  99. package/dist/entity/decorator/relation.js +0 -1
  100. package/dist/entity/index.d.ts +0 -1
  101. package/dist/entity/index.js +0 -1
  102. package/dist/entity/metadata/definition.d.ts +5 -6
  103. package/dist/entity/metadata/definition.js +10 -6
  104. package/dist/express/index.d.ts +0 -1
  105. package/dist/express/index.js +0 -1
  106. package/dist/express/querierMiddleware.d.ts +0 -1
  107. package/dist/express/querierMiddleware.js +0 -1
  108. package/dist/http/contract.d.ts +0 -1
  109. package/dist/http/contract.js +0 -1
  110. package/dist/http/fetchHandler.d.ts +0 -1
  111. package/dist/http/fetchHandler.js +0 -1
  112. package/dist/http/handler.d.ts +0 -1
  113. package/dist/http/handler.js +0 -1
  114. package/dist/http/index.d.ts +0 -1
  115. package/dist/http/index.js +0 -1
  116. package/dist/http/query.d.ts +0 -1
  117. package/dist/http/query.js +0 -1
  118. package/dist/index.d.ts +0 -1
  119. package/dist/index.js +0 -1
  120. package/dist/libsql/index.d.ts +0 -1
  121. package/dist/libsql/index.js +0 -1
  122. package/dist/libsql/libsqlDialect.d.ts +12 -3
  123. package/dist/libsql/libsqlDialect.js +14 -3
  124. package/dist/libsql/libsqlQuerier.d.ts +9 -23
  125. package/dist/libsql/libsqlQuerier.js +9 -78
  126. package/dist/libsql/libsqlQuerierPool.d.ts +10 -9
  127. package/dist/libsql/libsqlQuerierPool.js +17 -16
  128. package/dist/maria/index.d.ts +0 -1
  129. package/dist/maria/index.js +0 -1
  130. package/dist/maria/mariaDialect.d.ts +26 -5
  131. package/dist/maria/mariaDialect.js +54 -16
  132. package/dist/maria/mariadbQuerier.d.ts +0 -1
  133. package/dist/maria/mariadbQuerier.js +0 -1
  134. package/dist/maria/mariadbQuerierPool.d.ts +0 -1
  135. package/dist/maria/mariadbQuerierPool.js +0 -1
  136. package/dist/migrate/acquireQuerierForMigrations.d.ts +0 -1
  137. package/dist/migrate/acquireQuerierForMigrations.js +0 -1
  138. package/dist/migrate/assertCliConfig.d.ts +0 -1
  139. package/dist/migrate/assertCliConfig.js +0 -1
  140. package/dist/migrate/bin.d.ts +0 -1
  141. package/dist/migrate/bin.js +0 -1
  142. package/dist/migrate/builder/columnBuilder.d.ts +0 -1
  143. package/dist/migrate/builder/columnBuilder.js +0 -1
  144. package/dist/migrate/builder/expressions.d.ts +0 -1
  145. package/dist/migrate/builder/expressions.js +0 -1
  146. package/dist/migrate/builder/index.d.ts +0 -1
  147. package/dist/migrate/builder/index.js +0 -1
  148. package/dist/migrate/builder/migrationBuilder.d.ts +9 -30
  149. package/dist/migrate/builder/migrationBuilder.js +58 -77
  150. package/dist/migrate/builder/splitSqlStatements.d.ts +0 -3
  151. package/dist/migrate/builder/splitSqlStatements.js +0 -3
  152. package/dist/migrate/builder/tableBuilder.d.ts +12 -3
  153. package/dist/migrate/builder/tableBuilder.js +71 -120
  154. package/dist/migrate/builder/types.d.ts +30 -42
  155. package/dist/migrate/builder/types.js +0 -1
  156. package/dist/migrate/cli-config.d.ts +0 -1
  157. package/dist/migrate/cli-config.js +9 -5
  158. package/dist/migrate/cli.d.ts +3 -3
  159. package/dist/migrate/cli.js +21 -49
  160. package/dist/migrate/codegen/entityCodeGenerator.d.ts +0 -5
  161. package/dist/migrate/codegen/entityCodeGenerator.js +5 -64
  162. package/dist/migrate/codegen/fieldOptionsSource.d.ts +10 -0
  163. package/dist/migrate/codegen/fieldOptionsSource.js +55 -0
  164. package/dist/migrate/codegen/index.d.ts +0 -3
  165. package/dist/migrate/codegen/index.js +0 -5
  166. package/dist/migrate/codegen/migrationFile.d.ts +0 -1
  167. package/dist/migrate/codegen/migrationFile.js +0 -1
  168. package/dist/migrate/codegen/smartRelationDetector.d.ts +0 -1
  169. package/dist/migrate/codegen/smartRelationDetector.js +0 -1
  170. package/dist/migrate/drift/driftDetector.d.ts +0 -1
  171. package/dist/migrate/drift/driftDetector.js +0 -1
  172. package/dist/migrate/drift/index.d.ts +0 -1
  173. package/dist/migrate/drift/index.js +0 -1
  174. package/dist/migrate/generator/indexNodeToSchema.d.ts +9 -0
  175. package/dist/migrate/generator/indexNodeToSchema.js +14 -0
  176. package/dist/migrate/generator/mongoCommand.d.ts +57 -0
  177. package/dist/migrate/generator/mongoCommand.js +26 -0
  178. package/dist/migrate/generator/mongoSchemaGenerator.d.ts +9 -21
  179. package/dist/migrate/generator/mongoSchemaGenerator.js +40 -83
  180. package/dist/migrate/index.d.ts +0 -2
  181. package/dist/migrate/index.js +0 -2
  182. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts +25 -11
  183. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js +46 -33
  184. package/dist/migrate/introspection/baseSqlIntrospector.d.ts +0 -2
  185. package/dist/migrate/introspection/baseSqlIntrospector.js +3 -13
  186. package/dist/migrate/introspection/index.d.ts +0 -1
  187. package/dist/migrate/introspection/index.js +0 -1
  188. package/dist/migrate/introspection/mongoIntrospector.d.ts +0 -1
  189. package/dist/migrate/introspection/mongoIntrospector.js +2 -3
  190. package/dist/migrate/introspection/mysqlIntrospector.d.ts +5 -9
  191. package/dist/migrate/introspection/mysqlIntrospector.js +4 -11
  192. package/dist/migrate/introspection/postgresIntrospector.d.ts +5 -9
  193. package/dist/migrate/introspection/postgresIntrospector.js +4 -11
  194. package/dist/migrate/introspection/sqliteIntrospector.d.ts +6 -6
  195. package/dist/migrate/introspection/sqliteIntrospector.js +26 -19
  196. package/dist/migrate/migrator.d.ts +23 -4
  197. package/dist/migrate/migrator.js +57 -70
  198. package/dist/migrate/schemaGenerator.d.ts +26 -38
  199. package/dist/migrate/schemaGenerator.js +69 -175
  200. package/dist/migrate/schemaGeneratorAsync.d.ts +2 -3
  201. package/dist/migrate/schemaGeneratorAsync.js +3 -4
  202. package/dist/migrate/storage/databaseStorage.d.ts +0 -1
  203. package/dist/migrate/storage/databaseStorage.js +4 -5
  204. package/dist/migrate/storage/index.d.ts +0 -1
  205. package/dist/migrate/storage/index.js +0 -1
  206. package/dist/migrate/storage/jsonStorage.d.ts +0 -1
  207. package/dist/migrate/storage/jsonStorage.js +0 -1
  208. package/dist/mongo/index.d.ts +0 -1
  209. package/dist/mongo/index.js +0 -1
  210. package/dist/mongo/mongoDialect.d.ts +93 -5
  211. package/dist/mongo/mongoDialect.js +315 -83
  212. package/dist/mongo/mongodbNativeDialect.d.ts +0 -1
  213. package/dist/mongo/mongodbNativeDialect.js +0 -1
  214. package/dist/mongo/mongodbQuerier.d.ts +5 -1
  215. package/dist/mongo/mongodbQuerier.js +61 -19
  216. package/dist/mongo/mongodbQuerierPool.d.ts +0 -1
  217. package/dist/mongo/mongodbQuerierPool.js +0 -1
  218. package/dist/mysql/index.d.ts +0 -1
  219. package/dist/mysql/index.js +0 -1
  220. package/dist/mysql/mysql2Dialect.d.ts +0 -1
  221. package/dist/mysql/mysql2Dialect.js +0 -1
  222. package/dist/mysql/mysql2Querier.d.ts +0 -1
  223. package/dist/mysql/mysql2Querier.js +0 -1
  224. package/dist/mysql/mysql2QuerierPool.d.ts +0 -1
  225. package/dist/mysql/mysql2QuerierPool.js +0 -1
  226. package/dist/mysql/mysqlDialect.d.ts +8 -1
  227. package/dist/mysql/mysqlDialect.js +13 -1
  228. package/dist/namingStrategy/defaultNamingStrategy.d.ts +0 -1
  229. package/dist/namingStrategy/defaultNamingStrategy.js +0 -1
  230. package/dist/namingStrategy/index.d.ts +0 -1
  231. package/dist/namingStrategy/index.js +0 -1
  232. package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts +0 -1
  233. package/dist/namingStrategy/snakeCaseNamingStrategy.js +0 -1
  234. package/dist/neon/index.d.ts +0 -1
  235. package/dist/neon/index.js +0 -1
  236. package/dist/neon/neonDialect.d.ts +0 -1
  237. package/dist/neon/neonDialect.js +0 -1
  238. package/dist/neon/neonQuerier.d.ts +0 -1
  239. package/dist/neon/neonQuerier.js +0 -1
  240. package/dist/neon/neonQuerierPool.d.ts +0 -1
  241. package/dist/neon/neonQuerierPool.js +0 -1
  242. package/dist/nestjs/index.d.ts +0 -1
  243. package/dist/nestjs/index.js +0 -1
  244. package/dist/nestjs/uqlContextInterceptor.d.ts +0 -1
  245. package/dist/nestjs/uqlContextInterceptor.js +9 -2
  246. package/dist/nestjs/uqlModule.d.ts +0 -1
  247. package/dist/nestjs/uqlModule.js +12 -2
  248. package/dist/options.d.ts +0 -1
  249. package/dist/options.js +0 -1
  250. package/dist/postgres/abstractPgQuerier.d.ts +0 -1
  251. package/dist/postgres/abstractPgQuerier.js +0 -1
  252. package/dist/postgres/abstractPgQuerierPool.d.ts +0 -1
  253. package/dist/postgres/abstractPgQuerierPool.js +0 -1
  254. package/dist/postgres/index.d.ts +0 -1
  255. package/dist/postgres/index.js +0 -1
  256. package/dist/postgres/pgDialect.d.ts +0 -1
  257. package/dist/postgres/pgDialect.js +0 -1
  258. package/dist/postgres/pgQuerier.d.ts +0 -1
  259. package/dist/postgres/pgQuerier.js +0 -1
  260. package/dist/postgres/pgQuerierPool.d.ts +0 -1
  261. package/dist/postgres/pgQuerierPool.js +0 -1
  262. package/dist/postgres/postgresDialect.d.ts +0 -1
  263. package/dist/postgres/postgresDialect.js +0 -1
  264. package/dist/postgres/postgresWireDriverCapabilities.d.ts +0 -1
  265. package/dist/postgres/postgresWireDriverCapabilities.js +0 -1
  266. package/dist/querier/abstractPoolQuerier.d.ts +0 -1
  267. package/dist/querier/abstractPoolQuerier.js +0 -1
  268. package/dist/querier/abstractQuerier.d.ts +0 -1
  269. package/dist/querier/abstractQuerier.js +9 -2
  270. package/dist/querier/abstractQuerierPool.d.ts +0 -1
  271. package/dist/querier/abstractQuerierPool.js +0 -1
  272. package/dist/querier/abstractSqlQuerier.d.ts +0 -1
  273. package/dist/querier/abstractSqlQuerier.js +9 -2
  274. package/dist/querier/abstractSqlQuerierPool.d.ts +0 -1
  275. package/dist/querier/abstractSqlQuerierPool.js +0 -1
  276. package/dist/querier/decorator/index.d.ts +0 -1
  277. package/dist/querier/decorator/index.js +0 -1
  278. package/dist/querier/decorator/injectQuerier.d.ts +0 -1
  279. package/dist/querier/decorator/injectQuerier.js +0 -1
  280. package/dist/querier/decorator/log.d.ts +0 -1
  281. package/dist/querier/decorator/log.js +0 -1
  282. package/dist/querier/decorator/serialized.d.ts +0 -1
  283. package/dist/querier/decorator/serialized.js +0 -1
  284. package/dist/querier/decorator/transactional.d.ts +0 -1
  285. package/dist/querier/decorator/transactional.js +0 -1
  286. package/dist/querier/index.d.ts +0 -1
  287. package/dist/querier/index.js +0 -1
  288. package/dist/schema/canonicalType.d.ts +14 -13
  289. package/dist/schema/canonicalType.js +41 -44
  290. package/dist/schema/index.d.ts +1 -2
  291. package/dist/schema/index.js +0 -1
  292. package/dist/schema/schemaAST.d.ts +0 -1
  293. package/dist/schema/schemaAST.js +0 -1
  294. package/dist/schema/schemaASTBuilder.d.ts +8 -2
  295. package/dist/schema/schemaASTBuilder.js +56 -48
  296. package/dist/schema/schemaASTDiffer.d.ts +0 -1
  297. package/dist/schema/schemaASTDiffer.js +0 -1
  298. package/dist/schema/types.d.ts +10 -38
  299. package/dist/schema/types.js +0 -1
  300. package/dist/sqlite/abstractSqliteQuerier.d.ts +39 -1
  301. package/dist/sqlite/abstractSqliteQuerier.js +44 -1
  302. package/dist/sqlite/bunSqliteAdapter.bun.d.ts +26 -0
  303. package/dist/sqlite/bunSqliteAdapter.bun.js +25 -0
  304. package/dist/sqlite/hranaQuerier.d.ts +54 -0
  305. package/dist/sqlite/hranaQuerier.js +90 -0
  306. package/dist/sqlite/hranaQuerierPool.d.ts +21 -0
  307. package/dist/sqlite/hranaQuerierPool.js +25 -0
  308. package/dist/sqlite/index.d.ts +2 -2
  309. package/dist/sqlite/index.js +2 -2
  310. package/dist/sqlite/sqliteDialect.d.ts +18 -5
  311. package/dist/sqlite/sqliteDialect.js +24 -25
  312. package/dist/sqlite/sqliteQuerier.d.ts +16 -10
  313. package/dist/sqlite/sqliteQuerier.js +4 -28
  314. package/dist/sqlite/sqliteQuerierPool.d.ts +14 -5
  315. package/dist/sqlite/sqliteQuerierPool.js +16 -6
  316. package/dist/turso/index.d.ts +3 -0
  317. package/dist/turso/index.js +3 -0
  318. package/dist/turso/local.d.ts +3 -0
  319. package/dist/turso/local.js +3 -0
  320. package/dist/turso/tursoDialect.d.ts +15 -0
  321. package/dist/turso/tursoDialect.js +18 -0
  322. package/dist/turso/tursoLocalQuerier.d.ts +25 -0
  323. package/dist/turso/tursoLocalQuerier.js +20 -0
  324. package/dist/turso/tursoLocalQuerierPool.d.ts +32 -0
  325. package/dist/turso/tursoLocalQuerierPool.js +39 -0
  326. package/dist/turso/tursoQuerier.d.ts +10 -0
  327. package/dist/turso/tursoQuerier.js +10 -0
  328. package/dist/turso/tursoQuerierPool.d.ts +39 -0
  329. package/dist/turso/tursoQuerierPool.js +38 -0
  330. package/dist/type/config.d.ts +0 -7
  331. package/dist/type/config.js +0 -1
  332. package/dist/type/dialect.d.ts +12 -5
  333. package/dist/type/dialect.js +7 -2
  334. package/dist/type/entity.d.ts +66 -6
  335. package/dist/type/entity.js +0 -1
  336. package/dist/type/index.d.ts +0 -1
  337. package/dist/type/index.js +0 -1
  338. package/dist/type/logger.d.ts +0 -1
  339. package/dist/type/logger.js +0 -1
  340. package/dist/type/migration.d.ts +32 -24
  341. package/dist/type/migration.js +0 -1
  342. package/dist/type/migratorDialect.d.ts +0 -1
  343. package/dist/type/migratorDialect.js +0 -1
  344. package/dist/type/namingStrategy.d.ts +0 -1
  345. package/dist/type/namingStrategy.js +0 -1
  346. package/dist/type/querier.d.ts +0 -1
  347. package/dist/type/querier.js +0 -1
  348. package/dist/type/querierPool.d.ts +0 -1
  349. package/dist/type/querierPool.js +0 -1
  350. package/dist/type/query.d.ts +0 -1
  351. package/dist/type/query.js +0 -1
  352. package/dist/type/queryAggregate.d.ts +0 -1
  353. package/dist/type/queryAggregate.js +0 -1
  354. package/dist/type/queryRaw.d.ts +0 -1
  355. package/dist/type/queryRaw.js +0 -1
  356. package/dist/type/queryWhere.d.ts +0 -1
  357. package/dist/type/queryWhere.js +0 -1
  358. package/dist/type/universalQuerier.d.ts +0 -1
  359. package/dist/type/universalQuerier.js +0 -1
  360. package/dist/type/utility.d.ts +0 -1
  361. package/dist/type/utility.js +0 -1
  362. package/dist/type/vector.d.ts +5 -3
  363. package/dist/type/vector.js +0 -1
  364. package/dist/util/dialect.util.d.ts +8 -2
  365. package/dist/util/dialect.util.js +16 -1
  366. package/dist/util/field.util.d.ts +0 -1
  367. package/dist/util/field.util.js +0 -1
  368. package/dist/util/filters.util.d.ts +0 -1
  369. package/dist/util/filters.util.js +0 -1
  370. package/dist/util/hook.util.d.ts +0 -1
  371. package/dist/util/hook.util.js +0 -1
  372. package/dist/util/index.d.ts +1 -1
  373. package/dist/util/index.js +1 -1
  374. package/dist/util/indexColumn.util.d.ts +6 -0
  375. package/dist/util/indexColumn.util.js +26 -0
  376. package/dist/util/logger.d.ts +0 -1
  377. package/dist/util/logger.js +0 -1
  378. package/dist/util/object.util.d.ts +0 -1
  379. package/dist/util/object.util.js +0 -1
  380. package/dist/util/raw.d.ts +0 -1
  381. package/dist/util/raw.js +0 -1
  382. package/dist/util/relationQuery.util.d.ts +0 -1
  383. package/dist/util/relationQuery.util.js +0 -1
  384. package/dist/util/sql.util.d.ts +0 -1
  385. package/dist/util/sql.util.js +0 -1
  386. package/dist/util/sqlLiteral.d.ts +19 -0
  387. package/dist/util/sqlLiteral.js +108 -0
  388. package/dist/util/string.util.d.ts +0 -1
  389. package/dist/util/string.util.js +0 -1
  390. package/package.json +57 -27
  391. package/CHANGELOG.md +0 -1359
  392. package/dist/browser/http/bus.d.ts.map +0 -1
  393. package/dist/browser/http/bus.js.map +0 -1
  394. package/dist/browser/http/http.d.ts.map +0 -1
  395. package/dist/browser/http/http.js.map +0 -1
  396. package/dist/browser/http/index.d.ts.map +0 -1
  397. package/dist/browser/http/index.js.map +0 -1
  398. package/dist/browser/index.d.ts.map +0 -1
  399. package/dist/browser/index.js.map +0 -1
  400. package/dist/browser/options.d.ts.map +0 -1
  401. package/dist/browser/options.js.map +0 -1
  402. package/dist/browser/querier/httpQuerier.d.ts.map +0 -1
  403. package/dist/browser/querier/httpQuerier.js.map +0 -1
  404. package/dist/browser/querier/index.d.ts.map +0 -1
  405. package/dist/browser/querier/index.js.map +0 -1
  406. package/dist/browser/type/clientQuerier.d.ts.map +0 -1
  407. package/dist/browser/type/clientQuerier.js.map +0 -1
  408. package/dist/browser/type/clientQuerierPool.d.ts.map +0 -1
  409. package/dist/browser/type/clientQuerierPool.js.map +0 -1
  410. package/dist/browser/type/index.d.ts.map +0 -1
  411. package/dist/browser/type/index.js.map +0 -1
  412. package/dist/browser/type/request.d.ts.map +0 -1
  413. package/dist/browser/type/request.js.map +0 -1
  414. package/dist/bunSql/bunSql.util.d.ts.map +0 -1
  415. package/dist/bunSql/bunSql.util.js.map +0 -1
  416. package/dist/bunSql/bunSqlCockroachDialect.d.ts.map +0 -1
  417. package/dist/bunSql/bunSqlCockroachDialect.js.map +0 -1
  418. package/dist/bunSql/bunSqlPostgresDialect.d.ts.map +0 -1
  419. package/dist/bunSql/bunSqlPostgresDialect.js.map +0 -1
  420. package/dist/bunSql/bunSqlQuerier.d.ts.map +0 -1
  421. package/dist/bunSql/bunSqlQuerier.js.map +0 -1
  422. package/dist/bunSql/bunSqlQuerierPool.d.ts.map +0 -1
  423. package/dist/bunSql/bunSqlQuerierPool.js.map +0 -1
  424. package/dist/bunSql/bunSqliteDialect.d.ts.map +0 -1
  425. package/dist/bunSql/bunSqliteDialect.js.map +0 -1
  426. package/dist/bunSql/index.d.ts.map +0 -1
  427. package/dist/bunSql/index.js.map +0 -1
  428. package/dist/cockroachdb/cockroachDialect.d.ts.map +0 -1
  429. package/dist/cockroachdb/cockroachDialect.js.map +0 -1
  430. package/dist/cockroachdb/crdbQuerier.d.ts.map +0 -1
  431. package/dist/cockroachdb/crdbQuerier.js.map +0 -1
  432. package/dist/cockroachdb/crdbQuerierPool.d.ts.map +0 -1
  433. package/dist/cockroachdb/crdbQuerierPool.js.map +0 -1
  434. package/dist/cockroachdb/index.d.ts.map +0 -1
  435. package/dist/cockroachdb/index.js.map +0 -1
  436. package/dist/context/context.browser.d.ts.map +0 -1
  437. package/dist/context/context.browser.js.map +0 -1
  438. package/dist/context/context.d.ts.map +0 -1
  439. package/dist/context/context.js.map +0 -1
  440. package/dist/context/securityError.d.ts.map +0 -1
  441. package/dist/context/securityError.js.map +0 -1
  442. package/dist/d1/d1Querier.d.ts.map +0 -1
  443. package/dist/d1/d1Querier.js.map +0 -1
  444. package/dist/d1/d1QuerierPool.d.ts.map +0 -1
  445. package/dist/d1/d1QuerierPool.js.map +0 -1
  446. package/dist/d1/d1SqliteDialect.d.ts.map +0 -1
  447. package/dist/d1/d1SqliteDialect.js.map +0 -1
  448. package/dist/d1/index.d.ts.map +0 -1
  449. package/dist/d1/index.js.map +0 -1
  450. package/dist/dialect/abstractDialect.d.ts.map +0 -1
  451. package/dist/dialect/abstractDialect.js.map +0 -1
  452. package/dist/dialect/abstractSqlDialect.d.ts.map +0 -1
  453. package/dist/dialect/abstractSqlDialect.js.map +0 -1
  454. package/dist/dialect/index.d.ts.map +0 -1
  455. package/dist/dialect/index.js.map +0 -1
  456. package/dist/dialect/jsonArrayElemMatchUtils.d.ts.map +0 -1
  457. package/dist/dialect/jsonArrayElemMatchUtils.js.map +0 -1
  458. package/dist/dialect/jsonSql.d.ts.map +0 -1
  459. package/dist/dialect/jsonSql.js.map +0 -1
  460. package/dist/dialect/mysqlLikeSqlDialect.d.ts.map +0 -1
  461. package/dist/dialect/mysqlLikeSqlDialect.js.map +0 -1
  462. package/dist/dialect/pgLikeSqlDialect.d.ts.map +0 -1
  463. package/dist/dialect/pgLikeSqlDialect.js.map +0 -1
  464. package/dist/dialect/queryContext.d.ts.map +0 -1
  465. package/dist/dialect/queryContext.js.map +0 -1
  466. package/dist/dialect/vectorSqlDialect.d.ts.map +0 -1
  467. package/dist/dialect/vectorSqlDialect.js.map +0 -1
  468. package/dist/entity/decorator/entity.d.ts.map +0 -1
  469. package/dist/entity/decorator/entity.js.map +0 -1
  470. package/dist/entity/decorator/field.d.ts.map +0 -1
  471. package/dist/entity/decorator/field.js.map +0 -1
  472. package/dist/entity/decorator/filter.d.ts.map +0 -1
  473. package/dist/entity/decorator/filter.js.map +0 -1
  474. package/dist/entity/decorator/hook.d.ts.map +0 -1
  475. package/dist/entity/decorator/hook.js.map +0 -1
  476. package/dist/entity/decorator/id.d.ts.map +0 -1
  477. package/dist/entity/decorator/id.js.map +0 -1
  478. package/dist/entity/decorator/index-decorator.d.ts.map +0 -1
  479. package/dist/entity/decorator/index-decorator.js.map +0 -1
  480. package/dist/entity/decorator/index.d.ts.map +0 -1
  481. package/dist/entity/decorator/index.js.map +0 -1
  482. package/dist/entity/decorator/relation.d.ts.map +0 -1
  483. package/dist/entity/decorator/relation.js.map +0 -1
  484. package/dist/entity/index.d.ts.map +0 -1
  485. package/dist/entity/index.js.map +0 -1
  486. package/dist/entity/metadata/definition.d.ts.map +0 -1
  487. package/dist/entity/metadata/definition.js.map +0 -1
  488. package/dist/entity/test-helpers.d.ts +0 -4
  489. package/dist/entity/test-helpers.d.ts.map +0 -1
  490. package/dist/entity/test-helpers.js +0 -16
  491. package/dist/entity/test-helpers.js.map +0 -1
  492. package/dist/express/index.d.ts.map +0 -1
  493. package/dist/express/index.js.map +0 -1
  494. package/dist/express/querierMiddleware.d.ts.map +0 -1
  495. package/dist/express/querierMiddleware.js.map +0 -1
  496. package/dist/http/contract.d.ts.map +0 -1
  497. package/dist/http/contract.js.map +0 -1
  498. package/dist/http/fetchHandler.d.ts.map +0 -1
  499. package/dist/http/fetchHandler.js.map +0 -1
  500. package/dist/http/handler.d.ts.map +0 -1
  501. package/dist/http/handler.js.map +0 -1
  502. package/dist/http/index.d.ts.map +0 -1
  503. package/dist/http/index.js.map +0 -1
  504. package/dist/http/query.d.ts.map +0 -1
  505. package/dist/http/query.js.map +0 -1
  506. package/dist/index.d.ts.map +0 -1
  507. package/dist/index.js.map +0 -1
  508. package/dist/libsql/index.d.ts.map +0 -1
  509. package/dist/libsql/index.js.map +0 -1
  510. package/dist/libsql/libsqlDialect.d.ts.map +0 -1
  511. package/dist/libsql/libsqlDialect.js.map +0 -1
  512. package/dist/libsql/libsqlQuerier.d.ts.map +0 -1
  513. package/dist/libsql/libsqlQuerier.js.map +0 -1
  514. package/dist/libsql/libsqlQuerierPool.d.ts.map +0 -1
  515. package/dist/libsql/libsqlQuerierPool.js.map +0 -1
  516. package/dist/maria/index.d.ts.map +0 -1
  517. package/dist/maria/index.js.map +0 -1
  518. package/dist/maria/mariaDialect.d.ts.map +0 -1
  519. package/dist/maria/mariaDialect.js.map +0 -1
  520. package/dist/maria/mariadbQuerier.d.ts.map +0 -1
  521. package/dist/maria/mariadbQuerier.js.map +0 -1
  522. package/dist/maria/mariadbQuerierPool.d.ts.map +0 -1
  523. package/dist/maria/mariadbQuerierPool.js.map +0 -1
  524. package/dist/migrate/acquireQuerierForMigrations.d.ts.map +0 -1
  525. package/dist/migrate/acquireQuerierForMigrations.js.map +0 -1
  526. package/dist/migrate/assertCliConfig.d.ts.map +0 -1
  527. package/dist/migrate/assertCliConfig.js.map +0 -1
  528. package/dist/migrate/bin.d.ts.map +0 -1
  529. package/dist/migrate/bin.js.map +0 -1
  530. package/dist/migrate/builder/columnBuilder.d.ts.map +0 -1
  531. package/dist/migrate/builder/columnBuilder.js.map +0 -1
  532. package/dist/migrate/builder/expressions.d.ts.map +0 -1
  533. package/dist/migrate/builder/expressions.js.map +0 -1
  534. package/dist/migrate/builder/index.d.ts.map +0 -1
  535. package/dist/migrate/builder/index.js.map +0 -1
  536. package/dist/migrate/builder/migrationBuilder.d.ts.map +0 -1
  537. package/dist/migrate/builder/migrationBuilder.js.map +0 -1
  538. package/dist/migrate/builder/splitSqlStatements.d.ts.map +0 -1
  539. package/dist/migrate/builder/splitSqlStatements.js.map +0 -1
  540. package/dist/migrate/builder/tableBuilder.d.ts.map +0 -1
  541. package/dist/migrate/builder/tableBuilder.js.map +0 -1
  542. package/dist/migrate/builder/types.d.ts.map +0 -1
  543. package/dist/migrate/builder/types.js.map +0 -1
  544. package/dist/migrate/cli-config.d.ts.map +0 -1
  545. package/dist/migrate/cli-config.js.map +0 -1
  546. package/dist/migrate/cli.d.ts.map +0 -1
  547. package/dist/migrate/cli.js.map +0 -1
  548. package/dist/migrate/codegen/entityCodeGenerator.d.ts.map +0 -1
  549. package/dist/migrate/codegen/entityCodeGenerator.js.map +0 -1
  550. package/dist/migrate/codegen/entityMerger.d.ts +0 -115
  551. package/dist/migrate/codegen/entityMerger.d.ts.map +0 -1
  552. package/dist/migrate/codegen/entityMerger.js +0 -294
  553. package/dist/migrate/codegen/entityMerger.js.map +0 -1
  554. package/dist/migrate/codegen/index.d.ts.map +0 -1
  555. package/dist/migrate/codegen/index.js.map +0 -1
  556. package/dist/migrate/codegen/migrationCodeGenerator.d.ts +0 -62
  557. package/dist/migrate/codegen/migrationCodeGenerator.d.ts.map +0 -1
  558. package/dist/migrate/codegen/migrationCodeGenerator.js +0 -356
  559. package/dist/migrate/codegen/migrationCodeGenerator.js.map +0 -1
  560. package/dist/migrate/codegen/migrationFile.d.ts.map +0 -1
  561. package/dist/migrate/codegen/migrationFile.js.map +0 -1
  562. package/dist/migrate/codegen/smartRelationDetector.d.ts.map +0 -1
  563. package/dist/migrate/codegen/smartRelationDetector.js.map +0 -1
  564. package/dist/migrate/drift/driftDetector.d.ts.map +0 -1
  565. package/dist/migrate/drift/driftDetector.js.map +0 -1
  566. package/dist/migrate/drift/index.d.ts.map +0 -1
  567. package/dist/migrate/drift/index.js.map +0 -1
  568. package/dist/migrate/generator/index.d.ts +0 -3
  569. package/dist/migrate/generator/index.d.ts.map +0 -1
  570. package/dist/migrate/generator/index.js +0 -3
  571. package/dist/migrate/generator/index.js.map +0 -1
  572. package/dist/migrate/generator/mongoSchemaGenerator.d.ts.map +0 -1
  573. package/dist/migrate/generator/mongoSchemaGenerator.js.map +0 -1
  574. package/dist/migrate/index.d.ts.map +0 -1
  575. package/dist/migrate/index.js.map +0 -1
  576. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.d.ts.map +0 -1
  577. package/dist/migrate/introspection/abstractSqlSchemaIntrospector.js.map +0 -1
  578. package/dist/migrate/introspection/baseSqlIntrospector.d.ts.map +0 -1
  579. package/dist/migrate/introspection/baseSqlIntrospector.js.map +0 -1
  580. package/dist/migrate/introspection/index.d.ts.map +0 -1
  581. package/dist/migrate/introspection/index.js.map +0 -1
  582. package/dist/migrate/introspection/mongoIntrospector.d.ts.map +0 -1
  583. package/dist/migrate/introspection/mongoIntrospector.js.map +0 -1
  584. package/dist/migrate/introspection/mysqlIntrospector.d.ts.map +0 -1
  585. package/dist/migrate/introspection/mysqlIntrospector.js.map +0 -1
  586. package/dist/migrate/introspection/postgresIntrospector.d.ts.map +0 -1
  587. package/dist/migrate/introspection/postgresIntrospector.js.map +0 -1
  588. package/dist/migrate/introspection/sqliteIntrospector.d.ts.map +0 -1
  589. package/dist/migrate/introspection/sqliteIntrospector.js.map +0 -1
  590. package/dist/migrate/migrator.d.ts.map +0 -1
  591. package/dist/migrate/migrator.js.map +0 -1
  592. package/dist/migrate/schemaGenerator.d.ts.map +0 -1
  593. package/dist/migrate/schemaGenerator.js.map +0 -1
  594. package/dist/migrate/schemaGeneratorAsync.d.ts.map +0 -1
  595. package/dist/migrate/schemaGeneratorAsync.js.map +0 -1
  596. package/dist/migrate/storage/databaseStorage.d.ts.map +0 -1
  597. package/dist/migrate/storage/databaseStorage.js.map +0 -1
  598. package/dist/migrate/storage/index.d.ts.map +0 -1
  599. package/dist/migrate/storage/index.js.map +0 -1
  600. package/dist/migrate/storage/jsonStorage.d.ts.map +0 -1
  601. package/dist/migrate/storage/jsonStorage.js.map +0 -1
  602. package/dist/migrate/sync/index.d.ts +0 -7
  603. package/dist/migrate/sync/index.d.ts.map +0 -1
  604. package/dist/migrate/sync/index.js +0 -7
  605. package/dist/migrate/sync/index.js.map +0 -1
  606. package/dist/migrate/sync/schemaSync.d.ts +0 -132
  607. package/dist/migrate/sync/schemaSync.d.ts.map +0 -1
  608. package/dist/migrate/sync/schemaSync.js +0 -260
  609. package/dist/migrate/sync/schemaSync.js.map +0 -1
  610. package/dist/mongo/index.d.ts.map +0 -1
  611. package/dist/mongo/index.js.map +0 -1
  612. package/dist/mongo/mongoDialect.d.ts.map +0 -1
  613. package/dist/mongo/mongoDialect.js.map +0 -1
  614. package/dist/mongo/mongodbNativeDialect.d.ts.map +0 -1
  615. package/dist/mongo/mongodbNativeDialect.js.map +0 -1
  616. package/dist/mongo/mongodbQuerier.d.ts.map +0 -1
  617. package/dist/mongo/mongodbQuerier.js.map +0 -1
  618. package/dist/mongo/mongodbQuerierPool.d.ts.map +0 -1
  619. package/dist/mongo/mongodbQuerierPool.js.map +0 -1
  620. package/dist/mysql/index.d.ts.map +0 -1
  621. package/dist/mysql/index.js.map +0 -1
  622. package/dist/mysql/mysql2Dialect.d.ts.map +0 -1
  623. package/dist/mysql/mysql2Dialect.js.map +0 -1
  624. package/dist/mysql/mysql2Querier.d.ts.map +0 -1
  625. package/dist/mysql/mysql2Querier.js.map +0 -1
  626. package/dist/mysql/mysql2QuerierPool.d.ts.map +0 -1
  627. package/dist/mysql/mysql2QuerierPool.js.map +0 -1
  628. package/dist/mysql/mysqlDialect.d.ts.map +0 -1
  629. package/dist/mysql/mysqlDialect.js.map +0 -1
  630. package/dist/namingStrategy/defaultNamingStrategy.d.ts.map +0 -1
  631. package/dist/namingStrategy/defaultNamingStrategy.js.map +0 -1
  632. package/dist/namingStrategy/index.d.ts.map +0 -1
  633. package/dist/namingStrategy/index.js.map +0 -1
  634. package/dist/namingStrategy/snakeCaseNamingStrategy.d.ts.map +0 -1
  635. package/dist/namingStrategy/snakeCaseNamingStrategy.js.map +0 -1
  636. package/dist/neon/index.d.ts.map +0 -1
  637. package/dist/neon/index.js.map +0 -1
  638. package/dist/neon/neonDialect.d.ts.map +0 -1
  639. package/dist/neon/neonDialect.js.map +0 -1
  640. package/dist/neon/neonQuerier.d.ts.map +0 -1
  641. package/dist/neon/neonQuerier.js.map +0 -1
  642. package/dist/neon/neonQuerierPool.d.ts.map +0 -1
  643. package/dist/neon/neonQuerierPool.js.map +0 -1
  644. package/dist/nestjs/index.d.ts.map +0 -1
  645. package/dist/nestjs/index.js.map +0 -1
  646. package/dist/nestjs/uqlContextInterceptor.d.ts.map +0 -1
  647. package/dist/nestjs/uqlContextInterceptor.js.map +0 -1
  648. package/dist/nestjs/uqlModule.d.ts.map +0 -1
  649. package/dist/nestjs/uqlModule.js.map +0 -1
  650. package/dist/options.d.ts.map +0 -1
  651. package/dist/options.js.map +0 -1
  652. package/dist/postgres/abstractPgQuerier.d.ts.map +0 -1
  653. package/dist/postgres/abstractPgQuerier.js.map +0 -1
  654. package/dist/postgres/abstractPgQuerierPool.d.ts.map +0 -1
  655. package/dist/postgres/abstractPgQuerierPool.js.map +0 -1
  656. package/dist/postgres/index.d.ts.map +0 -1
  657. package/dist/postgres/index.js.map +0 -1
  658. package/dist/postgres/pgDialect.d.ts.map +0 -1
  659. package/dist/postgres/pgDialect.js.map +0 -1
  660. package/dist/postgres/pgQuerier.d.ts.map +0 -1
  661. package/dist/postgres/pgQuerier.js.map +0 -1
  662. package/dist/postgres/pgQuerierPool.d.ts.map +0 -1
  663. package/dist/postgres/pgQuerierPool.js.map +0 -1
  664. package/dist/postgres/postgresDialect.d.ts.map +0 -1
  665. package/dist/postgres/postgresDialect.js.map +0 -1
  666. package/dist/postgres/postgresWireDriverCapabilities.d.ts.map +0 -1
  667. package/dist/postgres/postgresWireDriverCapabilities.js.map +0 -1
  668. package/dist/querier/abstractPoolQuerier.d.ts.map +0 -1
  669. package/dist/querier/abstractPoolQuerier.js.map +0 -1
  670. package/dist/querier/abstractQuerier.d.ts.map +0 -1
  671. package/dist/querier/abstractQuerier.js.map +0 -1
  672. package/dist/querier/abstractQuerierPool.d.ts.map +0 -1
  673. package/dist/querier/abstractQuerierPool.js.map +0 -1
  674. package/dist/querier/abstractSqlQuerier.d.ts.map +0 -1
  675. package/dist/querier/abstractSqlQuerier.js.map +0 -1
  676. package/dist/querier/abstractSqlQuerierPool.d.ts.map +0 -1
  677. package/dist/querier/abstractSqlQuerierPool.js.map +0 -1
  678. package/dist/querier/decorator/index.d.ts.map +0 -1
  679. package/dist/querier/decorator/index.js.map +0 -1
  680. package/dist/querier/decorator/injectQuerier.d.ts.map +0 -1
  681. package/dist/querier/decorator/injectQuerier.js.map +0 -1
  682. package/dist/querier/decorator/log.d.ts.map +0 -1
  683. package/dist/querier/decorator/log.js.map +0 -1
  684. package/dist/querier/decorator/serialized.d.ts.map +0 -1
  685. package/dist/querier/decorator/serialized.js.map +0 -1
  686. package/dist/querier/decorator/transactional.d.ts.map +0 -1
  687. package/dist/querier/decorator/transactional.js.map +0 -1
  688. package/dist/querier/index.d.ts.map +0 -1
  689. package/dist/querier/index.js.map +0 -1
  690. package/dist/schema/canonicalType.d.ts.map +0 -1
  691. package/dist/schema/canonicalType.js.map +0 -1
  692. package/dist/schema/index.d.ts.map +0 -1
  693. package/dist/schema/index.js.map +0 -1
  694. package/dist/schema/schemaAST.d.ts.map +0 -1
  695. package/dist/schema/schemaAST.js.map +0 -1
  696. package/dist/schema/schemaASTBuilder.d.ts.map +0 -1
  697. package/dist/schema/schemaASTBuilder.js.map +0 -1
  698. package/dist/schema/schemaASTDiffer.d.ts.map +0 -1
  699. package/dist/schema/schemaASTDiffer.js.map +0 -1
  700. package/dist/schema/types.d.ts.map +0 -1
  701. package/dist/schema/types.js.map +0 -1
  702. package/dist/sqlite/abstractSqliteQuerier.d.ts.map +0 -1
  703. package/dist/sqlite/abstractSqliteQuerier.js.map +0 -1
  704. package/dist/sqlite/betterSqlite3Dialect.d.ts +0 -10
  705. package/dist/sqlite/betterSqlite3Dialect.d.ts.map +0 -1
  706. package/dist/sqlite/betterSqlite3Dialect.js +0 -10
  707. package/dist/sqlite/betterSqlite3Dialect.js.map +0 -1
  708. package/dist/sqlite/index.d.ts.map +0 -1
  709. package/dist/sqlite/index.js.map +0 -1
  710. package/dist/sqlite/sqliteDialect.d.ts.map +0 -1
  711. package/dist/sqlite/sqliteDialect.js.map +0 -1
  712. package/dist/sqlite/sqliteQuerier.d.ts.map +0 -1
  713. package/dist/sqlite/sqliteQuerier.js.map +0 -1
  714. package/dist/sqlite/sqliteQuerierPool.d.ts.map +0 -1
  715. package/dist/sqlite/sqliteQuerierPool.js.map +0 -1
  716. package/dist/type/config.d.ts.map +0 -1
  717. package/dist/type/config.js.map +0 -1
  718. package/dist/type/dialect.d.ts.map +0 -1
  719. package/dist/type/dialect.js.map +0 -1
  720. package/dist/type/entity.d.ts.map +0 -1
  721. package/dist/type/entity.js.map +0 -1
  722. package/dist/type/index.d.ts.map +0 -1
  723. package/dist/type/index.js.map +0 -1
  724. package/dist/type/logger.d.ts.map +0 -1
  725. package/dist/type/logger.js.map +0 -1
  726. package/dist/type/migration.d.ts.map +0 -1
  727. package/dist/type/migration.js.map +0 -1
  728. package/dist/type/migratorDialect.d.ts.map +0 -1
  729. package/dist/type/migratorDialect.js.map +0 -1
  730. package/dist/type/namingStrategy.d.ts.map +0 -1
  731. package/dist/type/namingStrategy.js.map +0 -1
  732. package/dist/type/querier.d.ts.map +0 -1
  733. package/dist/type/querier.js.map +0 -1
  734. package/dist/type/querierPool.d.ts.map +0 -1
  735. package/dist/type/querierPool.js.map +0 -1
  736. package/dist/type/query.d.ts.map +0 -1
  737. package/dist/type/query.js.map +0 -1
  738. package/dist/type/queryAggregate.d.ts.map +0 -1
  739. package/dist/type/queryAggregate.js.map +0 -1
  740. package/dist/type/queryRaw.d.ts.map +0 -1
  741. package/dist/type/queryRaw.js.map +0 -1
  742. package/dist/type/queryWhere.d.ts.map +0 -1
  743. package/dist/type/queryWhere.js.map +0 -1
  744. package/dist/type/universalQuerier.d.ts.map +0 -1
  745. package/dist/type/universalQuerier.js.map +0 -1
  746. package/dist/type/utility.d.ts.map +0 -1
  747. package/dist/type/utility.js.map +0 -1
  748. package/dist/type/vector.d.ts.map +0 -1
  749. package/dist/type/vector.js.map +0 -1
  750. package/dist/util/ansiSqlLiteral.d.ts +0 -23
  751. package/dist/util/ansiSqlLiteral.d.ts.map +0 -1
  752. package/dist/util/ansiSqlLiteral.js +0 -105
  753. package/dist/util/ansiSqlLiteral.js.map +0 -1
  754. package/dist/util/dialect.util.d.ts.map +0 -1
  755. package/dist/util/dialect.util.js.map +0 -1
  756. package/dist/util/field.util.d.ts.map +0 -1
  757. package/dist/util/field.util.js.map +0 -1
  758. package/dist/util/filters.util.d.ts.map +0 -1
  759. package/dist/util/filters.util.js.map +0 -1
  760. package/dist/util/hook.util.d.ts.map +0 -1
  761. package/dist/util/hook.util.js.map +0 -1
  762. package/dist/util/index.d.ts.map +0 -1
  763. package/dist/util/index.js.map +0 -1
  764. package/dist/util/logger.d.ts.map +0 -1
  765. package/dist/util/logger.js.map +0 -1
  766. package/dist/util/object.util.d.ts.map +0 -1
  767. package/dist/util/object.util.js.map +0 -1
  768. package/dist/util/raw.d.ts.map +0 -1
  769. package/dist/util/raw.js.map +0 -1
  770. package/dist/util/relationQuery.util.d.ts.map +0 -1
  771. package/dist/util/relationQuery.util.js.map +0 -1
  772. package/dist/util/sql.util.d.ts.map +0 -1
  773. package/dist/util/sql.util.js.map +0 -1
  774. package/dist/util/string.util.d.ts.map +0 -1
  775. package/dist/util/string.util.js.map +0 -1
@@ -1,7 +1,8 @@
1
1
  import { ObjectId } from 'mongodb';
2
2
  import { AbstractDialect } from '../dialect/abstractDialect.js';
3
3
  import { getMeta } from '../entity/index.js';
4
- import { applyFilters, asSelectMap, buildQueryWhereAsMap, buildSortMap, fillOnFields, filterFieldKeys, getKeys, getRelationRequestSummary, hasKeys, isJsonUpdateOp, isOperatorObject, isVectorSearch, normalizeScalarFieldSelection, parseGroupMap, } from '../util/index.js';
4
+ import { QueryRaw } from '../type/queryRaw.js';
5
+ import { asSelectMap, buildQueryWhereAsMap, buildSortMap, fillOnFields, filterFieldKeys, getKeys, getRelationRequestSummary, hasKeys, isJsonUpdateOp, isOperatorObject, isVectorSearch, normalizeScalarFieldSelection, parseGroupMap, parseRelationAtKey, parseRelationSize, } from '../util/index.js';
5
6
  /** Default {@link DialectFeatures} for MongoDB; shared by {@link MongoDialect} and its schema generator. */
6
7
  export const mongoDialectFeatures = {
7
8
  explicitJsonCast: false,
@@ -13,7 +14,7 @@ export const mongoDialectFeatures = {
13
14
  renameColumn: false,
14
15
  foreignKeyAlter: false,
15
16
  columnComment: false,
16
- vectorIndexStyle: 'create',
17
+ inlineVectorIndex: false,
17
18
  vectorSupportsLength: false,
18
19
  supportsTimestamptz: false,
19
20
  defaultStringAsText: false,
@@ -24,7 +25,13 @@ export class MongoDialect extends AbstractDialect {
24
25
  // The MongoDB driver reports the exact `_id` of every inserted document (`insertedIds`).
25
26
  insertIdSource = 'returning';
26
27
  static ID_KEY = '_id';
28
+ /** Temporary lookup fields for relation conditions, dropped with `$unset` after the `$match`. */
29
+ static REL_TEMP_PREFIX = '__uql_rel_';
30
+ static REL_COUNT_KEY = 'n';
31
+ static REL_NESTED_KEY = '__uql_target';
27
32
  static VECTOR_INDEX_TYPES = new Set(['vectorSearch', 'hnsw', 'ivfflat', 'vector']);
33
+ /** Atlas rejects a `$vectorSearch` asking for more candidates than this. */
34
+ static MAX_NUM_CANDIDATES = 10_000;
28
35
  // Direct field aggregates → MongoDB accumulator. `$count` is handled separately (COUNT(*) vs
29
36
  // COUNT(field) differ), so it is not listed here.
30
37
  static AGGREGATE_OP_MAP = new Map([
@@ -33,14 +40,52 @@ export class MongoDialect extends AbstractDialect {
33
40
  ['$min', '$min'],
34
41
  ['$max', '$max'],
35
42
  ]);
43
+ /**
44
+ * MongoDB stores the primary key as `_id`; everything else resolves as usual. Projections, sorts,
45
+ * `$group` refs and `$where` keys all map through here, so no read path can address a property name
46
+ * the document does not use.
47
+ */
48
+ columnOf(meta, key) {
49
+ if (key === MongoDialect.ID_KEY || key === meta.id) {
50
+ return MongoDialect.ID_KEY;
51
+ }
52
+ return super.columnOf(meta, key);
53
+ }
36
54
  where(entity, where = {}, opts = {}) {
37
55
  const meta = getMeta(entity);
38
- // Apply this entity's filters once, at the scope entry point; recursion uses `renderFilter`.
39
- const whereMap = applyFilters(meta, buildQueryWhereAsMap(meta, where), opts);
40
- return this.renderFilter(entity, whereMap);
56
+ // Filters are applied once, here at the scope entry point; recursion uses `renderFilter`.
57
+ return this.renderFilter(entity, this.scopedWhereMap(meta, where, opts));
58
+ }
59
+ /**
60
+ * A `$where` that may constrain relations, split into the `$lookup` stages it needs and the `$match`
61
+ * filter that consumes them. Each relation condition becomes one correlated lookup into a temporary
62
+ * field plus an ordinary condition on that field, so the caller's boolean structure survives intact
63
+ * (a relation inside `$or` still means what it says) and nothing depends on materializing ids.
64
+ * `unset` names the temporary fields, which the caller drops once the match is done.
65
+ */
66
+ whereWithRelations(entity, where = {}, opts = {}) {
67
+ const meta = getMeta(entity);
68
+ const lookups = { stages: [], temps: [] };
69
+ const filter = this.renderFilter(entity, this.scopedWhereMap(meta, where, opts), opts, lookups);
70
+ return { stages: lookups.stages, filter, unset: lookups.temps };
71
+ }
72
+ /** Whether a `$where` constrains any relation, and so needs the aggregation path rather than a cursor. */
73
+ constrainsRelations(entity, where) {
74
+ if (!where) {
75
+ return false;
76
+ }
77
+ const meta = getMeta(entity);
78
+ const whereMap = buildQueryWhereAsMap(meta, where);
79
+ return Object.entries(whereMap).some(([key, val]) => key === '$and' || key === '$or'
80
+ ? val.some((it) => this.constrainsRelations(entity, it))
81
+ : Boolean(meta.relations[key]));
41
82
  }
42
- /** Renders a `$where` tree without applying entity filters (used for same-scope `$and`/`$or` recursion). */
43
- renderFilter(entity, where = {}) {
83
+ /**
84
+ * Renders a `$where` tree without applying entity filters (used for same-scope `$and`/`$or`
85
+ * recursion). Relation keys need `$lookup` stages, so they are only accepted when `lookups` is
86
+ * given - a plain `find`/`updateMany` filter has nowhere to put them.
87
+ */
88
+ renderFilter(entity, where = {}, opts, lookups) {
44
89
  const meta = getMeta(entity);
45
90
  const whereMap = buildQueryWhereAsMap(meta, where);
46
91
  const filter = {};
@@ -48,17 +93,32 @@ export class MongoDialect extends AbstractDialect {
48
93
  let key = rawKey;
49
94
  let val = rawVal;
50
95
  if (key === '$and' || key === '$or') {
51
- filter[key] = val.map((filterIt) => this.renderFilter(entity, filterIt));
96
+ filter[key] = val.map((filterIt) => {
97
+ // A `QueryRaw` here would recurse forever: `buildQueryWhereAsMap` re-wraps it as
98
+ // `{ $and: [raw] }`, which lands back on this branch.
99
+ this.assertNoRaw(filterIt);
100
+ return this.renderFilter(entity, filterIt, opts, lookups);
101
+ });
102
+ }
103
+ else if (key === '$text') {
104
+ // MongoDB's text index declares which fields it covers, so `$fields` cannot narrow the search
105
+ // the way it does elsewhere - the same shape as `$distance` being index-defined here.
106
+ filter['$text'] = { $search: val.$value };
107
+ }
108
+ else if (meta.relations[key]) {
109
+ this.assertNoRaw(val);
110
+ if (!lookups) {
111
+ throw new TypeError(`filtering by relation '${key}' is not supported here on MongoDB`);
112
+ }
113
+ Object.assign(filter, this.appendRelationLookup(meta, key, val, opts, lookups));
52
114
  }
53
115
  else {
54
- const field = meta.fields[key];
55
- if (key === MongoDialect.ID_KEY || key === meta.id) {
56
- key = MongoDialect.ID_KEY;
116
+ this.assertNoRaw(val);
117
+ this.assertKnownPathRoot(meta, key);
118
+ key = this.pathOf(meta, key);
119
+ if (key === MongoDialect.ID_KEY) {
57
120
  val = this.getIdValue(val);
58
121
  }
59
- else if (field) {
60
- key = this.resolveColumnName(key, field);
61
- }
62
122
  if (isOperatorObject(val)) {
63
123
  val = this.transformOperators(val);
64
124
  }
@@ -70,6 +130,115 @@ export class MongoDialect extends AbstractDialect {
70
130
  }
71
131
  return filter;
72
132
  }
133
+ /**
134
+ * Emits the correlated `$lookup` for one relation condition and returns the condition that tests its
135
+ * result: presence of a row for a plain relation filter, a comparison against the row count for
136
+ * `$size`. The target's (and, for ManyToMany, the junction's) own filters scope the lookup, so a
137
+ * relation subquery can no more read out-of-scope rows than a direct query on the target can.
138
+ */
139
+ appendRelationLookup(meta, relKey, val, opts, lookups) {
140
+ const relOpts = meta.relations[relKey];
141
+ const relEntity = relOpts.entity();
142
+ const relMeta = getMeta(relEntity);
143
+ const temp = `${MongoDialect.REL_TEMP_PREFIX}${lookups.temps.length}`;
144
+ const sizeVal = parseRelationSize(val);
145
+ // `$count` for a size test, `$limit: 1` for existence: neither returns the matched documents.
146
+ const tail = sizeVal === undefined ? [{ $limit: 1 }] : [{ $count: MongoDialect.REL_COUNT_KEY }];
147
+ // Scope first, render once - merging the target's filters into an already-rendered filter would
148
+ // leave their own keys unmapped. The caller's filter bypass is deliberately *not* passed down:
149
+ // `withDeleted()` or `hardDelete` on the parent must not un-hide trashed rows of the target, the
150
+ // same rule the SQL dialects' relation subqueries follow.
151
+ const targetCondition = (sizeVal === undefined ? val : {});
152
+ const targetScope = this.renderFilter(relEntity, this.scopedWhereMap(relMeta, targetCondition), opts);
153
+ lookups.temps.push(temp);
154
+ lookups.stages.push(relOpts.cardinality === 'mm' && relOpts.through
155
+ ? this.junctionLookup(meta, relOpts, relMeta, relEntity, targetScope, temp, tail, opts)
156
+ : {
157
+ $lookup: {
158
+ from: this.resolveTableName(relEntity, relMeta),
159
+ ...this.joinKeys(meta, relMeta, relOpts),
160
+ pipeline: [...(hasKeys(targetScope) ? [{ $match: targetScope }] : []), ...tail],
161
+ as: temp,
162
+ },
163
+ });
164
+ return sizeVal === undefined
165
+ ? { [`${temp}.0`]: { $exists: true } }
166
+ : { $expr: this.compareRelationCount(temp, sizeVal) };
167
+ }
168
+ /**
169
+ * ManyToMany counts/tests junction rows, so the target is reached from inside the junction's own
170
+ * lookup - the junction's filters apply too, since a soft-deleted link is not a link.
171
+ */
172
+ junctionLookup(meta, relOpts, relMeta, relEntity, targetScope, temp, tail, opts) {
173
+ const throughEntity = relOpts.through();
174
+ const throughMeta = getMeta(throughEntity);
175
+ const junctionScope = this.renderFilter(throughEntity, this.scopedWhereMap(throughMeta, {}), opts);
176
+ const nested = MongoDialect.REL_NESTED_KEY;
177
+ return {
178
+ $lookup: {
179
+ from: this.resolveTableName(throughEntity, throughMeta),
180
+ localField: MongoDialect.ID_KEY,
181
+ foreignField: this.columnOf(throughMeta, relOpts.references[0].local),
182
+ pipeline: [
183
+ ...(hasKeys(junctionScope) ? [{ $match: junctionScope }] : []),
184
+ {
185
+ $lookup: {
186
+ from: this.resolveTableName(relEntity, relMeta),
187
+ localField: this.columnOf(throughMeta, relOpts.references[1].local),
188
+ foreignField: MongoDialect.ID_KEY,
189
+ pipeline: [...(hasKeys(targetScope) ? [{ $match: targetScope }] : []), { $limit: 1 }],
190
+ as: nested,
191
+ },
192
+ },
193
+ { $match: { [`${nested}.0`]: { $exists: true } } },
194
+ ...tail,
195
+ ],
196
+ as: temp,
197
+ },
198
+ };
199
+ }
200
+ /**
201
+ * Compares the looked-up row count, which is `[{ n: <count> }]` or `[]` when nothing matched - hence
202
+ * the `$ifNull` fallback to 0, so `{ $size: 0 }` matches parents with no related row at all.
203
+ */
204
+ compareRelationCount(temp, sizeVal) {
205
+ const count = { $ifNull: [{ $arrayElemAt: [`$${temp}.${MongoDialect.REL_COUNT_KEY}`, 0] }, 0] };
206
+ if (typeof sizeVal === 'number') {
207
+ return { $eq: [count, sizeVal] };
208
+ }
209
+ const comparisons = Object.entries(sizeVal)
210
+ .filter(([, bound]) => bound !== undefined)
211
+ .flatMap(([op, bound]) => op === '$between'
212
+ ? [{ $gte: [count, bound[0]] }, { $lte: [count, bound[1]] }]
213
+ : [{ [op]: [count, bound] }]);
214
+ if (!comparisons.length) {
215
+ throw new TypeError('$size on a relation needs at least one comparison');
216
+ }
217
+ return comparisons.length === 1 ? comparisons[0] : { $and: comparisons };
218
+ }
219
+ /** Whether a query subtracts `key` from the projection, via `$exclude` or a negative `$select`. */
220
+ subtractsKey(key, select, exclude) {
221
+ const at = (map) => map?.[key];
222
+ return at(exclude) === true || at(select) === false;
223
+ }
224
+ /** `raw()` renders SQL, so it has no MongoDB equivalent - say so instead of emitting `{}`. */
225
+ assertNoRaw(value) {
226
+ if (value instanceof QueryRaw) {
227
+ throw new TypeError('raw() in $where is not supported on MongoDB');
228
+ }
229
+ }
230
+ /**
231
+ * A dotted key addresses an embedded path, whose root must still be a declared field - otherwise it
232
+ * is a typo (or an injected key) that would silently match nothing, the same guard the SQL dialects
233
+ * apply to JSON paths.
234
+ */
235
+ assertKnownPathRoot(meta, key) {
236
+ const root = key.includes('.') ? key.slice(0, key.indexOf('.')) : key;
237
+ if (root === MongoDialect.ID_KEY || root === meta.id || meta.fields[root]) {
238
+ return;
239
+ }
240
+ throw new TypeError(`path ${key} does not exist in ${meta.name ?? ''}`);
241
+ }
73
242
  mapTableNameRow(row) {
74
243
  return row.table_name;
75
244
  }
@@ -168,87 +337,145 @@ export class MongoDialect extends AbstractDialect {
168
337
  if (Array.isArray(select)) {
169
338
  throw new TypeError('raw $select is not supported on MongoDB');
170
339
  }
171
- const selectedFields = normalizeScalarFieldSelection(meta, asSelectMap(select), exclude);
172
- return selectedFields.reduce((acc, key) => {
173
- acc[key] = 1;
340
+ const selectMap = asSelectMap(select);
341
+ // Projected by column, not by field key; `normalizeId` maps them back on the way out.
342
+ const projection = normalizeScalarFieldSelection(meta, selectMap, exclude).reduce((acc, key) => {
343
+ acc[this.columnOf(meta, key)] = 1;
174
344
  return acc;
175
345
  }, {});
346
+ // MongoDB returns `_id` unless it is explicitly excluded, so subtracting the primary key needs
347
+ // `_id: 0` - the one inclusion/exclusion mix MongoDB allows - or `$exclude: { id: true }` would
348
+ // have no effect at all.
349
+ if (this.subtractsKey(meta.id, selectMap, exclude)) {
350
+ projection[MongoDialect.ID_KEY] = 0;
351
+ }
352
+ return projection;
176
353
  }
177
354
  sort(entity, sort) {
178
- const raw = buildSortMap(sort);
355
+ const meta = getMeta(entity);
356
+ return this.sortBy(sort, (key) => {
357
+ if (meta.relations[key]) {
358
+ throw new TypeError(`sorting by relation '${key}' is not supported on MongoDB`);
359
+ }
360
+ return this.pathOf(meta, key);
361
+ });
362
+ }
363
+ /**
364
+ * Aggregate results are keyed by `$group`/`$agg` alias rather than by column, so an aggregate
365
+ * `$sort` addresses those aliases as-is - the same reason the SQL dialects sort by alias there.
366
+ */
367
+ aliasSort(sort) {
368
+ return this.sortBy(sort, (alias) => alias);
369
+ }
370
+ /** Shared direction normalization; `mapKey` decides whether keys are columns or aggregate aliases. */
371
+ sortBy(sort, mapKey) {
179
372
  const normalized = {};
180
- for (const [key, dir] of Object.entries(raw)) {
181
- normalized[key] = dir === 'desc' || dir === -1 ? -1 : 1;
373
+ for (const [key, dir] of Object.entries(buildSortMap(sort))) {
374
+ normalized[mapKey(key)] = dir === 'desc' || dir === -1 ? -1 : 1;
182
375
  }
183
376
  return normalized;
184
377
  }
378
+ /**
379
+ * {@link columnOf} for a possibly dotted key: only the root is a field key, the rest addresses an
380
+ * embedded path (`kind.city` -> `<kind's column>.city`).
381
+ */
382
+ pathOf(meta, key) {
383
+ const dot = key.indexOf('.');
384
+ if (dot < 0) {
385
+ return this.columnOf(meta, key);
386
+ }
387
+ return this.columnOf(meta, key.slice(0, dot)) + key.slice(dot);
388
+ }
185
389
  aggregationPipeline(entity, q, relationSummary, opts) {
186
- const meta = getMeta(entity);
187
- const where = this.where(entity, q.$where, opts);
390
+ const { stages, filter, unset } = this.whereWithRelations(entity, q.$where, opts);
188
391
  const sort = this.sort(entity, q.$sort);
189
- const firstPipelineEntry = {};
190
- if (hasKeys(where)) {
191
- firstPipelineEntry.$match = where;
392
+ const match = {};
393
+ if (hasKeys(filter)) {
394
+ match.$match = filter;
192
395
  }
193
396
  if (hasKeys(sort)) {
194
- firstPipelineEntry.$sort = sort;
195
- }
397
+ match.$sort = sort;
398
+ }
399
+ // Lookups that a relation condition needs come first, then the match that reads them, then the
400
+ // temporary fields are dropped so they never reach the caller.
401
+ const pipeline = [...stages];
402
+ if (hasKeys(match)) {
403
+ pipeline.push(match);
404
+ }
405
+ if (unset.length) {
406
+ pipeline.push({ $unset: unset });
407
+ }
408
+ const relStages = this.relationStages(entity, q, relationSummary, opts);
409
+ const pager = [
410
+ ...(q.$skip === undefined ? [] : [{ $skip: q.$skip }]),
411
+ ...(q.$limit === undefined ? [] : [{ $limit: q.$limit }]),
412
+ ];
413
+ // A `$required` relation drops parents when it unwinds, so paging has to come after it - as it
414
+ // does after an INNER JOIN. Otherwise paging first is equivalent and spares the lookups.
415
+ const dropsParents = relStages.some((stage) => stage.$unwind?.preserveNullAndEmptyArrays === false);
416
+ pipeline.push(...(dropsParents ? [...relStages, ...pager] : [...pager, ...relStages]));
417
+ return pipeline;
418
+ }
419
+ /**
420
+ * `$lookup`/`$unwind` stages for the joinable relations a query populates. Shared by the plain
421
+ * aggregation pipeline and the `$vectorSearch` one, so relations load the same way in both.
422
+ */
423
+ relationStages(entity, q, relationSummary, opts) {
424
+ const meta = getMeta(entity);
196
425
  const pipeline = [];
197
- if (hasKeys(firstPipelineEntry)) {
198
- pipeline.push(firstPipelineEntry);
199
- }
200
426
  const relKeys = (relationSummary ?? getRelationRequestSummary(meta, q.$populate)).joinableKeys;
201
427
  for (const relKey of relKeys) {
202
428
  const relOpts = meta.relations[relKey];
203
429
  if (!relOpts)
204
430
  continue;
205
431
  if (relOpts.cardinality === '1m' || relOpts.cardinality === 'mm') {
206
- // '1m' and 'mm' should be resolved in a higher layer because they will need multiple queries
432
+ // '1m' and 'mm' are resolved in a higher layer: they need a second query each.
207
433
  continue;
208
434
  }
209
435
  const relEntity = relOpts.entity();
210
436
  const relMeta = getMeta(relEntity);
437
+ const { query: relQuery, required } = parseRelationAtKey(relKey, q.$populate);
211
438
  // Unconditional, not gated by an explicit relation-level `$where`: the related entity's own
212
439
  // filters (in particular `security: true` ones) must apply even to a bare
213
440
  // `$populate: { rel: true }`, exactly like the SQL dialects' JOIN ON-clause filters.
214
- const relationFilter = this.where(relEntity, {}, opts);
215
- if (relOpts.cardinality === 'm1') {
216
- const localField = meta.fields[relOpts.references[0].local];
217
- pipeline.push({
218
- $lookup: {
219
- from: this.resolveTableName(relEntity, relMeta),
220
- localField: this.resolveColumnName(relOpts.references[0].local, localField),
221
- foreignField: '_id',
222
- // MongoDB runs `pipeline` after its own localField/foreignField match, so the related
223
- // entity's filters layer on top of the join condition without a `let`/`$expr` rewrite.
224
- ...(hasKeys(relationFilter) ? { pipeline: [{ $match: relationFilter }] } : {}),
225
- as: relKey,
226
- },
227
- });
228
- }
229
- else {
230
- const foreignField = relMeta.fields[relOpts.references[0].foreign];
231
- const foreignFieldName = this.resolveColumnName(relOpts.references[0].foreign, foreignField);
232
- const referenceSort = this.sort(relEntity, q.$sort);
233
- const _id = MongoDialect.ID_KEY;
234
- const referencePipelineEntry = {
235
- $match: { [foreignFieldName]: where[_id], ...relationFilter },
236
- };
237
- if (hasKeys(referenceSort)) {
238
- referencePipelineEntry.$sort = referenceSort;
239
- }
240
- pipeline.push({
241
- $lookup: {
242
- from: this.resolveTableName(relEntity, relMeta),
243
- pipeline: [referencePipelineEntry],
244
- as: relKey,
245
- },
246
- });
247
- }
248
- pipeline.push({ $unwind: { path: `$${relKey}`, preserveNullAndEmptyArrays: true } });
441
+ const relationFilter = this.where(relEntity, relQuery.$where ?? {}, opts);
442
+ pipeline.push({
443
+ $lookup: {
444
+ from: this.resolveTableName(relEntity, relMeta),
445
+ ...this.joinKeys(meta, relMeta, relOpts),
446
+ ...(hasKeys(relationFilter) ? { pipeline: [{ $match: relationFilter }] } : {}),
447
+ as: relKey,
448
+ },
449
+ });
450
+ // `$required` drops parents with no match, the aggregation equivalent of an INNER JOIN.
451
+ pipeline.push({ $unwind: { path: `$${relKey}`, preserveNullAndEmptyArrays: !required } });
249
452
  }
250
453
  return pipeline;
251
454
  }
455
+ /**
456
+ * The correlated join for a single-valued or one-to-many relation. MongoDB runs a lookup's `pipeline`
457
+ * after its own localField/foreignField match, so the target's filters layer on top of the join
458
+ * condition with no `let`/`$expr` rewrite: m1 joins the parent's FK to the target's `_id`, every other
459
+ * direction joins the parent's `_id` to the target's FK.
460
+ */
461
+ joinKeys(meta, relMeta, relOpts) {
462
+ return relOpts.cardinality === 'm1'
463
+ ? { localField: this.columnOf(meta, relOpts.references[0].local), foreignField: MongoDialect.ID_KEY }
464
+ : { localField: MongoDialect.ID_KEY, foreignField: this.columnOf(relMeta, relOpts.references[0].foreign) };
465
+ }
466
+ /** `[column, key]` for the fields whose stored name differs from their property name, memoized per entity. */
467
+ renamedColumns(meta) {
468
+ let renamed = this.#renamedColumns.get(meta);
469
+ if (!renamed) {
470
+ renamed = getKeys(meta.fields)
471
+ .map((key) => [this.columnOf(meta, key), key])
472
+ .filter(([column, key]) => column !== key);
473
+ this.#renamedColumns.set(meta, renamed);
474
+ }
475
+ return renamed;
476
+ }
477
+ // Keyed by the meta object itself; entity metadata is immutable once defined.
478
+ #renamedColumns = new WeakMap();
252
479
  normalizeIds(meta, docs) {
253
480
  return docs?.map((doc) => this.normalizeId(meta, doc));
254
481
  }
@@ -264,12 +491,12 @@ export class MongoDialect extends AbstractDialect {
264
491
  delete res[_id];
265
492
  }
266
493
  }
267
- for (const key of getKeys(meta.fields)) {
268
- const field = meta.fields[key];
269
- const dbName = this.resolveColumnName(key, field);
270
- if (dbName !== key && res[dbName] !== undefined) {
271
- res[key] = res[dbName];
272
- delete res[dbName];
494
+ // Only the renamed fields need touching, and which those are is a property of the entity, not of
495
+ // the document - so it is derived once instead of for every row of a result set.
496
+ for (const [column, key] of this.renamedColumns(meta)) {
497
+ if (res[column] !== undefined) {
498
+ res[key] = res[column];
499
+ delete res[column];
273
500
  }
274
501
  }
275
502
  const relKeys = getKeys(meta.relations).filter((key) => res[key]);
@@ -398,7 +625,7 @@ export class MongoDialect extends AbstractDialect {
398
625
  }
399
626
  }
400
627
  // $group stage
401
- const { groupId, groupAccumulators, distinctReducers } = this.buildGroupSpec(parseGroupMap(q.$group, q.$agg));
628
+ const { groupId, groupAccumulators, distinctReducers } = this.buildGroupSpec(getMeta(entity), parseGroupMap(q.$group, q.$agg));
402
629
  pipeline.push({ $group: { _id: hasKeys(groupId) ? groupId : null, ...groupAccumulators } });
403
630
  // Project stage - rename _id fields back to their original names, and reduce collected distinct
404
631
  // sets. Needed whenever there are group keys OR any distinct alias.
@@ -420,9 +647,9 @@ export class MongoDialect extends AbstractDialect {
420
647
  pipeline.push({ $match: havingFilter });
421
648
  }
422
649
  }
423
- // $sort stage
650
+ // $sort stage - by alias, since $group/$project already renamed everything
424
651
  if (q.$sort) {
425
- const sort = this.sort(entity, q.$sort);
652
+ const sort = this.aliasSort(q.$sort);
426
653
  if (hasKeys(sort)) {
427
654
  pipeline.push({ $sort: sort });
428
655
  }
@@ -441,7 +668,7 @@ export class MongoDialect extends AbstractDialect {
441
668
  * `distinctReducers` maps each DISTINCT alias (collected via `$addToSet`) to the `$project`
442
669
  * operator that reduces its set: `$size` for `$count`, `$sum`/`$avg` for the numeric ops.
443
670
  */
444
- buildGroupSpec(groupEntries) {
671
+ buildGroupSpec(meta, groupEntries) {
445
672
  if (!groupEntries.length) {
446
673
  throw new TypeError('aggregate requires at least one $group column or $agg function');
447
674
  }
@@ -449,25 +676,27 @@ export class MongoDialect extends AbstractDialect {
449
676
  const groupAccumulators = {};
450
677
  const distinctReducers = new Map();
451
678
  for (const entry of groupEntries) {
679
+ // Aliases stay as the caller wrote them ($project maps them back); the *refs* address columns.
680
+ const ref = entry.kind === 'key' ? `$${this.columnOf(meta, entry.alias)}` : `$${this.columnOf(meta, entry.fieldRef)}`;
452
681
  if (entry.kind === 'key') {
453
- groupId[entry.alias] = `$${entry.alias}`;
682
+ groupId[entry.alias] = ref;
454
683
  }
455
684
  else if (entry.distinct) {
456
685
  // Collect the set now; reduce it in $project: `$size` counts it, `$sum`/`$avg` reduce the array.
457
- groupAccumulators[entry.alias] = { $addToSet: `$${entry.fieldRef}` };
686
+ groupAccumulators[entry.alias] = { $addToSet: ref };
458
687
  distinctReducers.set(entry.alias, entry.op === '$count' ? '$size' : entry.op);
459
688
  }
460
689
  else if (entry.op === '$count') {
461
690
  // COUNT(*) counts every row; COUNT(field) counts non-null values, matching SQL.
462
691
  groupAccumulators[entry.alias] =
463
- entry.fieldRef === '*' ? { $sum: 1 } : { $sum: { $cond: [{ $ne: [`$${entry.fieldRef}`, null] }, 1, 0] } };
692
+ entry.fieldRef === '*' ? { $sum: 1 } : { $sum: { $cond: [{ $ne: [ref, null] }, 1, 0] } };
464
693
  }
465
694
  else {
466
695
  const mongoOp = MongoDialect.AGGREGATE_OP_MAP.get(entry.op);
467
696
  if (!mongoOp) {
468
697
  throw TypeError(`unsupported aggregate operator: ${entry.op}`);
469
698
  }
470
- groupAccumulators[entry.alias] = { [mongoOp]: `$${entry.fieldRef}` };
699
+ groupAccumulators[entry.alias] = { [mongoOp]: ref };
471
700
  }
472
701
  }
473
702
  return { groupId, groupAccumulators, distinctReducers };
@@ -522,13 +751,17 @@ export class MongoDialect extends AbstractDialect {
522
751
  }
523
752
  const colName = this.resolveColumnName(key, field);
524
753
  // Resolve index name from @Index metadata, or fall back to convention
525
- const indexMeta = meta.indexes?.find((idx) => idx.columns.includes(key) && MongoDialect.VECTOR_INDEX_TYPES.has(idx.type));
754
+ const indexMeta = meta.indexes?.find((idx) => idx.columns.some((entry) => entry.column === key) && MongoDialect.VECTOR_INDEX_TYPES.has(idx.type));
526
755
  const indexName = indexMeta?.name ?? `${colName}_index`;
756
+ if (!limit) {
757
+ throw new TypeError(`$vectorSearch requires $limit (vector sort on '${key}' of '${meta.name}')`);
758
+ }
527
759
  const stage = {
528
760
  index: indexName,
529
761
  path: colName,
530
762
  queryVector: [...search.$vector],
531
- numCandidates: limit * 10,
763
+ // Atlas caps `numCandidates` at 10000 and wants roughly 10x the limit below that.
764
+ numCandidates: Math.min(limit * 10, MongoDialect.MAX_NUM_CANDIDATES),
532
765
  limit,
533
766
  };
534
767
  // Pre-filter: merge $where into $vectorSearch.filter
@@ -541,4 +774,3 @@ export class MongoDialect extends AbstractDialect {
541
774
  return { $vectorSearch: stage };
542
775
  }
543
776
  }
544
- //# sourceMappingURL=mongoDialect.js.map
@@ -7,4 +7,3 @@ import { MongoDialect } from './mongoDialect.js';
7
7
  */
8
8
  export declare class MongodbNativeDialect extends MongoDialect {
9
9
  }
10
- //# sourceMappingURL=mongodbNativeDialect.d.ts.map
@@ -7,4 +7,3 @@ import { MongoDialect } from './mongoDialect.js';
7
7
  */
8
8
  export class MongodbNativeDialect extends MongoDialect {
9
9
  }
10
- //# sourceMappingURL=mongodbNativeDialect.js.map
@@ -23,6 +23,11 @@ export declare class MongodbQuerier extends AbstractQuerier {
23
23
  private buildVectorPipeline;
24
24
  protected internalAggregate<E extends Document, G extends QueryGroupMap<E>, A extends QueryAggMap<E>>(entity: Type<E>, q: QueryAggregate<E, G, A>, opts?: QueryOptions): Promise<QueryAggregateResult<E, G, A>[]>;
25
25
  protected internalCount<E extends Document>(entity: Type<E>, qm?: QuerySearch<E>, opts?: QueryOptions): Promise<number>;
26
+ /**
27
+ * The `_id`s a search matches. Writes need this whenever the `$where` constrains a relation, since a
28
+ * MongoDB `updateMany`/`deleteMany` filter cannot host a `$lookup` - reads never pay this cost.
29
+ */
30
+ private matchedIds;
26
31
  internalInsertMany<E extends Document>(entity: Type<E>, payloads: E[]): Promise<IdValue<E>[]>;
27
32
  internalUpdateMany<E extends Document>(entity: Type<E>, qm: QuerySearch<E>, payload: UpdatePayload<E>, opts?: QueryOptions): Promise<number>;
28
33
  private buildConflictFilter;
@@ -49,4 +54,3 @@ export declare class MongodbQuerier extends AbstractQuerier {
49
54
  rollbackTransaction(): Promise<void>;
50
55
  internalRelease(): Promise<void>;
51
56
  }
52
- //# sourceMappingURL=mongodbQuerier.d.ts.map