hysteria-orm 10.9.0 → 10.9.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
@@ -988,6 +988,8 @@ declare class ColumnTypeNode extends QueryNode {
988
988
  autoCreate?: boolean;
989
989
  autoUpdate?: boolean;
990
990
  collate?: string;
991
+ unsigned?: boolean;
992
+ zerofill?: boolean;
991
993
  chainsWith: string;
992
994
  canKeywordBeSeenMultipleTimes: boolean;
993
995
  folder: string;
@@ -1004,6 +1006,8 @@ declare class ColumnTypeNode extends QueryNode {
1004
1006
  autoUpdate?: boolean;
1005
1007
  collate?: string;
1006
1008
  isRawValue?: boolean;
1009
+ unsigned?: boolean;
1010
+ zerofill?: boolean;
1007
1011
  });
1008
1012
  }
1009
1013
 
@@ -1029,6 +1033,19 @@ declare class ConstraintBuilder extends BaseBuilder {
1029
1033
  * @description Sets the column to auto increment
1030
1034
  */
1031
1035
  increment(): this;
1036
+ /**
1037
+ * @description Sets the column to UNSIGNED (MySQL/MariaDB only)
1038
+ * Restricts the column to non-negative values.
1039
+ * @mysql Only supported by MySQL/MariaDB. Other databases silently ignore this.
1040
+ */
1041
+ unsigned(): this;
1042
+ /**
1043
+ * @description Sets the column to ZEROFILL (MySQL/MariaDB only)
1044
+ * Pads the column value with zeros up to the display width.
1045
+ * Note: ZEROFILL implicitly makes the column UNSIGNED.
1046
+ * @mysql Only supported by MySQL/MariaDB. Other databases silently ignore this.
1047
+ */
1048
+ zerofill(): this;
1032
1049
  /**
1033
1050
  * @description Sets the column to not nullable
1034
1051
  */
@@ -1835,18 +1852,19 @@ declare class InterpreterUtils {
1835
1852
  * @example
1836
1853
  * ```ts
1837
1854
  * // Get SQL without executing
1838
- * const sql = sql.query("users").insert({ name: "John" }).toQuery();
1855
+ * const sql = sql.from("users").insert({ name: "John" }).toQuery();
1839
1856
  *
1840
1857
  * // Execute the operation
1841
- * const result = await sql.query("users").insert({ name: "John" });
1858
+ * const result = await sql.from("users").insert({ name: "John" });
1842
1859
  * ```
1843
1860
  */
1844
1861
  declare class WriteOperation<T> implements PromiseLike<T> {
1845
1862
  private unWrapFn;
1863
+ private toSqlFn;
1846
1864
  private toQueryFn;
1847
1865
  private executor;
1848
1866
  readonly [Symbol.toStringTag] = "WriteOperation";
1849
- constructor(unWrapFn: () => ReturnType<typeof AstParser.prototype.parse>, toQueryFn: () => string, executor: () => Promise<T>);
1867
+ constructor(unWrapFn: () => ReturnType<typeof AstParser.prototype.parse>, toSqlFn: () => ReturnType<typeof AstParser.prototype.parse>, toQueryFn: () => string, executor: () => Promise<T>);
1850
1868
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
1851
1869
  catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
1852
1870
  finally(onfinally?: (() => void) | null | undefined): Promise<T>;
@@ -1856,7 +1874,13 @@ declare class WriteOperation<T> implements PromiseLike<T> {
1856
1874
  */
1857
1875
  toQuery(): string;
1858
1876
  /**
1859
- * @description Returns the query with database driver placeholders and the params
1877
+ * @description Returns the formatted query with database driver placeholders and the params
1878
+ * @description Use this for debugging purposes to see the formatted SQL
1879
+ * @warning Does not apply any hook from the model
1880
+ */
1881
+ toSql(): ReturnType<typeof AstParser.prototype.parse>;
1882
+ /**
1883
+ * @description Returns the raw query with database driver placeholders and the params
1860
1884
  * @warning Does not apply any hook from the model
1861
1885
  */
1862
1886
  unWrap(): ReturnType<typeof AstParser.prototype.parse>;
@@ -2854,6 +2878,8 @@ type ColumnType = {
2854
2878
  precision?: number;
2855
2879
  scale?: number;
2856
2880
  withTimezone?: boolean;
2881
+ unsigned?: boolean;
2882
+ zerofill?: boolean;
2857
2883
  constraints?: {
2858
2884
  nullable?: boolean;
2859
2885
  default?: string | number | null | boolean;
@@ -3898,10 +3924,10 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3898
3924
  * @description Supports: "column", "table.column", "*", "table.*", or [column, alias] tuples
3899
3925
  * @example
3900
3926
  * ```ts
3901
- * const user = await sql.query("users").select("name", "age").one();
3927
+ * const user = await sql.from("users").select("name", "age").one();
3902
3928
  * // user type: { name: any, age: any } | null
3903
3929
  *
3904
- * const user = await sql.query("users").select(["name", "userName"]).one();
3930
+ * const user = await sql.from("users").select(["name", "userName"]).one();
3905
3931
  * // user type: { userName: any } | null
3906
3932
  * ```
3907
3933
  */
@@ -3914,7 +3940,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3914
3940
  * @description Use the generic parameter to specify the type of the selected columns.
3915
3941
  * @example
3916
3942
  * ```ts
3917
- * const result = await sql.query("users")
3943
+ * const result = await sql.from("users")
3918
3944
  * .selectRaw<{ total: number }>("count(*) as total")
3919
3945
  * .one();
3920
3946
  * // result type: { total: number } | null
@@ -3934,7 +3960,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3934
3960
  * @param alias The alias for the result
3935
3961
  * @example
3936
3962
  * ```ts
3937
- * const result = await sql.query("users")
3963
+ * const result = await sql.from("users")
3938
3964
  * .selectFunc("count", "*", "total")
3939
3965
  * .one();
3940
3966
  * // result type: { total: number } | null - auto-inferred!
@@ -4011,7 +4037,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4011
4037
  * @example
4012
4038
  * const chunkSize = 3;
4013
4039
  * const chunks = [];
4014
- * const query = sql.query("users").orderBy("name", "asc");
4040
+ * const query = sql.from("users").orderBy("name", "asc");
4015
4041
  * for await (const chunk of sql.chunk(chunkSize)) {
4016
4042
  * chunks.push(chunk);
4017
4043
  * }
@@ -4121,7 +4147,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4121
4147
  /**
4122
4148
  * @description Adds a materialized CTE to the query using a callback to build the subquery.
4123
4149
  * @postgres only
4124
- * @throws HysteriaError if the database type is not postgres
4150
+ * @throws HysteriaError if the database type is not postgres or cockroachdb
4125
4151
  */
4126
4152
  withMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
4127
4153
  /**
@@ -4197,7 +4223,14 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4197
4223
  */
4198
4224
  toQuery(): string;
4199
4225
  /**
4200
- * @description Returns the query with database driver placeholders and the params
4226
+ * @description Returns the formatted query with database driver placeholders and the params
4227
+ * @description Use this for debugging purposes to see the formatted SQL
4228
+ * @warning Does not apply any hook from the model
4229
+ * @warning Does not show any `load` operations in the query, it only shows the operations that directly belong to the query builder instance
4230
+ */
4231
+ toSql(): ReturnType<typeof AstParser.prototype.parse>;
4232
+ /**
4233
+ * @description Returns the raw query with database driver placeholders and the params
4201
4234
  * @description To be used for executing the query with the database driver
4202
4235
  * @warning Does not apply any hook from the model
4203
4236
  * @warning Does not show any `load` operations in the query, it only shows the operations that directly belong to the query builder instance
@@ -4284,6 +4317,8 @@ type TableColumnInfo = {
4284
4317
  scale?: number | null;
4285
4318
  withTimezone?: boolean | null;
4286
4319
  enumValues?: string[] | null;
4320
+ unsigned?: boolean | null;
4321
+ zerofill?: boolean | null;
4287
4322
  };
4288
4323
  type TableIndexInfo = {
4289
4324
  name: string;
@@ -4352,8 +4387,11 @@ declare class Transaction {
4352
4387
  * const modelManager = trx.sql.getModelManager(User);
4353
4388
  * await modelManager.insert({ name: "John Doe" });
4354
4389
  *
4355
- * // Query builder
4356
- * await trx.query(User.table).insert({ name: "John Doe" });
4390
+ * // Query builder with model
4391
+ * await trx.sql.from(User).insert({ name: "John Doe" });
4392
+ *
4393
+ * // Query builder with table name
4394
+ * await trx.sql.from("users").insert({ name: "John Doe" });
4357
4395
  *
4358
4396
  * await trx.commit();
4359
4397
  * ```
@@ -4429,7 +4467,7 @@ declare const SQL_DATA_SOURCE_SYMBOL: unique symbol;
4429
4467
  * await sql.connect();
4430
4468
  *
4431
4469
  * // Now you can use the connection
4432
- * const users = await sql.query("users").many();
4470
+ * const users = await sql.from("users").many();
4433
4471
  * ```
4434
4472
  */
4435
4473
  declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> extends DataSource {
@@ -4613,17 +4651,29 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4613
4651
  * @description Returns the type of the database
4614
4652
  */
4615
4653
  getDbType(): D;
4616
- /**
4617
- * @description Returns a QueryBuilder instance for raw queries
4618
- * @description Query builder from the SqlDataSource instance returns raw data from the database
4619
- * @param table The table name to query from
4620
- */
4621
- query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
4622
4654
  /**
4623
4655
  * @description Returns a ModelQueryBuilder instance for the given model
4624
- * @param Model The model to create the query builder from
4656
+ * @description Model-based queries provide type safety, hooks, relations, and serialization
4657
+ * @param model The model class to create the query builder from
4658
+ * @example
4659
+ * ```ts
4660
+ * const users = await sql.from(User).select("name").many();
4661
+ * // users is typed as User[]
4662
+ * ```
4625
4663
  */
4626
4664
  from<M extends AnyModelConstructor>(model: M): ModelQueryBuilder<InstanceType<SchemaLookup<T, M>>, ModelWithoutRelations<InstanceType<SchemaLookup<T, M>>>, {}, D>;
4665
+ /**
4666
+ * @description Returns a QueryBuilder instance for raw table queries
4667
+ * @description Raw table queries return untyped data - use models for type safety
4668
+ * @param table The table name to query from
4669
+ * @param options Optional configuration for case convention and alias
4670
+ * @example
4671
+ * ```ts
4672
+ * const rows = await sql.from("users").select("name").many();
4673
+ * // rows is typed as Record<string, any>[]
4674
+ * ```
4675
+ */
4676
+ from<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
4627
4677
  /**
4628
4678
  * @description Returns a SchemaBuilder instance for DDL operations
4629
4679
  * @description The builder will execute queries when awaited or when .execute() is called
@@ -6292,12 +6342,23 @@ type ColStringOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "
6292
6342
  length?: number;
6293
6343
  };
6294
6344
  type ColTextOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6295
- type ColIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default">;
6296
- type ColBigIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default">;
6297
- type ColFloatOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default">;
6345
+ type ColIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6346
+ unsigned?: boolean;
6347
+ zerofill?: boolean;
6348
+ };
6349
+ type ColBigIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6350
+ unsigned?: boolean;
6351
+ zerofill?: boolean;
6352
+ };
6353
+ type ColFloatOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6354
+ unsigned?: boolean;
6355
+ zerofill?: boolean;
6356
+ };
6298
6357
  type ColDecimalOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6299
6358
  precision?: number;
6300
6359
  scale?: number;
6360
+ unsigned?: boolean;
6361
+ zerofill?: boolean;
6301
6362
  };
6302
6363
  type ColIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
6303
6364
  type ColBigIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
@@ -6320,9 +6381,18 @@ type ColCharOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "de
6320
6381
  type ColVarbinaryOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6321
6382
  length?: number;
6322
6383
  };
6323
- type ColTinyIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6324
- type ColSmallIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6325
- type ColMediumIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6384
+ type ColTinyIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6385
+ unsigned?: boolean;
6386
+ zerofill?: boolean;
6387
+ };
6388
+ type ColSmallIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6389
+ unsigned?: boolean;
6390
+ zerofill?: boolean;
6391
+ };
6392
+ type ColMediumIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6393
+ unsigned?: boolean;
6394
+ zerofill?: boolean;
6395
+ };
6326
6396
  type RelationConstraintOptions = {
6327
6397
  /**
6328
6398
  * Useful for auto generated migrations to specify the on delete action, it does not affect the code wise implementation
package/lib/index.d.ts CHANGED
@@ -988,6 +988,8 @@ declare class ColumnTypeNode extends QueryNode {
988
988
  autoCreate?: boolean;
989
989
  autoUpdate?: boolean;
990
990
  collate?: string;
991
+ unsigned?: boolean;
992
+ zerofill?: boolean;
991
993
  chainsWith: string;
992
994
  canKeywordBeSeenMultipleTimes: boolean;
993
995
  folder: string;
@@ -1004,6 +1006,8 @@ declare class ColumnTypeNode extends QueryNode {
1004
1006
  autoUpdate?: boolean;
1005
1007
  collate?: string;
1006
1008
  isRawValue?: boolean;
1009
+ unsigned?: boolean;
1010
+ zerofill?: boolean;
1007
1011
  });
1008
1012
  }
1009
1013
 
@@ -1029,6 +1033,19 @@ declare class ConstraintBuilder extends BaseBuilder {
1029
1033
  * @description Sets the column to auto increment
1030
1034
  */
1031
1035
  increment(): this;
1036
+ /**
1037
+ * @description Sets the column to UNSIGNED (MySQL/MariaDB only)
1038
+ * Restricts the column to non-negative values.
1039
+ * @mysql Only supported by MySQL/MariaDB. Other databases silently ignore this.
1040
+ */
1041
+ unsigned(): this;
1042
+ /**
1043
+ * @description Sets the column to ZEROFILL (MySQL/MariaDB only)
1044
+ * Pads the column value with zeros up to the display width.
1045
+ * Note: ZEROFILL implicitly makes the column UNSIGNED.
1046
+ * @mysql Only supported by MySQL/MariaDB. Other databases silently ignore this.
1047
+ */
1048
+ zerofill(): this;
1032
1049
  /**
1033
1050
  * @description Sets the column to not nullable
1034
1051
  */
@@ -1835,18 +1852,19 @@ declare class InterpreterUtils {
1835
1852
  * @example
1836
1853
  * ```ts
1837
1854
  * // Get SQL without executing
1838
- * const sql = sql.query("users").insert({ name: "John" }).toQuery();
1855
+ * const sql = sql.from("users").insert({ name: "John" }).toQuery();
1839
1856
  *
1840
1857
  * // Execute the operation
1841
- * const result = await sql.query("users").insert({ name: "John" });
1858
+ * const result = await sql.from("users").insert({ name: "John" });
1842
1859
  * ```
1843
1860
  */
1844
1861
  declare class WriteOperation<T> implements PromiseLike<T> {
1845
1862
  private unWrapFn;
1863
+ private toSqlFn;
1846
1864
  private toQueryFn;
1847
1865
  private executor;
1848
1866
  readonly [Symbol.toStringTag] = "WriteOperation";
1849
- constructor(unWrapFn: () => ReturnType<typeof AstParser.prototype.parse>, toQueryFn: () => string, executor: () => Promise<T>);
1867
+ constructor(unWrapFn: () => ReturnType<typeof AstParser.prototype.parse>, toSqlFn: () => ReturnType<typeof AstParser.prototype.parse>, toQueryFn: () => string, executor: () => Promise<T>);
1850
1868
  then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): Promise<TResult1 | TResult2>;
1851
1869
  catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): Promise<T | TResult>;
1852
1870
  finally(onfinally?: (() => void) | null | undefined): Promise<T>;
@@ -1856,7 +1874,13 @@ declare class WriteOperation<T> implements PromiseLike<T> {
1856
1874
  */
1857
1875
  toQuery(): string;
1858
1876
  /**
1859
- * @description Returns the query with database driver placeholders and the params
1877
+ * @description Returns the formatted query with database driver placeholders and the params
1878
+ * @description Use this for debugging purposes to see the formatted SQL
1879
+ * @warning Does not apply any hook from the model
1880
+ */
1881
+ toSql(): ReturnType<typeof AstParser.prototype.parse>;
1882
+ /**
1883
+ * @description Returns the raw query with database driver placeholders and the params
1860
1884
  * @warning Does not apply any hook from the model
1861
1885
  */
1862
1886
  unWrap(): ReturnType<typeof AstParser.prototype.parse>;
@@ -2854,6 +2878,8 @@ type ColumnType = {
2854
2878
  precision?: number;
2855
2879
  scale?: number;
2856
2880
  withTimezone?: boolean;
2881
+ unsigned?: boolean;
2882
+ zerofill?: boolean;
2857
2883
  constraints?: {
2858
2884
  nullable?: boolean;
2859
2885
  default?: string | number | null | boolean;
@@ -3898,10 +3924,10 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3898
3924
  * @description Supports: "column", "table.column", "*", "table.*", or [column, alias] tuples
3899
3925
  * @example
3900
3926
  * ```ts
3901
- * const user = await sql.query("users").select("name", "age").one();
3927
+ * const user = await sql.from("users").select("name", "age").one();
3902
3928
  * // user type: { name: any, age: any } | null
3903
3929
  *
3904
- * const user = await sql.query("users").select(["name", "userName"]).one();
3930
+ * const user = await sql.from("users").select(["name", "userName"]).one();
3905
3931
  * // user type: { userName: any } | null
3906
3932
  * ```
3907
3933
  */
@@ -3914,7 +3940,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3914
3940
  * @description Use the generic parameter to specify the type of the selected columns.
3915
3941
  * @example
3916
3942
  * ```ts
3917
- * const result = await sql.query("users")
3943
+ * const result = await sql.from("users")
3918
3944
  * .selectRaw<{ total: number }>("count(*) as total")
3919
3945
  * .one();
3920
3946
  * // result type: { total: number } | null
@@ -3934,7 +3960,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
3934
3960
  * @param alias The alias for the result
3935
3961
  * @example
3936
3962
  * ```ts
3937
- * const result = await sql.query("users")
3963
+ * const result = await sql.from("users")
3938
3964
  * .selectFunc("count", "*", "total")
3939
3965
  * .one();
3940
3966
  * // result type: { total: number } | null - auto-inferred!
@@ -4011,7 +4037,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4011
4037
  * @example
4012
4038
  * const chunkSize = 3;
4013
4039
  * const chunks = [];
4014
- * const query = sql.query("users").orderBy("name", "asc");
4040
+ * const query = sql.from("users").orderBy("name", "asc");
4015
4041
  * for await (const chunk of sql.chunk(chunkSize)) {
4016
4042
  * chunks.push(chunk);
4017
4043
  * }
@@ -4121,7 +4147,7 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4121
4147
  /**
4122
4148
  * @description Adds a materialized CTE to the query using a callback to build the subquery.
4123
4149
  * @postgres only
4124
- * @throws HysteriaError if the database type is not postgres
4150
+ * @throws HysteriaError if the database type is not postgres or cockroachdb
4125
4151
  */
4126
4152
  withMaterialized(alias: string, cb: (qb: QueryBuilder<T>) => void | SubQueryable): this;
4127
4153
  /**
@@ -4197,7 +4223,14 @@ declare class QueryBuilder<T extends Model = any, S extends Record<string, any>
4197
4223
  */
4198
4224
  toQuery(): string;
4199
4225
  /**
4200
- * @description Returns the query with database driver placeholders and the params
4226
+ * @description Returns the formatted query with database driver placeholders and the params
4227
+ * @description Use this for debugging purposes to see the formatted SQL
4228
+ * @warning Does not apply any hook from the model
4229
+ * @warning Does not show any `load` operations in the query, it only shows the operations that directly belong to the query builder instance
4230
+ */
4231
+ toSql(): ReturnType<typeof AstParser.prototype.parse>;
4232
+ /**
4233
+ * @description Returns the raw query with database driver placeholders and the params
4201
4234
  * @description To be used for executing the query with the database driver
4202
4235
  * @warning Does not apply any hook from the model
4203
4236
  * @warning Does not show any `load` operations in the query, it only shows the operations that directly belong to the query builder instance
@@ -4284,6 +4317,8 @@ type TableColumnInfo = {
4284
4317
  scale?: number | null;
4285
4318
  withTimezone?: boolean | null;
4286
4319
  enumValues?: string[] | null;
4320
+ unsigned?: boolean | null;
4321
+ zerofill?: boolean | null;
4287
4322
  };
4288
4323
  type TableIndexInfo = {
4289
4324
  name: string;
@@ -4352,8 +4387,11 @@ declare class Transaction {
4352
4387
  * const modelManager = trx.sql.getModelManager(User);
4353
4388
  * await modelManager.insert({ name: "John Doe" });
4354
4389
  *
4355
- * // Query builder
4356
- * await trx.query(User.table).insert({ name: "John Doe" });
4390
+ * // Query builder with model
4391
+ * await trx.sql.from(User).insert({ name: "John Doe" });
4392
+ *
4393
+ * // Query builder with table name
4394
+ * await trx.sql.from("users").insert({ name: "John Doe" });
4357
4395
  *
4358
4396
  * await trx.commit();
4359
4397
  * ```
@@ -4429,7 +4467,7 @@ declare const SQL_DATA_SOURCE_SYMBOL: unique symbol;
4429
4467
  * await sql.connect();
4430
4468
  *
4431
4469
  * // Now you can use the connection
4432
- * const users = await sql.query("users").many();
4470
+ * const users = await sql.from("users").many();
4433
4471
  * ```
4434
4472
  */
4435
4473
  declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T extends Record<string, SqlDataSourceModel> = {}, C extends CacheKeys = {}> extends DataSource {
@@ -4613,17 +4651,29 @@ declare class SqlDataSource<D extends SqlDataSourceType = SqlDataSourceType, T e
4613
4651
  * @description Returns the type of the database
4614
4652
  */
4615
4653
  getDbType(): D;
4616
- /**
4617
- * @description Returns a QueryBuilder instance for raw queries
4618
- * @description Query builder from the SqlDataSource instance returns raw data from the database
4619
- * @param table The table name to query from
4620
- */
4621
- query<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
4622
4654
  /**
4623
4655
  * @description Returns a ModelQueryBuilder instance for the given model
4624
- * @param Model The model to create the query builder from
4656
+ * @description Model-based queries provide type safety, hooks, relations, and serialization
4657
+ * @param model The model class to create the query builder from
4658
+ * @example
4659
+ * ```ts
4660
+ * const users = await sql.from(User).select("name").many();
4661
+ * // users is typed as User[]
4662
+ * ```
4625
4663
  */
4626
4664
  from<M extends AnyModelConstructor>(model: M): ModelQueryBuilder<InstanceType<SchemaLookup<T, M>>, ModelWithoutRelations<InstanceType<SchemaLookup<T, M>>>, {}, D>;
4665
+ /**
4666
+ * @description Returns a QueryBuilder instance for raw table queries
4667
+ * @description Raw table queries return untyped data - use models for type safety
4668
+ * @param table The table name to query from
4669
+ * @param options Optional configuration for case convention and alias
4670
+ * @example
4671
+ * ```ts
4672
+ * const rows = await sql.from("users").select("name").many();
4673
+ * // rows is typed as Record<string, any>[]
4674
+ * ```
4675
+ */
4676
+ from<S extends string>(table: TableFormat<S>, options?: RawModelOptions): QueryBuilder;
4627
4677
  /**
4628
4678
  * @description Returns a SchemaBuilder instance for DDL operations
4629
4679
  * @description The builder will execute queries when awaited or when .execute() is called
@@ -6292,12 +6342,23 @@ type ColStringOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "
6292
6342
  length?: number;
6293
6343
  };
6294
6344
  type ColTextOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6295
- type ColIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default">;
6296
- type ColBigIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default">;
6297
- type ColFloatOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default">;
6345
+ type ColIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6346
+ unsigned?: boolean;
6347
+ zerofill?: boolean;
6348
+ };
6349
+ type ColBigIntegerOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6350
+ unsigned?: boolean;
6351
+ zerofill?: boolean;
6352
+ };
6353
+ type ColFloatOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6354
+ unsigned?: boolean;
6355
+ zerofill?: boolean;
6356
+ };
6298
6357
  type ColDecimalOptions = Omit<ColumnOptions, "serialize" | "prepare" | "default"> & {
6299
6358
  precision?: number;
6300
6359
  scale?: number;
6360
+ unsigned?: boolean;
6361
+ zerofill?: boolean;
6301
6362
  };
6302
6363
  type ColIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
6303
6364
  type ColBigIncrementOptions = Omit<ColumnOptions, "serialize" | "prepare" | "primaryKey" | "nullable" | "default">;
@@ -6320,9 +6381,18 @@ type ColCharOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "de
6320
6381
  type ColVarbinaryOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6321
6382
  length?: number;
6322
6383
  };
6323
- type ColTinyIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6324
- type ColSmallIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6325
- type ColMediumIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default">;
6384
+ type ColTinyIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6385
+ unsigned?: boolean;
6386
+ zerofill?: boolean;
6387
+ };
6388
+ type ColSmallIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6389
+ unsigned?: boolean;
6390
+ zerofill?: boolean;
6391
+ };
6392
+ type ColMediumIntOptions = Omit<ColumnOptions, "type" | "serialize" | "prepare" | "default"> & {
6393
+ unsigned?: boolean;
6394
+ zerofill?: boolean;
6395
+ };
6326
6396
  type RelationConstraintOptions = {
6327
6397
  /**
6328
6398
  * Useful for auto generated migrations to specify the on delete action, it does not affect the code wise implementation