hysteria-orm 12.0.0 → 12.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.cts CHANGED
@@ -143,63 +143,6 @@ type DateTimeOptions = {
143
143
  */
144
144
  type DatabaseTableOptions = MysqlTableOptions | PostgresTableOptions | SqliteTableOptions | MssqlTableOptions | MysqlAdvancedTableOptions;
145
145
 
146
- declare abstract class QueryNode {
147
- /**
148
- * Sql keyword to use for the query e.g. "select"
149
- */
150
- keyword: string;
151
- /**
152
- * The current parameter index to use for the query
153
- */
154
- currParamIndex: number;
155
- /**
156
- * Whether the query node is a raw value and should not be parsed by the interpreter
157
- */
158
- isRawValue: boolean;
159
- /**
160
- * Whether the keyword can be seen multiple times in the query, e.g. "join" can be seen multiple times in a query
161
- */
162
- abstract canKeywordBeSeenMultipleTimes: boolean;
163
- /**
164
- * The string to use to chain the keyword with the next keyword
165
- */
166
- abstract chainsWith: string;
167
- /**
168
- * The folder to use for the query node, e.g. "select" is in the "select" folder inside the interpreter map
169
- */
170
- abstract folder: string;
171
- /**
172
- * The file to use for the query node, e.g. "select" is in the "select" file inside the interpreter map
173
- */
174
- abstract file: string;
175
- constructor(keyword: string, isRawValue?: boolean);
176
- }
177
-
178
- declare class RawNode extends QueryNode {
179
- rawValue: string;
180
- canKeywordBeSeenMultipleTimes: boolean;
181
- chainsWith: string;
182
- currParamIndex: number;
183
- isRawValue: boolean;
184
- folder: string;
185
- file: string;
186
- constructor(value: string);
187
- }
188
-
189
- type BaseValues$2 = string | number | boolean | undefined | null | RawNode;
190
- type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike" | (string & {});
191
- declare class WhereNode extends QueryNode {
192
- column: string;
193
- isNegated: boolean;
194
- operator: BinaryOperatorType$2;
195
- value: BaseValues$2 | BaseValues$2[];
196
- chainsWith: "and" | "or";
197
- canKeywordBeSeenMultipleTimes: boolean;
198
- folder: string;
199
- file: string;
200
- constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType$2, value: BaseValues$2 | BaseValues$2[], isRawValue?: boolean);
201
- }
202
-
203
146
  /**
204
147
  * @description AdminJS plugin types - All AdminJS imports are done at runtime via dynamic import()
205
148
  * @description This ensures the plugin is completely optional
@@ -733,6 +676,49 @@ interface NotNullableSqliteDataSourceInput extends SqliteDataSourceInput {
733
676
  */
734
677
  type DataSourceInput = MssqlDataSourceInput | MysqlSqlDataSourceInput | SqliteDataSourceInput | PostgresSqlDataSourceInput | MongoDataSourceInput$1;
735
678
 
679
+ declare abstract class QueryNode {
680
+ /**
681
+ * Sql keyword to use for the query e.g. "select"
682
+ */
683
+ keyword: string;
684
+ /**
685
+ * The current parameter index to use for the query
686
+ */
687
+ currParamIndex: number;
688
+ /**
689
+ * Whether the query node is a raw value and should not be parsed by the interpreter
690
+ */
691
+ isRawValue: boolean;
692
+ /**
693
+ * Whether the keyword can be seen multiple times in the query, e.g. "join" can be seen multiple times in a query
694
+ */
695
+ abstract canKeywordBeSeenMultipleTimes: boolean;
696
+ /**
697
+ * The string to use to chain the keyword with the next keyword
698
+ */
699
+ abstract chainsWith: string;
700
+ /**
701
+ * The folder to use for the query node, e.g. "select" is in the "select" folder inside the interpreter map
702
+ */
703
+ abstract folder: string;
704
+ /**
705
+ * The file to use for the query node, e.g. "select" is in the "select" file inside the interpreter map
706
+ */
707
+ abstract file: string;
708
+ constructor(keyword: string, isRawValue?: boolean);
709
+ }
710
+
711
+ declare class RawNode extends QueryNode {
712
+ rawValue: string;
713
+ canKeywordBeSeenMultipleTimes: boolean;
714
+ chainsWith: string;
715
+ currParamIndex: number;
716
+ isRawValue: boolean;
717
+ folder: string;
718
+ file: string;
719
+ constructor(value: string);
720
+ }
721
+
736
722
  /**
737
723
  * Simplifies complex return types like SelectedModel to make it more readable and strips out whatever is passed as the second type parameter (e.g. SELECT_BRAND) to avoid showing it in the IDE autocomplete.
738
724
  */
@@ -740,9 +726,23 @@ type Simplify<T, Strip> = T extends infer U ? {
740
726
  [K in keyof U as K extends Strip ? never : K]: U[K];
741
727
  } : never;
742
728
 
743
- type BaseValues$1 = string | number | boolean | null;
744
- type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
729
+ type BaseValues$2 = string | number | boolean | null | SqlFuncNode;
730
+ type BinaryOperatorType$2 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "like" | "ilike" | "in";
745
731
  declare class HavingNode extends QueryNode {
732
+ column: string;
733
+ isNegated: boolean;
734
+ operator: BinaryOperatorType$2;
735
+ value: BaseValues$2 | BaseValues$2[];
736
+ chainsWith: "and" | "or";
737
+ canKeywordBeSeenMultipleTimes: boolean;
738
+ folder: string;
739
+ file: string;
740
+ constructor(column: string, chainsWith: "and" | "or", isNegated: boolean | undefined, operator: BinaryOperatorType$2, value: BaseValues$2 | BaseValues$2[], isRawValue?: boolean);
741
+ }
742
+
743
+ type BaseValues$1 = string | number | boolean | undefined | null | RawNode | SqlFuncNode;
744
+ type BinaryOperatorType$1 = "=" | "!=" | "<>" | ">" | "<" | ">=" | "<=" | "is" | "is not" | "like" | "not like" | "is null" | "is not null" | "ilike" | "in" | "not in" | "between" | "not between" | "regexp" | "not regexp" | "not ilike" | (string & {});
745
+ declare class WhereNode extends QueryNode {
746
746
  column: string;
747
747
  isNegated: boolean;
748
748
  operator: BinaryOperatorType$1;
@@ -856,25 +856,6 @@ declare class ColumnTypeNode extends QueryNode {
856
856
  });
857
857
  }
858
858
 
859
- /**
860
- * @description Expression node for the global `sqlFunc` token namespace.
861
- * @internal
862
- */
863
- declare class SqlFuncNode extends QueryNode {
864
- fn: string;
865
- args: (string | number | SqlFuncNode | RawNode)[];
866
- chainsWith: string;
867
- canKeywordBeSeenMultipleTimes: boolean;
868
- folder: string;
869
- file: string;
870
- constructor(fn: string, args?: (string | number | SqlFuncNode | RawNode)[]);
871
- }
872
- declare const sqlFunc: {
873
- uuid: () => SqlFuncNode;
874
- now: () => SqlFuncNode;
875
- currentTimestamp: () => SqlFuncNode;
876
- };
877
-
878
859
  declare class ConstraintBuilder extends BaseBuilder {
879
860
  private readonly columnNode;
880
861
  private readonly tableName?;
@@ -952,6 +933,12 @@ declare class ConstraintBuilder extends BaseBuilder {
952
933
  collate(collation: CommonMysqlCollations): this;
953
934
  collate(collation: string): this;
954
935
  private handleSqliteAutoIncrement;
936
+ /**
937
+ * @description Whether the sqlite column interpreter emits the primary key
938
+ * inline (see sqlite/column/column_type.ts), in which case a separate
939
+ * table-level constraint would be a second primary key.
940
+ */
941
+ private isInlineSqlitePrimaryKey;
955
942
  }
956
943
 
957
944
  declare class CreateTableBuilder extends BaseBuilder {
@@ -1799,6 +1786,7 @@ declare class InterpreterUtils {
1799
1786
  private readonly model;
1800
1787
  private readonly modelColumnsMap;
1801
1788
  private readonly jsInsertColumns;
1789
+ private readonly autoUpdateColumns;
1802
1790
  constructor(model: typeof Model);
1803
1791
  formatStringColumn(dbType: SqlDataSourceType, column: string): string;
1804
1792
  /**
@@ -3341,6 +3329,19 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3341
3329
  * @private
3342
3330
  */
3343
3331
  sqlConnection: GetConnectionReturnType<D> | null;
3332
+ /**
3333
+ * @description Connection reserved for an advisory lock. `pg_try_advisory_lock`
3334
+ * is session-scoped, so acquire and release must run on one backend; the pool
3335
+ * may otherwise serve them on different sessions and the lock leaks.
3336
+ * @private
3337
+ */
3338
+ private lockConnection;
3339
+ /**
3340
+ * @description Lock key -> numeric id, so releaseLock unlocks the id that
3341
+ * acquireLock actually locked.
3342
+ * @private
3343
+ */
3344
+ private lockKeyToId;
3344
3345
  /**
3345
3346
  * @description The resolved execution driver for this instance (npm driver
3346
3347
  * under node, native bun under bun unless overridden via `driver`/`jsEnvironment`)
@@ -3831,6 +3832,12 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
3831
3832
  * @returns true if lock was released, false otherwise
3832
3833
  */
3833
3834
  releaseLock(lockKey?: string): Promise<boolean>;
3835
+ /**
3836
+ * @description Returns the dedicated advisory-lock session, reserving it on
3837
+ * first use. Advisory locks are session-scoped, so all acquire/release calls
3838
+ * must share one backend.
3839
+ */
3840
+ private getLockConnection;
3834
3841
  /**
3835
3842
  * @description Converts a string to a numeric lock ID for databases that require it
3836
3843
  */
@@ -4304,60 +4311,60 @@ declare class JoinOnQueryBuilder {
4304
4311
  /**
4305
4312
  * @description Adds a WHERE condition to the query.
4306
4313
  */
4307
- where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4314
+ where(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4308
4315
  where(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4309
- where(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4316
+ where(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4310
4317
  /**
4311
4318
  * @description Adds an AND WHERE condition to the query.
4312
4319
  */
4313
- andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4314
- andWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4320
+ andWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4321
+ andWhere(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4315
4322
  andWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4316
4323
  /**
4317
4324
  * @description Adds an OR WHERE condition to the query.
4318
4325
  */
4319
- orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4320
- orWhere(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4326
+ orWhere(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4327
+ orWhere(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4321
4328
  orWhere(cb: (queryBuilder: JoinOnQueryBuilder) => void): this;
4322
4329
  /**
4323
4330
  * @description Adds a negated WHERE condition to the query.
4324
4331
  */
4325
- whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4326
- whereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4332
+ whereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4333
+ whereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4327
4334
  /**
4328
4335
  * @description Adds a negated AND WHERE condition to the query.
4329
4336
  */
4330
- andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4331
- andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4337
+ andWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4338
+ andWhereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4332
4339
  /**
4333
4340
  * @description Adds a negated OR WHERE condition to the query.
4334
4341
  */
4335
- orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$2, value: BaseValues$2): this;
4336
- orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$2): this;
4342
+ orWhereNot(column: SelectableColumn$1<string>, operator: BinaryOperatorType$1, value: BaseValues$1): this;
4343
+ orWhereNot(column: SelectableColumn$1<string>, value: BaseValues$1): this;
4337
4344
  /**
4338
4345
  * @description Adds a WHERE BETWEEN condition to the query.
4339
4346
  */
4340
- whereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4347
+ whereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4341
4348
  /**
4342
4349
  * @description Adds an AND WHERE BETWEEN condition to the query.
4343
4350
  */
4344
- andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4351
+ andWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4345
4352
  /**
4346
4353
  * @description Adds an OR WHERE BETWEEN condition to the query.
4347
4354
  */
4348
- orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4355
+ orWhereBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4349
4356
  /**
4350
4357
  * @description Adds a WHERE NOT BETWEEN condition to the query.
4351
4358
  */
4352
- whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4359
+ whereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4353
4360
  /**
4354
4361
  * @description Adds an AND WHERE NOT BETWEEN condition to the query.
4355
4362
  */
4356
- andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4363
+ andWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4357
4364
  /**
4358
4365
  * @description Adds an OR WHERE NOT BETWEEN condition to the query.
4359
4366
  */
4360
- orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$2, max: BaseValues$2): this;
4367
+ orWhereNotBetween(column: SelectableColumn$1<string>, min: BaseValues$1, max: BaseValues$1): this;
4361
4368
  /**
4362
4369
  * @description Adds a WHERE LIKE condition to the query.
4363
4370
  */
@@ -4409,27 +4416,27 @@ declare class JoinOnQueryBuilder {
4409
4416
  /**
4410
4417
  * @description Adds a WHERE IN condition to the query.
4411
4418
  */
4412
- whereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4419
+ whereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4413
4420
  /**
4414
4421
  * @description Adds an AND WHERE IN condition to the query.
4415
4422
  */
4416
- andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4423
+ andWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4417
4424
  /**
4418
4425
  * @description Adds an OR WHERE IN condition to the query.
4419
4426
  */
4420
- orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4427
+ orWhereIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4421
4428
  /**
4422
4429
  * @description Adds a WHERE NOT IN condition to the query.
4423
4430
  */
4424
- whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4431
+ whereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4425
4432
  /**
4426
4433
  * @description Adds an AND WHERE NOT IN condition to the query.
4427
4434
  */
4428
- andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4435
+ andWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4429
4436
  /**
4430
4437
  * @description Adds an OR WHERE NOT IN condition to the query.
4431
4438
  */
4432
- orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$2[]): this;
4439
+ orWhereNotIn(column: SelectableColumn$1<string>, values: BaseValues$1[]): this;
4433
4440
  /**
4434
4441
  * @description Adds a WHERE NULL condition to the query.
4435
4442
  */
@@ -4493,15 +4500,15 @@ declare class JoinOnQueryBuilder {
4493
4500
  /**
4494
4501
  * @description Adds a raw WHERE condition to the query.
4495
4502
  */
4496
- whereRaw(sql: string, bindings?: BaseValues$2[]): this;
4503
+ whereRaw(sql: string, bindings?: BaseValues$1[]): this;
4497
4504
  /**
4498
4505
  * @description Adds an AND raw WHERE condition to the query.
4499
4506
  */
4500
- andWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4507
+ andWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4501
4508
  /**
4502
4509
  * @description Adds an OR raw WHERE condition to the query.
4503
4510
  */
4504
- orWhereRaw(sql: string, bindings?: BaseValues$2[]): this;
4511
+ orWhereRaw(sql: string, bindings?: BaseValues$1[]): this;
4505
4512
  }
4506
4513
 
4507
4514
  /**
@@ -4546,13 +4553,13 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4546
4553
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
4547
4554
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4548
4555
  */
4549
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4550
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4551
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4552
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4553
- innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4556
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4557
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4558
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4559
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4560
+ innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4554
4561
  innerJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4555
- innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4562
+ innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4556
4563
  innerJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4557
4564
  /**
4558
4565
  * @description Join a table with the current model
@@ -4561,13 +4568,13 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4561
4568
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
4562
4569
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4563
4570
  */
4564
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4565
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4566
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4567
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4568
- join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4571
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4572
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4573
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4574
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4575
+ join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4569
4576
  join(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4570
- join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4577
+ join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4571
4578
  join<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4572
4579
  /**
4573
4580
  * @description Join a table with the current model
@@ -4576,13 +4583,13 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4576
4583
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using a Model, if using a Raw Query Builder you must provide the key for the primary table, must be in the format of `table.column`
4577
4584
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4578
4585
  */
4579
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4580
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4581
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4582
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$2): this;
4583
- leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4586
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4587
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4588
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4589
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn?: ModelKey<T>, operator?: BinaryOperatorType$1): this;
4590
+ leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4584
4591
  leftJoin(relationTable: string, referencingColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4585
- leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4592
+ leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4586
4593
  leftJoin<R extends AnyModelConstructor>(relationModel: R, referencingColumn: ModelKey<InstanceType<R>>, primaryColumn: ModelKey<T>, callback: JoinOnCallback): this;
4587
4594
  /**
4588
4595
  * @description Join a table with the current model
@@ -4591,10 +4598,10 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4591
4598
  * @param primaryColumn - The primary column of the current model, default is caller model primary key if using A Model, if using a Raw Query Builder you must provide the key for the primary table
4592
4599
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4593
4600
  */
4594
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4595
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4596
- rightJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$2): this;
4597
- rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4601
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4602
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4603
+ rightJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$1): this;
4604
+ rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4598
4605
  rightJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4599
4606
  /**
4600
4607
  * @description Perform a FULL OUTER JOIN with another table
@@ -4603,10 +4610,10 @@ declare abstract class JoinQueryBuilder<T extends Model, S extends Record<string
4603
4610
  * @param primaryColumn - The primary column of the current model
4604
4611
  * @param operator - The comparison operator to use in the ON clause (default: "=")
4605
4612
  */
4606
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$2): this;
4607
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$2): this;
4608
- fullJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$2): this;
4609
- fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$2, callback: JoinOnCallback): this;
4613
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator?: BinaryOperatorType$1): this;
4614
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn?: JoinableColumn, operator?: BinaryOperatorType$1): this;
4615
+ fullJoin<R extends AnyModelConstructor>(relationTable: string | R, referencingColumnOrPrimaryColumn: ModelKey<InstanceType<R>> | JoinableColumn | ModelKey<T>, primaryColumn?: JoinableColumn | ModelKey<T>, operator?: BinaryOperatorType$1): this;
4616
+ fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, operator: BinaryOperatorType$1, callback: JoinOnCallback): this;
4610
4617
  fullJoin(relationTable: string, referencingColumnOrPrimaryColumn: JoinableColumn, primaryColumn: JoinableColumn, callback: JoinOnCallback): this;
4611
4618
  }
4612
4619
 
@@ -4761,9 +4768,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4761
4768
  where(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4762
4769
  where(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4763
4770
  where(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4764
- where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4771
+ where<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
4765
4772
  where<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4766
- where<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4773
+ where<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
4767
4774
  where<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4768
4775
  /**
4769
4776
  * @description Adds an AND WHERE condition to the query.
@@ -4771,9 +4778,9 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4771
4778
  andWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4772
4779
  andWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4773
4780
  andWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4774
- andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4781
+ andWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
4775
4782
  andWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4776
- andWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4783
+ andWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
4777
4784
  andWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4778
4785
  /**
4779
4786
  * @description Adds an OR WHERE condition to the query.
@@ -4781,57 +4788,57 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
4781
4788
  orWhere(cb: (queryBuilder: WhereOnlyQueryBuilder<T>) => void): this;
4782
4789
  orWhere(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4783
4790
  orWhere(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4784
- orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4791
+ orWhere<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
4785
4792
  orWhere<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4786
- orWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4793
+ orWhere<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
4787
4794
  orWhere<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4788
4795
  /**
4789
4796
  * @description Adds a WHERE condition comparing two columns.
4790
4797
  */
4791
4798
  whereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4792
- whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4799
+ whereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, referenceColumn: ModelKey<T>): this;
4793
4800
  whereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4794
- whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4801
+ whereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
4795
4802
  /**
4796
4803
  * @description Adds an AND WHERE condition comparing two columns.
4797
4804
  */
4798
4805
  andWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4799
- andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4806
+ andWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, referenceColumn: ModelKey<T>): this;
4800
4807
  andWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4801
- andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4808
+ andWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
4802
4809
  /**
4803
4810
  * @description Adds an OR WHERE condition comparing two columns.
4804
4811
  */
4805
4812
  orWhereColumn<K extends ModelKey<T>>(column: K, referenceColumn: ModelKey<T>): this;
4806
- orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, referenceColumn: ModelKey<T>): this;
4813
+ orWhereColumn<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, referenceColumn: ModelKey<T>): this;
4807
4814
  orWhereColumn(column: `${string}.${string}`, referenceColumn: `${string}.${string}`): this;
4808
- orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$2, referenceColumn: `${string}.${string}`): this;
4815
+ orWhereColumn(column: `${string}.${string}`, operator: BinaryOperatorType$1, referenceColumn: `${string}.${string}`): this;
4809
4816
  /**
4810
4817
  * @description Adds a negated WHERE condition to the query.
4811
4818
  */
4812
4819
  whereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4813
4820
  whereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4814
- whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4821
+ whereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
4815
4822
  whereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4816
- whereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4823
+ whereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
4817
4824
  whereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4818
4825
  /**
4819
4826
  * @description Adds a negated AND WHERE condition to the query.
4820
4827
  */
4821
4828
  andWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4822
4829
  andWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4823
- andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4830
+ andWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
4824
4831
  andWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4825
- andWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4832
+ andWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
4826
4833
  andWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4827
4834
  /**
4828
4835
  * @description Adds a negated OR WHERE condition to the query.
4829
4836
  */
4830
4837
  orWhereNot(column: string, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4831
4838
  orWhereNot(column: string, operator: SubqueryOperatorType, subQuery: QueryBuilder<T> | ((subQuery: QueryBuilder<T>) => void | SubQueryable)): this;
4832
- orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
4839
+ orWhereNot<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
4833
4840
  orWhereNot<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
4834
- orWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
4841
+ orWhereNot<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
4835
4842
  orWhereNot<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
4836
4843
  /**
4837
4844
  * @description Adds a WHERE BETWEEN condition to the query.
@@ -5077,24 +5084,24 @@ declare abstract class WhereQueryBuilder<T extends Model, S extends Record<strin
5077
5084
  * @description Adds a HAVING condition to the query.
5078
5085
  */
5079
5086
  having<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5080
- having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5087
+ having<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5081
5088
  having<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
5082
- having<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
5089
+ having<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5083
5090
  /**
5084
5091
  * @description Adds an AND HAVING condition to the query.
5085
5092
  */
5086
5093
  andHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5087
- andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5094
+ andHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5088
5095
  andHaving<K extends `${string}.${string}`>(column: K, value: ResolveWhereValue<T, K>): this;
5089
- andHaving<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$2, value: ResolveWhereValue<T, K>): this;
5090
- andHaving(column: ModelKey<T>, operator: BinaryOperatorType$2, value: any): this;
5096
+ andHaving<K extends `${string}.${string}`>(column: K, operator: BinaryOperatorType$1, value: ResolveWhereValue<T, K>): this;
5097
+ andHaving(column: ModelKey<T>, operator: BinaryOperatorType$1, value: any): this;
5091
5098
  /**
5092
5099
  * @description Adds an OR HAVING condition to the query.
5093
5100
  */
5094
5101
  orHaving<K extends ModelKey<T>>(column: K, value: WhereColumnValue<T, K>): this;
5095
- orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$2, value: WhereColumnValue<T, K>): this;
5102
+ orHaving<K extends ModelKey<T>>(column: K, operator: BinaryOperatorType$1, value: WhereColumnValue<T, K>): this;
5096
5103
  orHaving(column: `${string}.${string}`, value: any): this;
5097
- orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$2, value: any): this;
5104
+ orHaving(column: `${string}.${string}`, operator: BinaryOperatorType$1, value: any): this;
5098
5105
  /**
5099
5106
  * @description Adds a raw HAVING condition to the query.
5100
5107
  */
@@ -5380,7 +5387,7 @@ type UpsertOptionsRawBuilder = {
5380
5387
  updateOnConflict?: boolean;
5381
5388
  returning?: readonly string[];
5382
5389
  };
5383
- type WriteQueryParam = string | number | boolean | Date | RawNode | object | null | undefined;
5390
+ type WriteQueryParam = string | number | boolean | Date | RawNode | SqlFuncNode | object | null | undefined;
5384
5391
  /**
5385
5392
  * Simple paginated data type for raw query builders (without Model constraint)
5386
5393
  */
@@ -5677,6 +5684,20 @@ type SqlDataSourceInputShape<D extends SqlDataSourceType, T extends Record<strin
5677
5684
  * @warning For usage with types, you must have driver types installed if the driver handles types in a type package like e.g. `@types/pg`
5678
5685
  */
5679
5686
  driverOptions?: SqlDriverSpecificOptions<D>;
5687
+ /**
5688
+ * @description Parse postgres/cockroachdb `int8` (oid 20) as a JS `bigint`
5689
+ * and `numeric` (oid 1700) as a JS `number`, instead of the driver default
5690
+ * of a decimal string for both.
5691
+ * @description Only honoured on the node `pg` driver; the Bun native SQL
5692
+ * path (`bun-sql`) ignores it.
5693
+ * @default false
5694
+ * @warning Breaking when enabled: any result path that bypasses a model
5695
+ * column's `serialize` — `sql.rawQuery(...)`, the raw `sql.from("table")`
5696
+ * builder, `selectRaw` aliases and generic `col<T>()` columns — now yields
5697
+ * `bigint`/`number` where it previously yielded strings. Consumers comparing
5698
+ * against strings must switch to a numeric comparison.
5699
+ */
5700
+ coerceNumericTypes?: boolean;
5680
5701
  /**
5681
5702
  * @description The replication configuration for the sql data source, it's used to configure the replication for the sql data source
5682
5703
  */
@@ -5719,6 +5740,20 @@ type UseConnectionInput<D extends SqlDataSourceType = SqlDataSourceType, T exten
5719
5740
  readonly logs?: boolean | LoggerConfig;
5720
5741
  readonly models?: T;
5721
5742
  readonly driverOptions?: SqlDriverSpecificOptions<D>;
5743
+ /**
5744
+ * @description Parse postgres/cockroachdb `int8` (oid 20) as a JS `bigint`
5745
+ * and `numeric` (oid 1700) as a JS `number`, instead of the driver default
5746
+ * of a decimal string for both.
5747
+ * @description Only honoured on the node `pg` driver; the Bun native SQL
5748
+ * path (`bun-sql`) ignores it.
5749
+ * @default false
5750
+ * @warning Breaking when enabled: any result path that bypasses a model
5751
+ * column's `serialize` — `sql.rawQuery(...)`, the raw `sql.from("table")`
5752
+ * builder, `selectRaw` aliases and generic `col<T>()` columns — now yields
5753
+ * `bigint`/`number` where it previously yielded strings. Consumers comparing
5754
+ * against strings must switch to a numeric comparison.
5755
+ */
5756
+ coerceNumericTypes?: boolean;
5722
5757
  connectionPolicies?: ConnectionPolicies;
5723
5758
  queryFormatOptions?: FormatOptionsWithLanguage;
5724
5759
  cacheStrategy?: {
@@ -5766,6 +5801,42 @@ type PingResult = {
5766
5801
  dialect: SqlDataSourceType;
5767
5802
  };
5768
5803
 
5804
+ /**
5805
+ * @description Expression node for the global `sqlFunc` token namespace.
5806
+ * @internal
5807
+ */
5808
+ declare class SqlFuncNode extends QueryNode {
5809
+ fn: string;
5810
+ args: (string | number | SqlFuncNode | RawNode)[];
5811
+ chainsWith: string;
5812
+ canKeywordBeSeenMultipleTimes: boolean;
5813
+ folder: string;
5814
+ file: string;
5815
+ constructor(fn: string, args?: (string | number | SqlFuncNode | RawNode)[]);
5816
+ }
5817
+ declare const sqlFunc: {
5818
+ uuid: () => SqlFuncNode;
5819
+ now: () => SqlFuncNode;
5820
+ currentTimestamp: () => SqlFuncNode;
5821
+ };
5822
+ /**
5823
+ * @description Renders a `SqlFuncNode` to dialect SQL. Return `undefined` to
5824
+ * fall back to the built-in tokens for the remaining function names.
5825
+ */
5826
+ type SqlFuncRenderer = (node: SqlFuncNode) => string | undefined;
5827
+ /**
5828
+ * @description Registers a custom renderer for a dialect, or for every dialect
5829
+ * via `"*"`. A dialect-specific renderer wins over the `"*"` entry, which wins
5830
+ * over the built-in tokens.
5831
+ * @example
5832
+ * ```ts
5833
+ * registerSqlFuncRenderer("postgres", (node) =>
5834
+ * node.fn === "$tenant" ? "current_setting('app.tenant')" : undefined,
5835
+ * );
5836
+ * ```
5837
+ */
5838
+ declare function registerSqlFuncRenderer(dialect: SqlDataSourceType | "*", renderer: SqlFuncRenderer): void;
5839
+
5769
5840
  type NullableAndUndefinable<T> = T | (T | null) | (T | undefined) | (T | null | undefined);
5770
5841
  type UpsertOptions<T extends Model> = {
5771
5842
  updateOnConflict?: boolean;
@@ -5902,13 +5973,13 @@ type MutationReturningResult<T extends Model, Ret extends readonly any[]> = [Ret
5902
5973
  * Extracts the value type for a model column key, adding `null` for SQL compatibility.
5903
5974
  * Strips any table prefix before indexing into the model type.
5904
5975
  */
5905
- type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] | null;
5976
+ type WhereColumnValue<T extends Model, K extends ModelKey<T>> = T[StripTablePrefix<K & string> & keyof T] | null | SqlFuncNode;
5906
5977
  /**
5907
5978
  * Resolves the value type for a column in where clauses.
5908
5979
  * For model columns (ModelKey<T>), returns the specific column type.
5909
5980
  * For arbitrary columns (joins, aliases), falls back to BaseValues.
5910
5981
  */
5911
- type ResolveWhereValue<T extends Model, K extends string> = K extends ModelKey<T> ? T[StripTablePrefix<K> & keyof T] | null : BaseValues$2;
5982
+ type ResolveWhereValue<T extends Model, K extends string> = K extends ModelKey<T> ? T[StripTablePrefix<K> & keyof T] | null | SqlFuncNode : BaseValues$1;
5912
5983
  type ModelRelation<T extends Model> = OnlyRelations<T>;
5913
5984
  type OrderByChoices = "asc" | "desc";
5914
5985
  type OrderByType<T extends Model> = {
@@ -6866,37 +6937,37 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6866
6937
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
6867
6938
  */
6868
6939
  havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6869
- havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
6940
+ havingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
6870
6941
  /**
6871
6942
  * @description Checks if the relation exists in the models and has the given filters, if no callback is provided, it only check if there is at least one record for the relation
6872
6943
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
6873
6944
  */
6874
6945
  andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6875
- andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
6946
+ andHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
6876
6947
  /**
6877
6948
  * @description Checks if the relation exists in the models and has the given filters, if no callback is provided, it only check if there is at least one record for the relation,
6878
6949
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
6879
6950
  */
6880
6951
  orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6881
- orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
6952
+ orHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
6882
6953
  /**
6883
6954
  * @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the Relation
6884
6955
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
6885
6956
  */
6886
6957
  notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6887
- notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
6958
+ notHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
6888
6959
  /**
6889
6960
  * @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the relation
6890
6961
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
6891
6962
  */
6892
6963
  andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6893
- andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
6964
+ andNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
6894
6965
  /**
6895
6966
  * @description Checks if the relation does not exist in the models and has the given filters, if no callback is provided, it only check if there is no record for the Relation
6896
6967
  * @warning All select statements are ignored, since we're only checking if the relation exists, a "select 1" will be added to the Query
6897
6968
  */
6898
6969
  orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, cb?: (queryBuilder: ModelQueryBuilder<RelatedInstance<T, RelationKey>>) => void): this;
6899
- orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$2 | BaseValues$2, maybeValue?: BaseValues$2): this;
6970
+ orNotHavingRelated<RelationKey extends ModelRelation<T>>(relation: RelationKey, operatorOrValue?: BinaryOperatorType$1 | BaseValues$1, maybeValue?: BaseValues$1): this;
6900
6971
  /**
6901
6972
  * @description Returns a copy of the query builder instance.
6902
6973
  */
@@ -6948,7 +7019,7 @@ declare class ModelQueryBuilder<T extends Model, S extends Record<string, any> =
6948
7019
  protected getRelatedModelsForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): Promise<SelectedModel<T, ModelWithoutRelations<T>, R>[]>;
6949
7020
  protected getRelatedModelsQueryForRelation(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, models: T[]): ModelQueryBuilder<any, any, any>;
6950
7021
  protected getFilterValuesFromModelsForRelation(relation: Relation, models: T[]): any[];
6951
- protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$2, value?: BaseValues$2): void;
7022
+ protected applyHavingRelatedFilter(relationQueryBuilder: ModelQueryBuilder<any>, relation: Relation, operator?: BinaryOperatorType$1, value?: BaseValues$1): void;
6952
7023
  }
6953
7024
 
6954
7025
  /**
@@ -8795,4 +8866,4 @@ type BetterAuthAdapterConfig = Partial<Pick<AdapterFactoryConfig, "usePlural" |
8795
8866
  */
8796
8867
  declare function betterAuthAdapter(sql: SqlDataSource, config?: BetterAuthAdapterConfig): (options: BetterAuthOptions) => DBAdapter;
8797
8868
 
8798
- export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AllowedDrivers, type AnyModelConstructor, type AnySqlDataSourceInput, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BeginTransactionOptions, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type BuiltinDriverName, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type DriverAdapter, type DriverAdapterFactory, type DriverAdapterFactoryContext, type EndTransactionOptions, type ExcludeMethods, type ExecuteOptions, type ExtractColumnName, type ExtractSourceColumn, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsEnvironmentValue, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelStream, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type Operation, type PgPoolClientInstance, type PingResult, type PlatformAdapter, type PlatformFs, type PlatformPath, PlatformUnsupportedError, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ResolvedJsEnvironment, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, SqlFuncNode, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, loadPlatform, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, registerDriverAdapter, required, sqlFunc, url };
8869
+ export { type AdminJsActionOptions, type AdminJsAssets, type AdminJsBranding, type AdminJsInstance, type AdminJsLocale, type AdminJsOptions, type AdminJsPage, type AdminJsPropertyOptions, type AdminJsResourceOptions, type AdminJsSettings, type AllowedDrivers, type AnyModelConstructor, type AnySqlDataSourceInput, type AtomicOptions, type BaseModelMethodOptions, BaseSeeder, type BeginTransactionOptions, type BetterAuthAdapterConfig, type BuildSelectType, type BuildSingleSelectType, type BuiltinDriverName, type CacheAdapter, type CacheKeys, ClientMigrator, type ColCharOptions, type ColComputedOptions, type ColJsonbOptions, type ColMediumIntOptions, type ColSmallIntOptions, type ColTinyIntOptions, type ColVarbinaryOptions, Collection, type CollectionDefinition, type ColumnDef, type CommonDataSourceInput, type ComposeBuildSelect, type ComposeSelect, type ComputedColumnDef, type ConnectionPolicies, type CreateSchemaResult, type CustomLogger, type DataSourceInput, type DataSourceType, type DateAutoHook, type DefinedCollection, type DefinedModel, type DefinedView, type DriverAdapter, type DriverAdapterFactory, type DriverAdapterFactoryContext, type EndTransactionOptions, type ExcludeMethods, type ExecuteOptions, type ExtractColumnName, type ExtractSourceColumn, type FindReturnType, type GetColumnType, type GetConnectionReturnType, HysteriaError, type HysteriaErrorCode, InMemoryAdapter, type InferPK, type IntrospectedColumn, type IntrospectedForeignKey, type IntrospectedSchema, type IntrospectedTable, type JsEnvironmentValue, type JsonPathInput, type JsonPaths, type LoadOptions, type LoggerConfig, Migration, type MigrationConfig, type MigrationConfigBase, type MigrationLockConfig, type ModelColumns, type ModelDataProperties, type ModelInstanceType, type ModelKey, ModelQueryBuilder, type ModelQueryResult, type ModelRelation, type ModelSelectTuple, type ModelSelectableInput, type ModelStream, type ModelWithoutRelations, type ModelsProxy, MongoDataSource, type MongoDataSourceInput$1 as MongoDataSourceInput, type MssqlConnectionInstance, type MssqlDataSourceInput, type MssqlPoolInstance, type MutationReturningResult, type MysqlConnectionInstance, type MysqlSqlDataSourceInput, type NotNullableMysqlSqlDataSourceInput, type NotNullableOracleMssqlDataSourceInput, type NotNullablePostgresSqlDataSourceInput, type NotNullableSqliteDataSourceInput, type NullableColumn, type NumberModelKey, ObserverChain, ObserverChainWrapper, type Operation, type PgPoolClientInstance, type PingResult, type PlatformAdapter, type PlatformFs, type PlatformPath, PlatformUnsupportedError, type PostgresSqlDataSourceInput, type PrimaryColumnDef, type PropNamespace, type PropertyDef, QueryBuilder, type QueryContext, type QueryContextWithDuration, type QueryObserver, type RawModelKey, type RawModelOptions, RawNode, type RawQueryOptions, RedisCacheAdapter, type RedisFetchable, type RedisStorable, type RelatedInstance, type RelationDef, type RelationDefinitions, type RelationHelpers, type RelationLoadStrategy, type RelationQueryBuilderType, type ReplicationType, type ResolveColumnType, type ResolveJsonPathType, type ResolvedJsEnvironment, type ReturningColumns, type ReturningKey, type ReturningParam, type ReturningResult, type ReturningResultMany, type ReturningSupported, Schema, SchemaBuilder, type SchemaLookup, type SchemaRelDef, type SeederConfig, type SelectBrand, type SelectableColumn, type SelectedModel, type SlaveAlgorithm, type SlaveContext, type SqlCloneOptions, SqlDataSource, type SqlDataSourceInput, type SqlDataSourceModel, type SqlDataSourceType, type SqlDriverSpecificOptions, SqlFuncNode, type SqlFuncRenderer, type SqlPoolType, type Sqlite3ConnectionOptions, type SqliteConnectionInstance, type SqliteDataSourceInput, type StartTransactionOptions, type StripTablePrefix, type SubQueryable, type TableFormat, Transaction, type TransactionExecutionOptions, type TypedDefault, type TypedJsonPathInput, type TypedPrepare, type TypedSerialize, type UseCacheReturnType, type UseConnectionInput, type ValidationContext, ValidationError, type ValidationResult, type Validator, type ViewDefinition, WriteOperation, type WriteReturnType, atomic, betterAuthAdapter, col, createSchema, defineCollection, defineMigrator, defineModel, defineModelFactory, defineRelations, defineView, deriveOperationFromQuery, email, enumValidator, generateOpenApiModel, generateOpenApiModelSchema, generateOpenApiModelWithMetadata, type getPoolReturnType, loadPlatform, HysteriaLogger as logger, max, maxLength, min, minLength, pattern, prop, RedisDataSource as redis, registerDriverAdapter, registerSqlFuncRenderer, required, sqlFunc, url };