@rvoh/dream 2.12.1 → 2.13.1

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 (200) hide show
  1. package/dist/cjs/src/Dream.js +4 -4
  2. package/dist/cjs/src/dream/QueryDriver/Kysely.js +56 -22
  3. package/dist/cjs/src/helpers/range.js +1 -1
  4. package/dist/cjs/src/utils/datetime/DateTime.js +14 -5
  5. package/dist/esm/src/Dream.js +4 -4
  6. package/dist/esm/src/dream/QueryDriver/Kysely.js +56 -22
  7. package/dist/esm/src/helpers/range.js +1 -1
  8. package/dist/esm/src/utils/datetime/DateTime.js +14 -5
  9. package/dist/types/src/Dream.d.ts +4 -4
  10. package/dist/types/src/db/migration-helpers/DreamMigrationHelpers.d.ts +3 -3
  11. package/dist/types/src/dream/QueryDriver/Kysely.d.ts +11 -0
  12. package/dist/types/src/types/utils.d.ts +1 -1
  13. package/dist/types/src/types/utils.ts +1 -1
  14. package/dist/types/src/types/variadic.d.ts +1 -1
  15. package/dist/types/src/types/variadic.ts +1 -1
  16. package/dist/types/src/utils/datetime/DateTime.d.ts +13 -4
  17. package/docs/assets/hierarchy.js +1 -1
  18. package/docs/classes/db.DreamMigrationHelpers.html +9 -9
  19. package/docs/classes/db.KyselyQueryDriver.html +32 -32
  20. package/docs/classes/db.PostgresQueryDriver.html +33 -33
  21. package/docs/classes/db.QueryDriverBase.html +31 -31
  22. package/docs/classes/errors.CheckConstraintViolation.html +3 -3
  23. package/docs/classes/errors.ColumnOverflow.html +3 -3
  24. package/docs/classes/errors.CreateOrFindByFailedToCreateAndFind.html +3 -3
  25. package/docs/classes/errors.DataIncompatibleWithDatabaseField.html +3 -3
  26. package/docs/classes/errors.DataTypeColumnTypeMismatch.html +3 -3
  27. package/docs/classes/errors.DecryptionError.html +2 -2
  28. package/docs/classes/errors.DecryptionParseError.html +2 -2
  29. package/docs/classes/errors.DecryptionRotationError.html +3 -3
  30. package/docs/classes/errors.GlobalNameNotSet.html +3 -3
  31. package/docs/classes/errors.InvalidCalendarDate.html +2 -2
  32. package/docs/classes/errors.InvalidClockTime.html +2 -2
  33. package/docs/classes/errors.InvalidClockTimeTz.html +2 -2
  34. package/docs/classes/errors.InvalidDateTime.html +2 -2
  35. package/docs/classes/errors.MissingSerializersDefinition.html +3 -3
  36. package/docs/classes/errors.NonLoadedAssociation.html +3 -3
  37. package/docs/classes/errors.NotNullViolation.html +3 -3
  38. package/docs/classes/errors.RecordNotFound.html +3 -3
  39. package/docs/classes/errors.ValidationError.html +3 -3
  40. package/docs/classes/index.CalendarDate.html +33 -33
  41. package/docs/classes/index.ClockTime.html +32 -32
  42. package/docs/classes/index.ClockTimeTz.html +35 -35
  43. package/docs/classes/index.DateTime.html +86 -86
  44. package/docs/classes/index.Decorators.html +19 -19
  45. package/docs/classes/index.Dream.html +118 -118
  46. package/docs/classes/index.DreamApp.html +5 -5
  47. package/docs/classes/index.DreamTransaction.html +2 -2
  48. package/docs/classes/index.Env.html +2 -2
  49. package/docs/classes/index.Query.html +57 -57
  50. package/docs/classes/system.CliFileWriter.html +4 -4
  51. package/docs/classes/system.DreamBin.html +2 -2
  52. package/docs/classes/system.DreamCLI.html +7 -7
  53. package/docs/classes/system.DreamImporter.html +2 -2
  54. package/docs/classes/system.DreamLogos.html +2 -2
  55. package/docs/classes/system.DreamSerializerBuilder.html +11 -11
  56. package/docs/classes/system.ObjectSerializerBuilder.html +8 -8
  57. package/docs/classes/system.PathHelpers.html +3 -3
  58. package/docs/classes/utils.Encrypt.html +3 -3
  59. package/docs/classes/utils.Range.html +2 -2
  60. package/docs/functions/db.closeAllDbConnections.html +1 -1
  61. package/docs/functions/db.dreamDbConnections.html +1 -1
  62. package/docs/functions/db.untypedDb.html +1 -1
  63. package/docs/functions/db.validateColumn.html +1 -1
  64. package/docs/functions/db.validateTable.html +1 -1
  65. package/docs/functions/errors.pgErrorType.html +1 -1
  66. package/docs/functions/index.DreamSerializer.html +1 -1
  67. package/docs/functions/index.ObjectSerializer.html +1 -1
  68. package/docs/functions/index.ReplicaSafe.html +1 -1
  69. package/docs/functions/index.STI.html +1 -1
  70. package/docs/functions/index.SoftDelete.html +1 -1
  71. package/docs/functions/utils.camelize.html +1 -1
  72. package/docs/functions/utils.capitalize.html +1 -1
  73. package/docs/functions/utils.cloneDeepSafe.html +1 -1
  74. package/docs/functions/utils.compact.html +1 -1
  75. package/docs/functions/utils.groupBy.html +1 -1
  76. package/docs/functions/utils.hyphenize.html +1 -1
  77. package/docs/functions/utils.intersection.html +1 -1
  78. package/docs/functions/utils.isEmpty.html +1 -1
  79. package/docs/functions/utils.normalizeUnicode.html +1 -1
  80. package/docs/functions/utils.pascalize.html +1 -1
  81. package/docs/functions/utils.percent.html +1 -1
  82. package/docs/functions/utils.range.html +1 -1
  83. package/docs/functions/utils.round.html +1 -1
  84. package/docs/functions/utils.sanitizeString.html +1 -1
  85. package/docs/functions/utils.snakeify.html +1 -1
  86. package/docs/functions/utils.sort.html +1 -1
  87. package/docs/functions/utils.sortBy.html +1 -1
  88. package/docs/functions/utils.sortObjectByKey.html +1 -1
  89. package/docs/functions/utils.sortObjectByValue.html +1 -1
  90. package/docs/functions/utils.uncapitalize.html +1 -1
  91. package/docs/functions/utils.uniq.html +1 -1
  92. package/docs/hierarchy.html +1 -1
  93. package/docs/interfaces/openapi.OpenapiDescription.html +2 -2
  94. package/docs/interfaces/openapi.OpenapiSchemaProperties.html +1 -1
  95. package/docs/interfaces/openapi.OpenapiSchemaPropertiesShorthand.html +1 -1
  96. package/docs/interfaces/openapi.OpenapiTypeFieldObject.html +1 -1
  97. package/docs/interfaces/types.BelongsToStatement.html +2 -2
  98. package/docs/interfaces/types.DecoratorContext.html +2 -2
  99. package/docs/interfaces/types.DreamAppInitOptions.html +2 -2
  100. package/docs/interfaces/types.DreamAppOpts.html +2 -2
  101. package/docs/interfaces/types.DreamDbConfig.html +5 -5
  102. package/docs/interfaces/types.DurationObject.html +2 -2
  103. package/docs/interfaces/types.EncryptOptions.html +2 -2
  104. package/docs/interfaces/types.InternalAnyTypedSerializerRendersMany.html +2 -2
  105. package/docs/interfaces/types.InternalAnyTypedSerializerRendersOne.html +2 -2
  106. package/docs/interfaces/types.SerializerRendererOpts.html +2 -2
  107. package/docs/types/openapi.CommonOpenapiSchemaObjectFields.html +1 -1
  108. package/docs/types/openapi.OpenapiAllTypes.html +1 -1
  109. package/docs/types/openapi.OpenapiFormats.html +1 -1
  110. package/docs/types/openapi.OpenapiNumberFormats.html +1 -1
  111. package/docs/types/openapi.OpenapiPrimitiveBaseTypes.html +1 -1
  112. package/docs/types/openapi.OpenapiPrimitiveTypes.html +1 -1
  113. package/docs/types/openapi.OpenapiSchemaArray.html +1 -1
  114. package/docs/types/openapi.OpenapiSchemaArrayShorthand.html +1 -1
  115. package/docs/types/openapi.OpenapiSchemaBase.html +1 -1
  116. package/docs/types/openapi.OpenapiSchemaBody.html +1 -1
  117. package/docs/types/openapi.OpenapiSchemaBodyShorthand.html +1 -1
  118. package/docs/types/openapi.OpenapiSchemaCommonFields.html +1 -1
  119. package/docs/types/openapi.OpenapiSchemaExpressionAllOf.html +2 -2
  120. package/docs/types/openapi.OpenapiSchemaExpressionAnyOf.html +2 -2
  121. package/docs/types/openapi.OpenapiSchemaExpressionOneOf.html +2 -2
  122. package/docs/types/openapi.OpenapiSchemaExpressionRef.html +2 -2
  123. package/docs/types/openapi.OpenapiSchemaExpressionRefSchemaShorthand.html +2 -2
  124. package/docs/types/openapi.OpenapiSchemaInteger.html +1 -1
  125. package/docs/types/openapi.OpenapiSchemaNull.html +2 -2
  126. package/docs/types/openapi.OpenapiSchemaNumber.html +1 -1
  127. package/docs/types/openapi.OpenapiSchemaObject.html +1 -1
  128. package/docs/types/openapi.OpenapiSchemaObjectAllOf.html +1 -1
  129. package/docs/types/openapi.OpenapiSchemaObjectAllOfShorthand.html +1 -1
  130. package/docs/types/openapi.OpenapiSchemaObjectAnyOf.html +1 -1
  131. package/docs/types/openapi.OpenapiSchemaObjectAnyOfShorthand.html +1 -1
  132. package/docs/types/openapi.OpenapiSchemaObjectBase.html +1 -1
  133. package/docs/types/openapi.OpenapiSchemaObjectBaseShorthand.html +1 -1
  134. package/docs/types/openapi.OpenapiSchemaObjectOneOf.html +1 -1
  135. package/docs/types/openapi.OpenapiSchemaObjectOneOfShorthand.html +1 -1
  136. package/docs/types/openapi.OpenapiSchemaObjectShorthand.html +1 -1
  137. package/docs/types/openapi.OpenapiSchemaPrimitiveGeneric.html +1 -1
  138. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAllOf.html +2 -2
  139. package/docs/types/openapi.OpenapiSchemaShorthandExpressionAnyOf.html +2 -2
  140. package/docs/types/openapi.OpenapiSchemaShorthandExpressionOneOf.html +2 -2
  141. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializableRef.html +2 -2
  142. package/docs/types/openapi.OpenapiSchemaShorthandExpressionSerializerRef.html +2 -2
  143. package/docs/types/openapi.OpenapiSchemaShorthandPrimitiveGeneric.html +1 -1
  144. package/docs/types/openapi.OpenapiSchemaString.html +1 -1
  145. package/docs/types/openapi.OpenapiShorthandAllTypes.html +1 -1
  146. package/docs/types/openapi.OpenapiShorthandPrimitiveBaseTypes.html +1 -1
  147. package/docs/types/openapi.OpenapiShorthandPrimitiveTypes.html +1 -1
  148. package/docs/types/openapi.OpenapiTypeField.html +1 -1
  149. package/docs/types/system.DreamAppAllowedPackageManagersEnum.html +1 -1
  150. package/docs/types/types.CalendarDateDurationUnit.html +1 -1
  151. package/docs/types/types.CalendarDateObject.html +1 -1
  152. package/docs/types/types.Camelized.html +1 -1
  153. package/docs/types/types.ClockTimeObject.html +1 -1
  154. package/docs/types/types.DbConnectionType.html +1 -1
  155. package/docs/types/types.DbTypes.html +1 -1
  156. package/docs/types/types.DreamAssociationMetadata.html +1 -1
  157. package/docs/types/types.DreamAttributes.html +1 -1
  158. package/docs/types/types.DreamClassAssociationAndStatement.html +1 -1
  159. package/docs/types/types.DreamClassColumn.html +1 -1
  160. package/docs/types/types.DreamColumn.html +1 -1
  161. package/docs/types/types.DreamColumnNames.html +1 -1
  162. package/docs/types/types.DreamLogLevel.html +1 -1
  163. package/docs/types/types.DreamLogger.html +2 -2
  164. package/docs/types/types.DreamModelSerializerType.html +1 -1
  165. package/docs/types/types.DreamOrViewModelClassSerializerKey.html +1 -1
  166. package/docs/types/types.DreamOrViewModelSerializerKey.html +1 -1
  167. package/docs/types/types.DreamParamSafeAttributes.html +1 -1
  168. package/docs/types/types.DreamParamSafeColumnNames.html +1 -1
  169. package/docs/types/types.DreamSerializable.html +1 -1
  170. package/docs/types/types.DreamSerializableArray.html +1 -1
  171. package/docs/types/types.DreamSerializerKey.html +1 -1
  172. package/docs/types/types.DreamSerializers.html +1 -1
  173. package/docs/types/types.DreamVirtualColumns.html +1 -1
  174. package/docs/types/types.DurationUnit.html +1 -1
  175. package/docs/types/types.EncryptAlgorithm.html +1 -1
  176. package/docs/types/types.HasManyStatement.html +1 -1
  177. package/docs/types/types.HasOneStatement.html +1 -1
  178. package/docs/types/types.Hyphenized.html +1 -1
  179. package/docs/types/types.Pascalized.html +1 -1
  180. package/docs/types/types.PrimaryKeyType.html +1 -1
  181. package/docs/types/types.RoundingPrecision.html +1 -1
  182. package/docs/types/types.SerializerCasing.html +1 -1
  183. package/docs/types/types.SimpleObjectSerializerType.html +1 -1
  184. package/docs/types/types.Snakeified.html +1 -1
  185. package/docs/types/types.StrictInterface.html +1 -1
  186. package/docs/types/types.UpdateableAssociationProperties.html +1 -1
  187. package/docs/types/types.UpdateableProperties.html +1 -1
  188. package/docs/types/types.ValidationType.html +1 -1
  189. package/docs/types/types.ViewModel.html +2 -2
  190. package/docs/types/types.ViewModelClass.html +1 -1
  191. package/docs/types/types.WeekdayName.html +1 -1
  192. package/docs/types/types.WhereStatementForDream.html +1 -1
  193. package/docs/types/types.WhereStatementForDreamClass.html +1 -1
  194. package/docs/variables/index.DreamConst.html +1 -1
  195. package/docs/variables/index.ops.html +1 -1
  196. package/docs/variables/openapi.openapiPrimitiveTypes.html +1 -1
  197. package/docs/variables/openapi.openapiShorthandPrimitiveTypes.html +1 -1
  198. package/docs/variables/system.DreamAppAllowedPackageManagersEnumValues.html +1 -1
  199. package/docs/variables/system.primaryKeyTypes.html +1 -1
  200. package/package.json +3 -2
@@ -2020,10 +2020,10 @@ export default class Dream {
2020
2020
  * // as: 'ratings',
2021
2021
  * // polymorphic: true,
2022
2022
  * // source: 'ratings',
2023
- * // where: undefined,
2024
- * // whereNot: undefined,
2025
- * // selfWhere: undefined,
2026
- * // selfWhereNot: undefined,
2023
+ * // and: undefined,
2024
+ * // andNot: undefined,
2025
+ * // selfAnd: undefined,
2026
+ * // selfAndNot: undefined,
2027
2027
  * // primaryKeyOverride: null,
2028
2028
  * // primaryKey: [Function: primaryKey],
2029
2029
  * // primaryKeyValue: [Function: primaryKeyValue],
@@ -1007,7 +1007,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1007
1007
  joinAndStatements: query['innerJoinAndStatements'],
1008
1008
  dreamClass: query['dreamClass'],
1009
1009
  // As recursivelyJoin progresses through the chain of associations that
1010
- // the developer has inclued in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1010
+ // the developer has included in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1011
1011
  // previousTableAlias will be modified so that the join statement can properly reference
1012
1012
  // what we are joining on. When an `associationQuery` is the start of a join, then `baseSqlAlias` is set,
1013
1013
  // this is passed into the very beginning of recursivelyJoin.
@@ -1022,7 +1022,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1022
1022
  joinAndStatements: query['leftJoinAndStatements'],
1023
1023
  dreamClass: query['dreamClass'],
1024
1024
  // As recursivelyJoin progresses through the chain of associations that
1025
- // the developer has inclued in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1025
+ // the developer has included in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1026
1026
  // previousTableAlias will be modified so that the join statement can properly reference
1027
1027
  // what we are joining on. When an `associationQuery` is the start of a join, then `baseSqlAlias` is set,
1028
1028
  // this is passed into the very beginning of recursivelyJoin.
@@ -1367,6 +1367,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1367
1367
  namespaceColumn(column, alias = this.query['baseSqlAlias']) {
1368
1368
  return namespaceColumn(column, alias);
1369
1369
  }
1370
+ /**
1371
+ * @internal
1372
+ *
1373
+ * Builds the table expression passed to Kysely's `innerJoin`/`leftJoin` for an
1374
+ * association. When the alias already snakeifies to the table name, Kysely's
1375
+ * CamelCasePlugin emits the correct identifier from the alias alone, so no
1376
+ * explicit `as` clause is needed; otherwise we join the table aliased as `alias`.
1377
+ *
1378
+ * @returns A table expression string, e.g. `"beautiful_balloons as balloon"`
1379
+ */
1380
+ aliasedJoinTableExpression(tableName, alias) {
1381
+ return snakeify(alias) === tableName ? alias : `${tableName} as ${alias}`;
1382
+ }
1370
1383
  checkForQueryViolations() {
1371
1384
  const invalidWhereNotClauses = this.similarityStatementBuilder().whereNotStatementsWithSimilarityClauses();
1372
1385
  if (invalidWhereNotClauses.length) {
@@ -1502,12 +1515,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1502
1515
  */
1503
1516
  joinsBridgeThroughAssociations({ query, dreamClassTheAssociationIsDefinedOn, throughAssociation,
1504
1517
  /**
1505
- * If the join statement includes an explicit alias, e.g.,
1506
- * `leftJoinPreload('hello as ho', 'world as wd')`
1507
- * then explicitAlias is set (e.g., to 'ho' the first time that `recursivelyJoin`
1508
- * calls this method and to 'ho' the second time `recursivelyJoin` is called)
1509
- * If only implicit aliasing happens (based on association name)
1510
- * (e.g. `leftJoinPreload('hello', 'world')`), then explicitAlias is null
1518
+ * The table alias to use for the association being joined.
1519
+ *
1520
+ * When the join statement includes an explicit alias, e.g.
1521
+ * `leftJoinPreload('hello as ho', 'world as wd')`, explicitAlias is that
1522
+ * alias ('ho' for `hello`, 'wd' for `world`).
1523
+ *
1524
+ * When no explicit alias is given (e.g. `leftJoinPreload('hello', 'world')`),
1525
+ * `recursivelyJoin` passes the association name itself ('hello', 'world') as
1526
+ * the alias, so explicitAlias is still defined.
1527
+ *
1528
+ * explicitAlias is only `undefined` for the intermediate join tables that
1529
+ * `joinsBridgeThroughAssociations` synthesizes while bridging a `through`
1530
+ * association — those tables are never aliased by the developer.
1511
1531
  */
1512
1532
  explicitAlias,
1513
1533
  /**
@@ -1628,12 +1648,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1628
1648
  }
1629
1649
  applyOneJoin({ query, dreamClass, association,
1630
1650
  /**
1631
- * If the join statement includes an explicit alias, e.g.,
1632
- * `leftJoinPreload('hello as ho', 'world as wd')`
1633
- * then explicitAlias is set (e.g., to 'ho' the first time that `recursivelyJoin`
1634
- * calls this method and to 'ho' the second time `recursivelyJoin` is called)
1635
- * If only implicit aliasing happens (based on association name)
1636
- * (e.g. `leftJoinPreload('hello', 'world')`), then explicitAlias is null
1651
+ * The table alias to use for the association being joined.
1652
+ *
1653
+ * When the join statement includes an explicit alias, e.g.
1654
+ * `leftJoinPreload('hello as ho', 'world as wd')`, explicitAlias is that
1655
+ * alias ('ho' for `hello`, 'wd' for `world`).
1656
+ *
1657
+ * When no explicit alias is given (e.g. `leftJoinPreload('hello', 'world')`),
1658
+ * `recursivelyJoin` passes the association name itself ('hello', 'world') as
1659
+ * the alias, so explicitAlias is still defined.
1660
+ *
1661
+ * explicitAlias is only `undefined` for the intermediate join tables that
1662
+ * `joinsBridgeThroughAssociations` synthesizes while bridging a `through`
1663
+ * association — those tables are never aliased by the developer.
1637
1664
  */
1638
1665
  explicitAlias,
1639
1666
  /**
@@ -1672,12 +1699,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1672
1699
  }
1673
1700
  addAssociationJoinStatementToQuery({ query, dreamClass, association,
1674
1701
  /**
1675
- * If the join statement includes an explicit alias, e.g.,
1676
- * `leftJoinPreload('hello as ho', 'world as wd')`
1677
- * then explicitAlias is set (e.g., to 'ho' the first time that `recursivelyJoin`
1678
- * calls this method and to 'ho' the second time `recursivelyJoin` is called)
1679
- * If only implicit aliasing happens (based on association name)
1680
- * (e.g. `leftJoinPreload('hello', 'world')`), then explicitAlias is null
1702
+ * The table alias to use for the association being joined.
1703
+ *
1704
+ * When the join statement includes an explicit alias, e.g.
1705
+ * `leftJoinPreload('hello as ho', 'world as wd')`, explicitAlias is that
1706
+ * alias ('ho' for `hello`, 'wd' for `world`).
1707
+ *
1708
+ * When no explicit alias is given (e.g. `leftJoinPreload('hello', 'world')`),
1709
+ * `recursivelyJoin` passes the association name itself ('hello', 'world') as
1710
+ * the alias, so explicitAlias is still defined.
1711
+ *
1712
+ * explicitAlias is only `undefined` for the intermediate join tables that
1713
+ * `joinsBridgeThroughAssociations` synthesizes while bridging a `through`
1714
+ * association — those tables are never aliased by the developer.
1681
1715
  */
1682
1716
  explicitAlias,
1683
1717
  /**
@@ -1714,7 +1748,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1714
1748
  leftJoinStatements: this.query['leftJoinStatements'],
1715
1749
  });
1716
1750
  const to = (dreamClassThroughAssociationWantsToHydrate ?? association.modelCB()).table;
1717
- const joinTableExpression = snakeify(currentTableAlias) === to ? currentTableAlias : `${to} as ${currentTableAlias}`;
1751
+ const joinTableExpression = this.aliasedJoinTableExpression(to, currentTableAlias);
1718
1752
  query = query[(joinType === 'inner' ? 'innerJoin' : 'leftJoin')](joinTableExpression, (join) => {
1719
1753
  join = join.onRef(this.namespaceColumn(association.foreignKey(), previousTableAlias), '=', this.namespaceColumn(association.primaryKey(undefined, {
1720
1754
  associatedClassOverride: dreamClassThroughAssociationWantsToHydrate,
@@ -1747,7 +1781,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1747
1781
  }
1748
1782
  else {
1749
1783
  const to = association.modelCB().table;
1750
- const joinTableExpression = snakeify(currentTableAlias) === to ? currentTableAlias : `${to} as ${currentTableAlias}`;
1784
+ const joinTableExpression = this.aliasedJoinTableExpression(to, currentTableAlias);
1751
1785
  query = query[(joinType === 'inner' ? 'innerJoin' : 'leftJoin')](joinTableExpression, (join) => {
1752
1786
  join = join.onRef(this.namespaceColumn(association.primaryKey(), previousTableAlias), '=', this.namespaceColumn(association.foreignKey(), currentTableAlias));
1753
1787
  if (association.polymorphic) {
@@ -9,7 +9,7 @@ export class Range {
9
9
  this.begin = begin;
10
10
  this.end = end;
11
11
  this.excludeEnd = excludeEnd;
12
- if (!begin && !end)
12
+ if (begin == null && end == null)
13
13
  throw new Error('Must pass either begin or end to a range');
14
14
  }
15
15
  }
@@ -682,14 +682,23 @@ export class DateTime {
682
682
  return this.luxonDatetime.toJSDate();
683
683
  }
684
684
  /**
685
- * Returns an ISO 8601 string representation (for valueOf() operations).
685
+ * Returns a UTC-normalized ISO 8601 string representation (for valueOf() operations).
686
686
  *
687
- * Preserves the timezone of the DateTime instance.
687
+ * Unlike {@link DateTime.toISO} / {@link DateTime.toString} / {@link DateTime.toJSON}, which
688
+ * preserve the instance's zone, `valueOf` always normalizes to UTC (`…Z`) before stringifying.
689
+ * Because every value is rendered in the same zone with fixed-width 6-digit fractional seconds,
690
+ * JavaScript's relational operators (`<`, `>`, `<=`, `>=`), loose `==`, and `+` — which route
691
+ * through `valueOf` — order and compare by the underlying instant rather than by wall-clock text.
692
+ * This makes cross-zone comparisons correct. As a consequence `dt + ''` and `Number(dt)` reflect
693
+ * UTC, while `` `${dt}` ``, `toString`, and `toJSON` stay local because they don't use `valueOf`.
688
694
  *
689
- * @returns ISO datetime string with microsecond precision
695
+ * Limit: lexical ordering equals chronological ordering only for years 0001–9999. BC/negative
696
+ * years and years ≥ 10000 sort incorrectly (ISO's `-`/`+` year prefixes break lexical order).
697
+ *
698
+ * @returns UTC ISO datetime string with microsecond precision
690
699
  * @example
691
700
  * ```ts
692
- * DateTime.local(2017, 3, 12).valueOf() // Preserves local timezone
701
+ * DateTime.local(2017, 3, 12).valueOf() // UTC-normalized ISO string
693
702
  * DateTime.fromISO('2026-02-07T09:03:44.123456Z').valueOf() // '2026-02-07T09:03:44.123456Z'
694
703
  * ```
695
704
  */
@@ -697,7 +706,7 @@ export class DateTime {
697
706
  valueOf() {
698
707
  if (this._valueOf)
699
708
  return this._valueOf;
700
- this._valueOf = this.toISO();
709
+ this._valueOf = this.toUTC().toISO();
701
710
  return this._valueOf;
702
711
  }
703
712
  /**
@@ -2020,10 +2020,10 @@ export default class Dream {
2020
2020
  * // as: 'ratings',
2021
2021
  * // polymorphic: true,
2022
2022
  * // source: 'ratings',
2023
- * // where: undefined,
2024
- * // whereNot: undefined,
2025
- * // selfWhere: undefined,
2026
- * // selfWhereNot: undefined,
2023
+ * // and: undefined,
2024
+ * // andNot: undefined,
2025
+ * // selfAnd: undefined,
2026
+ * // selfAndNot: undefined,
2027
2027
  * // primaryKeyOverride: null,
2028
2028
  * // primaryKey: [Function: primaryKey],
2029
2029
  * // primaryKeyValue: [Function: primaryKeyValue],
@@ -1007,7 +1007,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1007
1007
  joinAndStatements: query['innerJoinAndStatements'],
1008
1008
  dreamClass: query['dreamClass'],
1009
1009
  // As recursivelyJoin progresses through the chain of associations that
1010
- // the developer has inclued in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1010
+ // the developer has included in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1011
1011
  // previousTableAlias will be modified so that the join statement can properly reference
1012
1012
  // what we are joining on. When an `associationQuery` is the start of a join, then `baseSqlAlias` is set,
1013
1013
  // this is passed into the very beginning of recursivelyJoin.
@@ -1022,7 +1022,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1022
1022
  joinAndStatements: query['leftJoinAndStatements'],
1023
1023
  dreamClass: query['dreamClass'],
1024
1024
  // As recursivelyJoin progresses through the chain of associations that
1025
- // the developer has inclued in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1025
+ // the developer has included in a join statement (e.g. `leftJoinPreload('hello as ho', 'world as wd')`),
1026
1026
  // previousTableAlias will be modified so that the join statement can properly reference
1027
1027
  // what we are joining on. When an `associationQuery` is the start of a join, then `baseSqlAlias` is set,
1028
1028
  // this is passed into the very beginning of recursivelyJoin.
@@ -1367,6 +1367,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1367
1367
  namespaceColumn(column, alias = this.query['baseSqlAlias']) {
1368
1368
  return namespaceColumn(column, alias);
1369
1369
  }
1370
+ /**
1371
+ * @internal
1372
+ *
1373
+ * Builds the table expression passed to Kysely's `innerJoin`/`leftJoin` for an
1374
+ * association. When the alias already snakeifies to the table name, Kysely's
1375
+ * CamelCasePlugin emits the correct identifier from the alias alone, so no
1376
+ * explicit `as` clause is needed; otherwise we join the table aliased as `alias`.
1377
+ *
1378
+ * @returns A table expression string, e.g. `"beautiful_balloons as balloon"`
1379
+ */
1380
+ aliasedJoinTableExpression(tableName, alias) {
1381
+ return snakeify(alias) === tableName ? alias : `${tableName} as ${alias}`;
1382
+ }
1370
1383
  checkForQueryViolations() {
1371
1384
  const invalidWhereNotClauses = this.similarityStatementBuilder().whereNotStatementsWithSimilarityClauses();
1372
1385
  if (invalidWhereNotClauses.length) {
@@ -1502,12 +1515,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1502
1515
  */
1503
1516
  joinsBridgeThroughAssociations({ query, dreamClassTheAssociationIsDefinedOn, throughAssociation,
1504
1517
  /**
1505
- * If the join statement includes an explicit alias, e.g.,
1506
- * `leftJoinPreload('hello as ho', 'world as wd')`
1507
- * then explicitAlias is set (e.g., to 'ho' the first time that `recursivelyJoin`
1508
- * calls this method and to 'ho' the second time `recursivelyJoin` is called)
1509
- * If only implicit aliasing happens (based on association name)
1510
- * (e.g. `leftJoinPreload('hello', 'world')`), then explicitAlias is null
1518
+ * The table alias to use for the association being joined.
1519
+ *
1520
+ * When the join statement includes an explicit alias, e.g.
1521
+ * `leftJoinPreload('hello as ho', 'world as wd')`, explicitAlias is that
1522
+ * alias ('ho' for `hello`, 'wd' for `world`).
1523
+ *
1524
+ * When no explicit alias is given (e.g. `leftJoinPreload('hello', 'world')`),
1525
+ * `recursivelyJoin` passes the association name itself ('hello', 'world') as
1526
+ * the alias, so explicitAlias is still defined.
1527
+ *
1528
+ * explicitAlias is only `undefined` for the intermediate join tables that
1529
+ * `joinsBridgeThroughAssociations` synthesizes while bridging a `through`
1530
+ * association — those tables are never aliased by the developer.
1511
1531
  */
1512
1532
  explicitAlias,
1513
1533
  /**
@@ -1628,12 +1648,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1628
1648
  }
1629
1649
  applyOneJoin({ query, dreamClass, association,
1630
1650
  /**
1631
- * If the join statement includes an explicit alias, e.g.,
1632
- * `leftJoinPreload('hello as ho', 'world as wd')`
1633
- * then explicitAlias is set (e.g., to 'ho' the first time that `recursivelyJoin`
1634
- * calls this method and to 'ho' the second time `recursivelyJoin` is called)
1635
- * If only implicit aliasing happens (based on association name)
1636
- * (e.g. `leftJoinPreload('hello', 'world')`), then explicitAlias is null
1651
+ * The table alias to use for the association being joined.
1652
+ *
1653
+ * When the join statement includes an explicit alias, e.g.
1654
+ * `leftJoinPreload('hello as ho', 'world as wd')`, explicitAlias is that
1655
+ * alias ('ho' for `hello`, 'wd' for `world`).
1656
+ *
1657
+ * When no explicit alias is given (e.g. `leftJoinPreload('hello', 'world')`),
1658
+ * `recursivelyJoin` passes the association name itself ('hello', 'world') as
1659
+ * the alias, so explicitAlias is still defined.
1660
+ *
1661
+ * explicitAlias is only `undefined` for the intermediate join tables that
1662
+ * `joinsBridgeThroughAssociations` synthesizes while bridging a `through`
1663
+ * association — those tables are never aliased by the developer.
1637
1664
  */
1638
1665
  explicitAlias,
1639
1666
  /**
@@ -1672,12 +1699,19 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1672
1699
  }
1673
1700
  addAssociationJoinStatementToQuery({ query, dreamClass, association,
1674
1701
  /**
1675
- * If the join statement includes an explicit alias, e.g.,
1676
- * `leftJoinPreload('hello as ho', 'world as wd')`
1677
- * then explicitAlias is set (e.g., to 'ho' the first time that `recursivelyJoin`
1678
- * calls this method and to 'ho' the second time `recursivelyJoin` is called)
1679
- * If only implicit aliasing happens (based on association name)
1680
- * (e.g. `leftJoinPreload('hello', 'world')`), then explicitAlias is null
1702
+ * The table alias to use for the association being joined.
1703
+ *
1704
+ * When the join statement includes an explicit alias, e.g.
1705
+ * `leftJoinPreload('hello as ho', 'world as wd')`, explicitAlias is that
1706
+ * alias ('ho' for `hello`, 'wd' for `world`).
1707
+ *
1708
+ * When no explicit alias is given (e.g. `leftJoinPreload('hello', 'world')`),
1709
+ * `recursivelyJoin` passes the association name itself ('hello', 'world') as
1710
+ * the alias, so explicitAlias is still defined.
1711
+ *
1712
+ * explicitAlias is only `undefined` for the intermediate join tables that
1713
+ * `joinsBridgeThroughAssociations` synthesizes while bridging a `through`
1714
+ * association — those tables are never aliased by the developer.
1681
1715
  */
1682
1716
  explicitAlias,
1683
1717
  /**
@@ -1714,7 +1748,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1714
1748
  leftJoinStatements: this.query['leftJoinStatements'],
1715
1749
  });
1716
1750
  const to = (dreamClassThroughAssociationWantsToHydrate ?? association.modelCB()).table;
1717
- const joinTableExpression = snakeify(currentTableAlias) === to ? currentTableAlias : `${to} as ${currentTableAlias}`;
1751
+ const joinTableExpression = this.aliasedJoinTableExpression(to, currentTableAlias);
1718
1752
  query = query[(joinType === 'inner' ? 'innerJoin' : 'leftJoin')](joinTableExpression, (join) => {
1719
1753
  join = join.onRef(this.namespaceColumn(association.foreignKey(), previousTableAlias), '=', this.namespaceColumn(association.primaryKey(undefined, {
1720
1754
  associatedClassOverride: dreamClassThroughAssociationWantsToHydrate,
@@ -1747,7 +1781,7 @@ export default class KyselyQueryDriver extends QueryDriverBase {
1747
1781
  }
1748
1782
  else {
1749
1783
  const to = association.modelCB().table;
1750
- const joinTableExpression = snakeify(currentTableAlias) === to ? currentTableAlias : `${to} as ${currentTableAlias}`;
1784
+ const joinTableExpression = this.aliasedJoinTableExpression(to, currentTableAlias);
1751
1785
  query = query[(joinType === 'inner' ? 'innerJoin' : 'leftJoin')](joinTableExpression, (join) => {
1752
1786
  join = join.onRef(this.namespaceColumn(association.primaryKey(), previousTableAlias), '=', this.namespaceColumn(association.foreignKey(), currentTableAlias));
1753
1787
  if (association.polymorphic) {
@@ -9,7 +9,7 @@ export class Range {
9
9
  this.begin = begin;
10
10
  this.end = end;
11
11
  this.excludeEnd = excludeEnd;
12
- if (!begin && !end)
12
+ if (begin == null && end == null)
13
13
  throw new Error('Must pass either begin or end to a range');
14
14
  }
15
15
  }
@@ -682,14 +682,23 @@ export class DateTime {
682
682
  return this.luxonDatetime.toJSDate();
683
683
  }
684
684
  /**
685
- * Returns an ISO 8601 string representation (for valueOf() operations).
685
+ * Returns a UTC-normalized ISO 8601 string representation (for valueOf() operations).
686
686
  *
687
- * Preserves the timezone of the DateTime instance.
687
+ * Unlike {@link DateTime.toISO} / {@link DateTime.toString} / {@link DateTime.toJSON}, which
688
+ * preserve the instance's zone, `valueOf` always normalizes to UTC (`…Z`) before stringifying.
689
+ * Because every value is rendered in the same zone with fixed-width 6-digit fractional seconds,
690
+ * JavaScript's relational operators (`<`, `>`, `<=`, `>=`), loose `==`, and `+` — which route
691
+ * through `valueOf` — order and compare by the underlying instant rather than by wall-clock text.
692
+ * This makes cross-zone comparisons correct. As a consequence `dt + ''` and `Number(dt)` reflect
693
+ * UTC, while `` `${dt}` ``, `toString`, and `toJSON` stay local because they don't use `valueOf`.
688
694
  *
689
- * @returns ISO datetime string with microsecond precision
695
+ * Limit: lexical ordering equals chronological ordering only for years 0001–9999. BC/negative
696
+ * years and years ≥ 10000 sort incorrectly (ISO's `-`/`+` year prefixes break lexical order).
697
+ *
698
+ * @returns UTC ISO datetime string with microsecond precision
690
699
  * @example
691
700
  * ```ts
692
- * DateTime.local(2017, 3, 12).valueOf() // Preserves local timezone
701
+ * DateTime.local(2017, 3, 12).valueOf() // UTC-normalized ISO string
693
702
  * DateTime.fromISO('2026-02-07T09:03:44.123456Z').valueOf() // '2026-02-07T09:03:44.123456Z'
694
703
  * ```
695
704
  */
@@ -697,7 +706,7 @@ export class DateTime {
697
706
  valueOf() {
698
707
  if (this._valueOf)
699
708
  return this._valueOf;
700
- this._valueOf = this.toISO();
709
+ this._valueOf = this.toUTC().toISO();
701
710
  return this._valueOf;
702
711
  }
703
712
  /**
@@ -1660,10 +1660,10 @@ export default class Dream {
1660
1660
  * // as: 'ratings',
1661
1661
  * // polymorphic: true,
1662
1662
  * // source: 'ratings',
1663
- * // where: undefined,
1664
- * // whereNot: undefined,
1665
- * // selfWhere: undefined,
1666
- * // selfWhereNot: undefined,
1663
+ * // and: undefined,
1664
+ * // andNot: undefined,
1665
+ * // selfAnd: undefined,
1666
+ * // selfAndNot: undefined,
1667
1667
  * // primaryKeyOverride: null,
1668
1668
  * // primaryKey: [Function: primaryKey],
1669
1669
  * // primaryKeyValue: [Function: primaryKeyValue],
@@ -154,11 +154,11 @@ interface DropValueFromEnumTablesAndColumnsForArrayBase {
154
154
  array: true;
155
155
  }
156
156
  interface DropValueWithRemovalFromEnumTablesAndColumnsForArray extends DropValueFromEnumTablesAndColumnsForArrayBase {
157
- behavior: 'replace';
158
- replaceWith: string;
157
+ behavior: 'remove';
159
158
  }
160
159
  interface DropValueWithReplacementFromEnumTablesAndColumnsForArray extends DropValueFromEnumTablesAndColumnsForArrayBase {
161
- behavior: 'remove';
160
+ behavior: 'replace';
161
+ replaceWith: string;
162
162
  }
163
163
  type DropValueFromEnumTablesAndColumnsForNonArray = {
164
164
  table: string;
@@ -362,6 +362,17 @@ export default class KyselyQueryDriver<DreamInstance extends Dream> extends Quer
362
362
  * @returns A string
363
363
  */
364
364
  private namespaceColumn;
365
+ /**
366
+ * @internal
367
+ *
368
+ * Builds the table expression passed to Kysely's `innerJoin`/`leftJoin` for an
369
+ * association. When the alias already snakeifies to the table name, Kysely's
370
+ * CamelCasePlugin emits the correct identifier from the alias alone, so no
371
+ * explicit `as` clause is needed; otherwise we join the table aliased as `alias`.
372
+ *
373
+ * @returns A table expression string, e.g. `"beautiful_balloons as balloon"`
374
+ */
375
+ private aliasedJoinTableExpression;
365
376
  private checkForQueryViolations;
366
377
  private similarityStatementBuilder;
367
378
  /**
@@ -59,7 +59,7 @@ type DecrementTable = {
59
59
  12: 11;
60
60
  13: 12;
61
61
  14: 13;
62
- 15: 15;
62
+ 15: 14;
63
63
  16: 15;
64
64
  17: 16;
65
65
  18: 17;
@@ -74,7 +74,7 @@ type DecrementTable = {
74
74
  12: 11
75
75
  13: 12
76
76
  14: 13
77
- 15: 15
77
+ 15: 14
78
78
  16: 15
79
79
  17: 16
80
80
  18: 17
@@ -23,7 +23,7 @@ export type VariadicJoinsArgs<I extends Dream, DB, Schema, ConcreteTableName ext
23
23
  type VariadicCheckThenRecurse<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], RecursionType extends RecursionTypes, UsedNamespaces, Depth extends number, PreviousConcreteTableName, ConcreteAssociationName, AssociationNamesOrOnClause, LastDream extends Dream = I, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], AllowedNamesForArrayArg = PreviousConcreteTableName extends keyof Schema ? AssociationNamesForAssociation<Schema, PreviousConcreteTableName, ConcreteAssociationName> : keyof SchemaAssociations & string, NthArgument extends VALID | INVALID = ConcreteArgs['length'] extends 0 ? VALID : ConcreteArgs[0] extends keyof SchemaAssociations & string ? VALID : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? VALID : ConcreteArgs[0] extends JoinAndStatements<LastDream, DB, Schema, ConcreteTableName, RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>> ? VALID : ConcreteArgs[0] extends readonly AllowedNamesForArrayArg[] ? VALID : ConcreteArgs[0] extends JoinAndStatements<LastDream, DB, Schema, ConcreteTableName, RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>> ? VALID : ConcreteArgs[0] extends AllowedNamesForArrayArg ? VALID : INVALID> = NthArgument extends INVALID ? `invalid where clause in argument ${Inc<Depth>}` : ConcreteArgs['length'] extends 0 ? AssociationNamesOrOnClause : VariadicRecurse<I, DB, Schema, ConcreteTableName, ConcreteArgs, RecursionType, UsedNamespaces, Depth, PreviousConcreteTableName, ConcreteAssociationName, LastDream>;
24
24
  export type AliasedSchemaAssociation<Schema, ConcreteTableName extends keyof Schema, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]]> = `${keyof SchemaAssociations & string} as ${string}`;
25
25
  type VariadicRecurse<I extends Dream, DB, Schema, ConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, ConcreteArgs extends readonly unknown[], RecursionType extends RecursionTypes, UsedNamespaces, Depth extends number, PreviousConcreteTableName, ConcreteAssociationName, LastDream extends Dream, SchemaAssociations = Schema[ConcreteTableName]['associations' & keyof Schema[ConcreteTableName]], PolymorphicTableNamesUnion = PreviousConcreteTableName extends keyof Schema ? AssociationTableNamesForAssociation<Schema, PreviousConcreteTableName, ConcreteAssociationName> : ConcreteTableName, CrossPolymorphicTableForCurrentArg = ConcreteArgs[0] extends string ? TableContainingAssociationInUnion<Schema, PolymorphicTableNamesUnion, ConcreteArgs[0]> : never, EffectiveConcreteTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = ConcreteArgs[0] extends keyof SchemaAssociations & string ? ConcreteTableName : [CrossPolymorphicTableForCurrentArg] extends [never] ? ConcreteTableName : CrossPolymorphicTableForCurrentArg extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB ? CrossPolymorphicTableForCurrentArg : ConcreteTableName, EffectiveSchemaAssociations = Schema[EffectiveConcreteTableName]['associations' & keyof Schema[EffectiveConcreteTableName]], ConcreteNthArg extends (keyof SchemaAssociations & string) | (keyof EffectiveSchemaAssociations & string) | AliasedSchemaAssociation<Schema, ConcreteTableName> | null = ConcreteArgs[0] extends undefined ? null : ConcreteArgs[0] extends null ? null : ConcreteArgs[0] extends keyof SchemaAssociations & string ? ConcreteArgs[0] & keyof SchemaAssociations & string : ConcreteArgs[0] extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? ConcreteArgs[0] & AliasedSchemaAssociation<Schema, ConcreteTableName> : ConcreteArgs[0] extends keyof EffectiveSchemaAssociations & string ? ConcreteArgs[0] & keyof EffectiveSchemaAssociations & string : null, NextUsedNamespaces = ConcreteArgs[0] extends undefined ? never : ConcreteArgs[0] extends null ? never : ConcreteNthArg extends null ? UsedNamespaces : UsedNamespaces | ConcreteNthArg, CurrentArgumentType extends IS_ASSOCIATION_NAME | IS_ASSOCIATION_ALIAS | IS_CROSS_POLYMORPHIC_ASSOCIATION_NAME | IS_NOT_ASSOCIATION_NAME = ConcreteNthArg extends null ? IS_NOT_ASSOCIATION_NAME : ConcreteNthArg extends keyof SchemaAssociations & string ? IS_ASSOCIATION_NAME : ConcreteNthArg extends AliasedSchemaAssociation<Schema, ConcreteTableName> ? IS_ASSOCIATION_ALIAS : ConcreteNthArg extends keyof EffectiveSchemaAssociations & string ? IS_CROSS_POLYMORPHIC_ASSOCIATION_NAME : IS_NOT_ASSOCIATION_NAME, NextPreviousConcreteTableName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteTableName : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteTableName : CurrentArgumentType extends IS_CROSS_POLYMORPHIC_ASSOCIATION_NAME ? EffectiveConcreteTableName : PreviousConcreteTableName, NextUnaliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${infer AssocName extends string} as ${string}` ? AssocName & keyof SchemaAssociations & string : never : CurrentArgumentType extends IS_CROSS_POLYMORPHIC_ASSOCIATION_NAME ? ConcreteNthArg : never, NextAliasedAssociationName = CurrentArgumentType extends IS_ASSOCIATION_NAME ? ConcreteNthArg : CurrentArgumentType extends IS_ASSOCIATION_ALIAS ? ConcreteNthArg extends `${string} as ${infer AssocAlias extends string}` ? AssocAlias & string : ConcreteAssociationName : CurrentArgumentType extends IS_CROSS_POLYMORPHIC_ASSOCIATION_NAME ? ConcreteNthArg : ConcreteAssociationName, IsAssociationNameOrAlias extends boolean = CurrentArgumentType extends IS_ASSOCIATION_NAME | IS_ASSOCIATION_ALIAS | IS_CROSS_POLYMORPHIC_ASSOCIATION_NAME ? true : false, NextTableName extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = IsAssociationNameOrAlias extends true ? AssociationTableName<Schema, EffectiveConcreteTableName, NextUnaliasedAssociationName> : ConcreteTableName & AssociationTableNames<DB, Schema> & keyof DB, AllowedAssociationNames = IsAssociationNameOrAlias extends true ? AssociationNamesForAssociation<Schema, EffectiveConcreteTableName, NextUnaliasedAssociationName> : PreviousConcreteTableName extends keyof Schema ? AssociationNamesForAssociation<Schema, PreviousConcreteTableName, ConcreteAssociationName> : AssociationNamesForTable<Schema, ConcreteTableName>, // fall back to association names for table for root only
26
- AssociationTableOrConcreteTable extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = IsAssociationNameOrAlias extends true ? AssociationTableName<Schema, EffectiveConcreteTableName, NextUnaliasedAssociationName> : ConcreteTableName, CurrentRequiredOnClauseKeys = IsAssociationNameOrAlias extends true ? RequiredOnClauseKeys<Schema, EffectiveConcreteTableName, NextAliasedAssociationName> : RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>, AllowedNextArgValues = RecursionType extends 'load' ? AllowedNextArgValuesForLoad<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, AllowedAssociationNames, AssociationTableOrConcreteTable, CurrentRequiredOnClauseKeys> : RecursionType extends 'leftJoinLoad' ? AllowedNextArgValuesForLeftJoinLoad<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, AllowedAssociationNames, AssociationTableOrConcreteTable, CurrentRequiredOnClauseKeys, NextUsedNamespaces> : RecursionType extends 'join' ? AllowedNextArgValuesForJoin<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, AllowedAssociationNames, AssociationTableOrConcreteTable, CurrentRequiredOnClauseKeys, NextUsedNamespaces> : never> = Depth extends MAX_VARIADIC_DEPTH ? never : VariadicCheckThenRecurse<I, DB, Schema, NextTableName, ReadonlyTail<ConcreteArgs>, RecursionType, NextUsedNamespaces, Inc<Depth>, NextPreviousConcreteTableName, NextAliasedAssociationName, AllowedNextArgValues, DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> extends Dream ? DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> : LastDream>;
26
+ AssociationTableOrConcreteTable extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB = IsAssociationNameOrAlias extends true ? AssociationTableName<Schema, EffectiveConcreteTableName, NextUnaliasedAssociationName> : ConcreteTableName, CurrentRequiredOnClauseKeys = IsAssociationNameOrAlias extends true ? RequiredOnClauseKeys<Schema, EffectiveConcreteTableName, NextUnaliasedAssociationName> : RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>, AllowedNextArgValues = RecursionType extends 'load' ? AllowedNextArgValuesForLoad<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, AllowedAssociationNames, AssociationTableOrConcreteTable, CurrentRequiredOnClauseKeys> : RecursionType extends 'leftJoinLoad' ? AllowedNextArgValuesForLeftJoinLoad<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, AllowedAssociationNames, AssociationTableOrConcreteTable, CurrentRequiredOnClauseKeys, NextUsedNamespaces> : RecursionType extends 'join' ? AllowedNextArgValuesForJoin<DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream>, DB, Schema, AllowedAssociationNames, AssociationTableOrConcreteTable, CurrentRequiredOnClauseKeys, NextUsedNamespaces> : never> = Depth extends MAX_VARIADIC_DEPTH ? never : VariadicCheckThenRecurse<I, DB, Schema, NextTableName, ReadonlyTail<ConcreteArgs>, RecursionType, NextUsedNamespaces, Inc<Depth>, NextPreviousConcreteTableName, NextAliasedAssociationName, AllowedNextArgValues, DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> extends Dream ? DreamAssociationNameToAssociatedModel<LastDream, ConcreteArgs[0] & keyof LastDream> : LastDream>;
27
27
  type AllowedNextArgValuesForLoad<I extends Dream, DB, Schema, AllowedNames, TableForJoin extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation> = AllowedNames | AllowedNames[] | JoinAndStatements<I, DB, Schema, TableForJoin, RequiredOnClauseKeysForThisAssociation>;
28
28
  type AllowedNextArgValuesForLeftJoinLoad<I extends Dream, DB, Schema, AllowedNames, TableForJoin extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, UsedNamespaces> = Exclude<AllowedNames, UsedNamespaces> | Exclude<AllowedNames, UsedNamespaces>[] | JoinAndStatements<I, DB, Schema, TableForJoin, RequiredOnClauseKeysForThisAssociation>;
29
29
  type AllowedNextArgValuesForJoin<I extends Dream, DB, Schema, AllowedNames, TableForJoin extends keyof Schema & AssociationTableNames<DB, Schema> & keyof DB, RequiredOnClauseKeysForThisAssociation, UsedNamespaces> = Exclude<AllowedNames, UsedNamespaces> | JoinAndStatements<I, DB, Schema, TableForJoin, RequiredOnClauseKeysForThisAssociation>;
@@ -341,7 +341,7 @@ type VariadicRecurse<
341
341
  : ConcreteTableName,
342
342
  //
343
343
  CurrentRequiredOnClauseKeys = IsAssociationNameOrAlias extends true
344
- ? RequiredOnClauseKeys<Schema, EffectiveConcreteTableName, NextAliasedAssociationName>
344
+ ? RequiredOnClauseKeys<Schema, EffectiveConcreteTableName, NextUnaliasedAssociationName>
345
345
  : RequiredOnClauseKeys<Schema, PreviousConcreteTableName, ConcreteAssociationName>,
346
346
  //
347
347
  AllowedNextArgValues = RecursionType extends 'load'
@@ -546,14 +546,23 @@ export declare class DateTime {
546
546
  */
547
547
  toJSDate(): Date;
548
548
  /**
549
- * Returns an ISO 8601 string representation (for valueOf() operations).
549
+ * Returns a UTC-normalized ISO 8601 string representation (for valueOf() operations).
550
550
  *
551
- * Preserves the timezone of the DateTime instance.
551
+ * Unlike {@link DateTime.toISO} / {@link DateTime.toString} / {@link DateTime.toJSON}, which
552
+ * preserve the instance's zone, `valueOf` always normalizes to UTC (`…Z`) before stringifying.
553
+ * Because every value is rendered in the same zone with fixed-width 6-digit fractional seconds,
554
+ * JavaScript's relational operators (`<`, `>`, `<=`, `>=`), loose `==`, and `+` — which route
555
+ * through `valueOf` — order and compare by the underlying instant rather than by wall-clock text.
556
+ * This makes cross-zone comparisons correct. As a consequence `dt + ''` and `Number(dt)` reflect
557
+ * UTC, while `` `${dt}` ``, `toString`, and `toJSON` stay local because they don't use `valueOf`.
552
558
  *
553
- * @returns ISO datetime string with microsecond precision
559
+ * Limit: lexical ordering equals chronological ordering only for years 0001–9999. BC/negative
560
+ * years and years ≥ 10000 sort incorrectly (ISO's `-`/`+` year prefixes break lexical order).
561
+ *
562
+ * @returns UTC ISO datetime string with microsecond precision
554
563
  * @example
555
564
  * ```ts
556
- * DateTime.local(2017, 3, 12).valueOf() // Preserves local timezone
565
+ * DateTime.local(2017, 3, 12).valueOf() // UTC-normalized ISO string
557
566
  * DateTime.fromISO('2026-02-07T09:03:44.123456Z').valueOf() // '2026-02-07T09:03:44.123456Z'
558
567
  * ```
559
568
  */
@@ -1 +1 @@
1
- window.hierarchyData = "eJyVks1uAiEURt/lrtE6P+LIspomTVPbJk27MC5w5tohMmCAsZkY372hbqi1HdwAIffjHOAewGjtLLBlQtOcTEcrAgY3EksntLLADjAd+VHxBoHBS4ummxuxR3PLLQKBrVAVsCQtCLRGAoNScmvR3lTr4Vn1sHaNBHKqAAbOVgMfH5w2CJS1kJVBBWyZZpPVkUCaTQL6Q2dRdsGpPfxf9dcYJBktvIKfA4dnbd2HQRtvcSHR4+Gp4yKkzmostzOtrDNcKPcmtOT+h/5DozHa2OFf0QgHOqKhg5Zto572aDZSf8aQfwRieGke8Obc8XtV6mbHnVhLfBeu9ntrbvFOoKwiFHrPuKojxkVB/KOQhOYZSShNvhuE5tmZ9mu3w9Pt/epR2Ia7so70vRyOeT6aBB4L7RatlNe0ynmkj3k8fgGG6267"
1
+ window.hierarchyData = "eJyVkkFvwiAUx7/LO6OzaFvLcZolyzK3Jct2MB6wfa5ECgaoS2P87gvzwpxb8QKEvD+/H/AOYLR2FtgyyeiUFKMVAYMbiaUTWllgByhGflS8QWDw0qLp5kbs0dxyi0BgK1QFLKFTAq2RwKCU3Fq0N9V6eFY9rF0jgZwqgIGz1cDHB6cNAmUtZGVQAVvScb46EqDjPKA/dBZlF5zaw/9Vf41BMs6pV/Bz4PCsrfswaOMtLiR6PDw1LULqrMZyO9PKOsOFcm9CS+5/6D80GqONHf4VjXDIkvDvZ1q2jXrao9lI/RlD/hGI4dFpwJtzx+9VqZsdd2It8V242u+tucU7gbKKUOg946qOSAtK/KOQJJvkJMmy9LtBskl+pv3a7fB0e796FLbhrqwjfS+HY54vSwOPhXaLVsprWuU80sc8Hr8AarputQ=="