import { SQLiteViewBase } from "../view-base.cjs";
import { SQLiteSelectJoinConfig, SelectedFields, SelectedFieldsOrdered } from "./select.types.cjs";
import { SQLiteColumn } from "../columns/common.cjs";
import { entityKind } from "../../entity.cjs";
import { SelectResultFields } from "../../query-builders/select.types.cjs";
import { Placeholder, Query, SQL, SQLWrapper } from "../../sql/sql.cjs";
import { Subquery } from "../../subquery.cjs";
import { InferInsertModel } from "../../table.cjs";
import { Assume, UpdateSet, ValueOrArray } from "../../utils.cjs";
import { GetColumnData } from "../../column.cjs";
import { SQLiteTable } from "../table.cjs";
import { SQLiteDialect } from "../dialect.cjs";
import { SQLiteSession } from "../session.cjs";

//#region src/sqlite-core/query-builders/update.d.ts
interface SQLiteUpdateConfig {
  where?: SQL | undefined;
  limit?: number | Placeholder;
  orderBy?: (SQLiteColumn | SQL | SQL.Aliased)[];
  set: UpdateSet;
  table: SQLiteTable;
  from?: SQLiteTable | Subquery | SQLiteViewBase | SQL;
  joins: SQLiteSelectJoinConfig[];
  returning?: SelectedFieldsOrdered;
  withList?: Subquery[];
}
type SQLiteUpdateSetSource<TTable extends SQLiteTable, TModel extends Record<string, any> = InferInsertModel<TTable>> = { [Key in keyof TModel & string]?: GetColumnData<TTable['_']['columns'][Key], 'query'> | SQL | SQLiteColumn | Placeholder | undefined } & {};
interface SQLiteUpdateBuilderConstructor {
  new (table: SQLiteTable, set: UpdateSet, session: SQLiteSession<any, any>, dialect: SQLiteDialect, withList?: Subquery[]): AnySQLiteUpdate;
}
declare class SQLiteUpdateBuilder<TTable extends SQLiteTable, TRunResult, THKT extends SQLiteUpdateHKTBase = SQLiteUpdateQueryBuilderHKT> {
  protected table: TTable;
  protected session: SQLiteSession<any, any>;
  protected dialect: SQLiteDialect;
  private withList?;
  private builder;
  static readonly [entityKind]: string;
  readonly _: {
    readonly table: TTable;
  };
  constructor(table: TTable, session: SQLiteSession<any, any>, dialect: SQLiteDialect, withList?: Subquery[] | undefined, builder?: SQLiteUpdateBuilderConstructor);
  set(values: SQLiteUpdateSetSource<TTable>): SQLiteUpdateWithout<Assume<SQLiteUpdateKind<THKT, TTable, TRunResult>, AnySQLiteUpdate>, false, 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>;
}
interface SQLiteUpdateHKTBase {
  table: unknown;
  resultType: unknown;
  runResult: unknown;
  from: unknown;
  returning: unknown;
  dynamic: boolean;
  excludedMethods: string;
  result: unknown;
  _type: unknown;
}
interface SQLiteUpdateQueryBuilderHKT extends SQLiteUpdateHKTBase {
  _type: SQLiteUpdateBase<SQLiteUpdateQueryBuilderHKT, Assume<this['table'], SQLiteTable>, this['runResult'], Assume<this['from'], SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined>, this['returning'], this['dynamic'], this['excludedMethods']>;
}
type SQLiteUpdateKind<T extends SQLiteUpdateHKTBase, TTable extends SQLiteTable, TRunResult, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> = (T & {
  table: TTable;
  runResult: TRunResult;
  from: TFrom;
  returning: TReturning;
  dynamic: TDynamic;
  excludedMethods: TExcludedMethods;
  result: TReturning extends undefined ? TRunResult : TReturning[];
})['_type'];
type SQLiteUpdateWithout<T extends AnySQLiteUpdate, TDynamic extends boolean, K extends keyof T & string> = TDynamic extends true ? T : Omit<SQLiteUpdateKind<T['_']['hkt'], T['_']['table'], T['_']['runResult'], T['_']['from'], T['_']['returning'], TDynamic, T['_']['excludedMethods'] | K>, T['_']['excludedMethods'] | K>;
type SQLiteUpdateWithJoins<T extends AnySQLiteUpdate, TDynamic extends boolean, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL> = TDynamic extends true ? T : Omit<SQLiteUpdateKind<T['_']['hkt'], T['_']['table'], T['_']['runResult'], TFrom, T['_']['returning'], TDynamic, Exclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>>, Exclude<T['_']['excludedMethods'] | 'from', 'leftJoin' | 'rightJoin' | 'innerJoin' | 'fullJoin'>>;
type SQLiteUpdateReturningAll<T extends AnySQLiteUpdate, TDynamic extends boolean> = SQLiteUpdateWithout<SQLiteUpdateKind<T['_']['hkt'], T['_']['table'], T['_']['runResult'], T['_']['from'], T['_']['table']['$inferSelect'], TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
type SQLiteUpdateReturning<T extends AnySQLiteUpdate, TDynamic extends boolean, TSelectedFields extends SelectedFields> = SQLiteUpdateWithout<SQLiteUpdateKind<T['_']['hkt'], T['_']['table'], T['_']['runResult'], T['_']['from'], SelectResultFields<TSelectedFields>, TDynamic, T['_']['excludedMethods']>, TDynamic, 'returning'>;
type SQLiteUpdateJoinFn<T extends AnySQLiteUpdate> = <TJoinedTable extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(table: TJoinedTable, on: ((updateTable: T['_']['table']['_']['columns'], from: T['_']['from'] extends SQLiteTable ? T['_']['from']['_']['columns'] : T['_']['from'] extends Subquery | SQLiteViewBase ? T['_']['from']['_']['selectedFields'] : never) => SQL | undefined) | SQL | undefined) => T;
type SQLiteUpdateDynamic<T extends AnySQLiteUpdate> = SQLiteUpdateKind<T['_']['hkt'], T['_']['table'], T['_']['runResult'], T['_']['from'], T['_']['returning'], true, never>;
type SQLiteUpdate<TTable extends SQLiteTable = SQLiteTable, TRunResult = any, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning extends Record<string, unknown> | undefined = Record<string, unknown> | undefined> = SQLiteUpdateBase<SQLiteUpdateQueryBuilderHKT, TTable, TRunResult, TFrom, TReturning, true, never>;
type AnySQLiteUpdate = SQLiteUpdateBase<any, any, any, any, any, any, any>;
interface SQLiteUpdateBase<THKT extends SQLiteUpdateHKTBase, TTable extends SQLiteTable = SQLiteTable, TRunResult = unknown, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> extends SQLWrapper {
  readonly _: {
    readonly dialect: 'sqlite';
    readonly hkt: THKT;
    readonly table: TTable;
    readonly runResult: TRunResult;
    readonly from: TFrom;
    readonly returning: TReturning;
    readonly dynamic: TDynamic;
    readonly excludedMethods: TExcludedMethods;
    readonly result: TReturning extends undefined ? TRunResult : TReturning[];
  };
}
declare class SQLiteUpdateBase<THKT extends SQLiteUpdateHKTBase, TTable extends SQLiteTable = SQLiteTable, TRunResult = unknown, TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL | undefined = undefined, TReturning = undefined, TDynamic extends boolean = false, TExcludedMethods extends string = never> implements SQLWrapper {
  protected session: SQLiteSession<any, any>;
  protected dialect: SQLiteDialect;
  static readonly [entityKind]: string;
  constructor(table: TTable, set: UpdateSet, session: SQLiteSession<any, any>, dialect: SQLiteDialect, withList?: Subquery[]);
  from<TFrom extends SQLiteTable | Subquery | SQLiteViewBase | SQL>(source: TFrom): SQLiteUpdateWithJoins<this, TDynamic, TFrom>;
  private createJoin;
  leftJoin: SQLiteUpdateJoinFn<this>;
  rightJoin: SQLiteUpdateJoinFn<this>;
  innerJoin: SQLiteUpdateJoinFn<this>;
  fullJoin: SQLiteUpdateJoinFn<this>;
  /**
   * Adds a 'where' clause to the query.
   *
   * Calling this method will update only those rows that fulfill a specified condition.
   *
   * See docs: {@link https://orm.drizzle.team/docs/update}
   *
   * @param where the 'where' clause.
   *
   * @example
   * You can use conditional operators and `sql function` to filter the rows to be updated.
   *
   * ```ts
   * // Update all cars with green color
   * db.update(cars).set({ color: 'red' })
   *   .where(eq(cars.color, 'green'));
   * // or
   * db.update(cars).set({ color: 'red' })
   *   .where(sql`${cars.color} = 'green'`)
   * ```
   *
   * You can logically combine conditional operators with `and()` and `or()` operators:
   *
   * ```ts
   * // Update all BMW cars with a green color
   * db.update(cars).set({ color: 'red' })
   *   .where(and(eq(cars.color, 'green'), eq(cars.brand, 'BMW')));
   *
   * // Update all cars with the green or blue color
   * db.update(cars).set({ color: 'red' })
   *   .where(or(eq(cars.color, 'green'), eq(cars.color, 'blue')));
   * ```
   */
  where(where: SQL | undefined): SQLiteUpdateWithout<this, TDynamic, 'where'>;
  orderBy(builder: (updateTable: TTable) => ValueOrArray<SQLiteColumn | SQL | SQL.Aliased>): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;
  orderBy(...columns: (SQLiteColumn | SQL | SQL.Aliased)[]): SQLiteUpdateWithout<this, TDynamic, 'orderBy'>;
  limit(limit: number | Placeholder): SQLiteUpdateWithout<this, TDynamic, 'limit'>;
  /**
   * Adds a `returning` clause to the query.
   *
   * Calling this method will return the specified fields of the updated rows. If no fields are specified, all fields will be returned.
   *
   * See docs: {@link https://orm.drizzle.team/docs/update#update-with-returning}
   *
   * @example
   * ```ts
   * // Update all cars with the green color and return all fields
   * const updatedCars: Car[] = await db.update(cars)
   *   .set({ color: 'red' })
   *   .where(eq(cars.color, 'green'))
   *   .returning();
   *
   * // Update all cars with the green color and return only their id and brand fields
   * const updatedCarsIdsAndBrands: { id: number, brand: string }[] = await db.update(cars)
   *   .set({ color: 'red' })
   *   .where(eq(cars.color, 'green'))
   *   .returning({ id: cars.id, brand: cars.brand });
   * ```
   */
  returning(): SQLiteUpdateReturningAll<this, TDynamic>;
  returning<TSelectedFields extends SelectedFields>(fields: TSelectedFields): SQLiteUpdateReturning<this, TDynamic, TSelectedFields>;
  getSQL(): SQL;
  toSQL(): Query;
  $dynamic(): SQLiteUpdateDynamic<this>;
}
//#endregion
export { AnySQLiteUpdate, SQLiteUpdate, SQLiteUpdateBase, SQLiteUpdateBuilder, SQLiteUpdateBuilderConstructor, SQLiteUpdateConfig, SQLiteUpdateDynamic, SQLiteUpdateHKTBase, SQLiteUpdateJoinFn, SQLiteUpdateKind, SQLiteUpdateQueryBuilderHKT, SQLiteUpdateReturning, SQLiteUpdateReturningAll, SQLiteUpdateSetSource, SQLiteUpdateWithJoins, SQLiteUpdateWithout };
//# sourceMappingURL=update.d.cts.map