pqb 0.67.1 → 0.67.3

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/dist/index.d.ts CHANGED
@@ -4455,6 +4455,7 @@ declare class QueryScope {
4455
4455
  type DeleteMethodsNames = 'delete';
4456
4456
  type DeleteArgs<T extends PickQueryHasWhere> = T['__hasWhere'] extends true ? EmptyTuple : [never];
4457
4457
  type DeleteResult<T extends PickQueryHasSelectResultReturnType> = T['__hasSelect'] extends true ? T : T['returnType'] extends undefined | 'all' ? SetQueryReturnsRowCountMany<T> : SetQueryReturnsRowCount<T>;
4458
+ interface DeleteSelf extends PickQueryHasSelectHasWhereResultReturnType, Query.Pick.IsNotReadOnly {}
4458
4459
  declare const _queryDelete: <T extends PickQueryHasSelectResultReturnType>(query: T) => DeleteResult<T>;
4459
4460
  declare class QueryDelete {
4460
4461
  /**
@@ -4516,10 +4517,10 @@ declare class QueryDelete {
4516
4517
  * .from('b');
4517
4518
  * ```
4518
4519
  */
4519
- delete<T extends PickQueryHasSelectHasWhereResultReturnType>(this: T, ..._args: DeleteArgs<T>): DeleteResult<T>;
4520
+ delete<T extends DeleteSelf>(this: T, ..._args: DeleteArgs<T>): DeleteResult<T>;
4520
4521
  }
4521
4522
  type SoftDeleteOption<Shape extends Column.QueryColumns> = true | keyof Shape;
4522
- interface QueryWithSoftDelete extends PickQueryResult, PickQueryReturnType, PickQueryHasSelect, PickQueryHasWhere {
4523
+ interface QueryWithSoftDelete extends PickQueryResult, PickQueryReturnType, PickQueryHasSelect, PickQueryHasWhere, Query.Pick.IsNotReadOnly {
4523
4524
  __scopes: NonDeletedScope;
4524
4525
  }
4525
4526
  interface NonDeletedScope {
@@ -4820,6 +4821,7 @@ interface QueryInternal<SinglePrimaryKey = any, UniqueColumns = any, UniqueColum
4820
4821
  snakeCase?: boolean;
4821
4822
  noPrimaryKey: boolean;
4822
4823
  comment?: string;
4824
+ readOnly?: boolean;
4823
4825
  primaryKeys?: string[];
4824
4826
  singlePrimaryKey: SinglePrimaryKey;
4825
4827
  uniqueColumns: UniqueColumns;
@@ -4909,6 +4911,10 @@ interface DbTableOptions<ColumnTypes, Table extends string | undefined, Shape ex
4909
4911
  * Table comment, for migrations generator
4910
4912
  */
4911
4913
  comment?: string;
4914
+ /**
4915
+ * Disallow runtime create, update, and delete operations.
4916
+ */
4917
+ readOnly?: true | undefined;
4912
4918
  /**
4913
4919
  * Computed SQL or JS columns definitions
4914
4920
  */
@@ -4919,10 +4925,10 @@ interface DbTableOptions<ColumnTypes, Table extends string | undefined, Shape ex
4919
4925
  nowSQL?: string;
4920
4926
  }
4921
4927
  type DbTableOptionScopes<Table extends string | undefined, Shape extends Column.QueryColumns, Keys extends string = string> = { [K in Keys]: (q: ScopeArgumentQuery<Table, Shape>) => IsQuery };
4922
- interface QueryBuilder extends Query {
4928
+ interface QueryBuilder extends Query.NotReadOnlyQuery {
4923
4929
  returnType: undefined;
4924
4930
  }
4925
- declare class Db<Table extends string | undefined = undefined, Shape extends Column.QueryColumnsInit = Column.QueryColumnsInit, PrimaryKeys = never, UniqueColumns = never, UniqueColumnTuples = never, UniqueConstraints = never, ColumnTypes = DefaultColumnTypes<ColumnSchemaConfig>, ShapeWithComputed extends Column.QueryColumnsInit = Shape, Scopes extends RecordUnknown | undefined = EmptyObject, DefaultSelect extends keyof Shape = keyof Shape> extends QueryMethods<ColumnTypes> implements Query {
4931
+ declare class Db<Table extends string | undefined = undefined, Shape extends Column.QueryColumnsInit = Column.QueryColumnsInit, PrimaryKeys = never, UniqueColumns = never, UniqueColumnTuples = never, UniqueConstraints = never, ColumnTypes = DefaultColumnTypes<ColumnSchemaConfig>, ShapeWithComputed extends Column.QueryColumnsInit = Shape, Scopes extends RecordUnknown | undefined = EmptyObject, DefaultSelect extends keyof Shape = keyof Shape, ReadOnly extends true | undefined = undefined> extends QueryMethods<ColumnTypes> implements Query {
4926
4932
  adapterNotInTransaction: Adapter;
4927
4933
  qb: QueryBuilder;
4928
4934
  table: Table;
@@ -4931,6 +4937,7 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Col
4931
4937
  __isQuery: true;
4932
4938
  __as: Table & string;
4933
4939
  __selectable: SelectableFromShape<ShapeWithComputed, Table>;
4940
+ readOnly: ReadOnly;
4934
4941
  __hasSelect: boolean;
4935
4942
  __hasWhere: boolean;
4936
4943
  __defaults: { [K in { [K in keyof Shape]: unknown extends Shape[K]['data']['default'] ? never : K }[keyof Shape]]: true };
@@ -5020,9 +5027,7 @@ declare class Db<Table extends string | undefined = undefined, Shape extends Col
5020
5027
  queryArrays<R extends any[] = any[]>(...args: SQLQueryArgs): Promise<QueryResult<R>>;
5021
5028
  }
5022
5029
  interface DbTableConstructor<ColumnTypes> {
5023
- <Table extends string, Shape extends Column.QueryColumnsInit, Data extends MaybeArray<TableDataItem>, Options extends DbTableOptions<ColumnTypes, Table, Shape>>(table: Table, shape?: ((t: ColumnTypes) => Shape) | Shape, tableData?: TableDataFn<Shape, Data>, options?: Options): Db<Table, Shape, keyof ShapeColumnPrimaryKeys<Shape> extends never ? never : ShapeColumnPrimaryKeys<Shape>, ShapeUniqueColumns<Shape> | TableDataItemsUniqueColumns<Shape, Data>, TableDataItemsUniqueColumnTuples<Shape, Data>, UniqueConstraints<Shape> | TableDataItemsUniqueConstraints<Data>, ColumnTypes, Shape & ComputedColumnsFromOptions<Options['computed']>, MapTableScopesOption<Options>, ColumnsShape.DefaultSelectKeys<Shape>> & {
5024
- ko: Shape;
5025
- };
5030
+ <Table extends string, Shape extends Column.QueryColumnsInit, Data extends MaybeArray<TableDataItem>, Options extends DbTableOptions<ColumnTypes, Table, Shape>>(table: Table, shape?: ((t: ColumnTypes) => Shape) | Shape, tableData?: TableDataFn<Shape, Data>, options?: Options): Db<Table, Shape, keyof ShapeColumnPrimaryKeys<Shape> extends never ? never : ShapeColumnPrimaryKeys<Shape>, ShapeUniqueColumns<Shape> | TableDataItemsUniqueColumns<Shape, Data>, TableDataItemsUniqueColumnTuples<Shape, Data>, UniqueConstraints<Shape> | TableDataItemsUniqueConstraints<Data>, ColumnTypes, Shape & ComputedColumnsFromOptions<Options['computed']>, MapTableScopesOption<Options>, ColumnsShape.DefaultSelectKeys<Shape>, Options['readOnly'] extends true ? true : undefined>;
5026
5031
  }
5027
5032
  interface DbSqlMethod<ColumnTypes> {
5028
5033
  <T>(...args: StaticSQLArgs): RawSql<Column.Pick.QueryColumnOfType<T>, ColumnTypes>;
@@ -7486,13 +7491,12 @@ declare class QueryCreateFrom {
7486
7491
  */
7487
7492
  insertForEachFrom<T extends CreateSelf>(this: T, query: IsQuery): InsertManyFromResult<T>;
7488
7493
  }
7489
- interface CreateSelf extends IsQuery, PickQueryHasSelect, PickQueryDefaults, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryUniqueProperties, PickQueryInputType {}
7494
+ interface CreateSelf extends PickQueryHasSelect, PickQueryDefaults, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryUniqueProperties, PickQueryInputType, Query.Pick.IsNotReadOnly {}
7490
7495
  type CreateData<T extends CreateSelf> = EmptyObject extends T['relations'] ? CreateDataWithDefaults<T, keyof T['__defaults']> : CreateRelationsData<T>;
7491
7496
  type CreateDataWithDefaults<T extends CreateSelf, Defaults extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults ? never : K]: K extends Defaults ? never : CreateColumn<T, K> } & { [K in Defaults]?: K extends keyof T['inputType'] ? CreateColumn<T, K> : never };
7492
7497
  type CreateDataWithDefaultsForRelations<T extends CreateSelf, Defaults extends keyof T['inputType'], OmitFKeys extends PropertyKey> = { [K in keyof T['inputType'] as K extends Defaults | OmitFKeys ? never : K]: K extends Defaults | OmitFKeys ? never : CreateColumn<T, K> } & { [K in Defaults as K extends OmitFKeys ? never : K]?: CreateColumn<T, K> };
7493
7498
  type CreateColumn<T extends CreateSelf, K extends keyof T['inputType']> = T['inputType'][K] | ((q: T) => QueryOrExpression<T['inputType'][K]>);
7494
- type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsForRelations<T, keyof T['__defaults'], T['relations'][keyof T['relations']]['omitForeignKeyInCreate']> & CreateBelongsToData<T> & T['relations'][keyof T['relations']]['optionalDataForCreate'];
7495
- type CreateBelongsToData<T extends CreateSelf> = [T['relations'][keyof T['relations']]['dataForCreate']] extends [never] ? EmptyObject : CreateRelationsDataOmittingFKeys<T, T['relations'][keyof T['relations']]['dataForCreate']>;
7499
+ type CreateRelationsData<T extends CreateSelf> = CreateDataWithDefaultsForRelations<T, keyof T['__defaults'], T['relations'][keyof T['relations']]['omitForeignKeyInCreate']> & CreateRelationsDataOmittingFKeys<T, T['relations'][keyof T['relations']]['dataForCreate']> & T['relations'][keyof T['relations']]['optionalDataForCreate'];
7496
7500
  type CreateRelationsDataOmittingFKeys<T extends CreateSelf, Union> = (Union extends RelationConfigDataForCreate ? (u: Union['columns'] extends keyof T['__defaults'] ? { [P in Exclude<Union['columns'] & keyof T['inputType'], keyof T['__defaults']>]: CreateColumn<T, P> } & { [P in keyof T['__defaults'] & Union['columns']]?: CreateColumn<T, P> } & Partial<Union['nested']> : { [P in Union['columns'] & keyof T['inputType']]: CreateColumn<T, P> } | Union['nested']) => void : never) extends ((u: infer Obj) => void) ? Obj : never;
7497
7501
  type CreateResult<T extends CreateSelf, Data> = T extends {
7498
7502
  isCount: true;
@@ -7877,23 +7881,24 @@ declare class OnConflictQueryBuilder<T extends CreateSelf, Arg extends OnConflic
7877
7881
  except: keyof T['shape'] | (keyof T['shape'])[];
7878
7882
  }): T;
7879
7883
  }
7880
- interface UpdateSelf extends PickQuerySelectable, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryInputType, PickQueryAs, PickQueryHasSelect, PickQueryHasWhere {}
7881
- type UpdateData<T extends UpdateSelf> = EmptyObject extends T['relations'] ? { [K in keyof T['inputType']]?: UpdateColumn<T, K> } : { [K in keyof T['inputType'] | keyof T['relations']]?: K extends keyof T['inputType'] ? UpdateColumn<T, K> : UpdateRelationData<T, T['relations'][K]> };
7882
- type UpdateColumn<T extends UpdateSelf, Key extends keyof T['inputType']> = T['inputType'][Key] | ((q: { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['query'] : K extends keyof T ? T[K] : never }) => QueryOrExpression<T['inputType'][Key]>);
7883
- type UpdateRelationData<T extends UpdateSelf, Rel extends RelationConfigBase> = T['returnType'] extends undefined | 'all' ? Rel['dataForUpdate'] : Rel['dataForUpdateOne'];
7884
+ interface UpdateSelf extends PickQuerySelectable, PickQueryResult, PickQueryRelations, PickQueryWithData, PickQueryReturnType, PickQueryShape, PickQueryInputType, PickQueryAs, PickQueryHasSelect, PickQueryHasWhere, Query.Pick.IsNotReadOnly {}
7885
+ type UpdateData<T extends UpdateSelf> = { [K in keyof T['inputType'] | keyof T['relations']]?: K extends keyof T['inputType'] ? T['inputType'][K] | ((q: { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['query'] : K extends keyof T ? T[K] : never }) => QueryOrExpression<T['inputType'][K]>) : T['returnType'] extends undefined | 'all' ? T['relations'][K]['dataForUpdate'] : T['relations'][K]['dataForUpdateOne'] };
7884
7886
  type UpdateArg<T extends UpdateSelf> = T['__hasWhere'] extends true ? UpdateData<T> : 'Update statement must have where conditions. To update all prefix `update` with `all()`';
7885
7887
  type UpdateResult<T extends UpdateSelf> = T['__hasSelect'] extends true ? T : T['returnType'] extends undefined | 'all' ? SetQueryReturnsRowCountMany<T> : SetQueryReturnsRowCount<T>;
7886
7888
  type NumericColumns<T extends UpdateSelf> = { [K in keyof T['inputType']]: Exclude<T['shape'][K]['queryType'], string> extends number | bigint | null ? K : never }[keyof T['inputType']];
7887
7889
  type ChangeCountArg<T extends UpdateSelf> = NumericColumns<T> | { [K in NumericColumns<T>]?: T['shape'][K]['type'] extends number | null ? number : number | string | bigint };
7888
- type UpdateManyBySelf = UpdateSelf & PickQueryResultReturnTypeUniqueColumns & PickQueryUniqueProperties;
7889
- type UpdateManyData<T extends UpdateSelf> = ({ [K in keyof T['shape'] as T['shape'][K] extends {
7890
- data: {
7891
- primaryKey: string;
7890
+ interface UpdateManyBySelf extends UpdateSelf {
7891
+ internal: {
7892
+ uniqueColumns: unknown;
7893
+ uniqueColumnNames: unknown;
7894
+ uniqueColumnTuples: unknown;
7895
+ uniqueConstraints: unknown;
7892
7896
  };
7893
- } ? K : never]: T['shape'][K]['queryType'] | Expression } & { [P in keyof T['inputType']]?: T['inputType'][P] | Expression })[];
7897
+ }
7898
+ type UpdateManyData<T extends UpdateSelf> = ({ [K in keyof T['shape'] as T['shape'][K] extends Column.Modifiers.IsPrimaryKey<string> ? K : never]: T['shape'][K]['queryType'] | Expression } & { [P in keyof T['inputType']]?: T['inputType'][P] | Expression })[];
7894
7899
  type UpdateManyByKeys<T extends UpdateManyBySelf> = T['internal']['uniqueColumnNames'] | T['internal']['uniqueColumnTuples'];
7895
- type UpdateManyByKeyColumns<Keys> = Keys extends string ? Keys : Keys extends unknown[] ? Keys[number] & string : never;
7896
- type UpdateManyByData<T extends UpdateSelf, K extends string> = ({ [P in K & keyof T['inputType']]-?: T['inputType'][P] } & { [P in keyof T['inputType'] as P extends K ? never : P]?: T['inputType'][P] | Expression })[];
7900
+ type UpdateManyByKeyColumns<K> = K extends string[] ? K[number] : K;
7901
+ type UpdateManyByData<T extends UpdateSelf, K> = ({ [P in K & keyof T['inputType']]: T['inputType'][P] } & { [P in keyof T['inputType']]?: P extends K ? T['inputType'][P] : T['inputType'][P] | Expression })[];
7897
7902
  type UpdateManyResult<T extends UpdateSelf> = T['__hasSelect'] extends true ? T['returnType'] extends 'one' | 'oneOrThrow' ? SetQueryReturnsAllResult<T, T['result']> : T['returnType'] extends 'value' | 'valueOrThrow' ? SetQueryReturnsPluckColumnResult<T, T['result']> : SetQueryResult<T, T['result']> : SetQueryReturnsRowCountMany<T>;
7898
7903
  declare const _queryUpdate: <T extends UpdateSelf>(updateSelf: T, arg: UpdateArg<T>) => UpdateResult<T>;
7899
7904
  declare const _queryUpdateOrThrow: <T extends UpdateSelf>(q: T, arg: UpdateArg<T>) => UpdateResult<T>;
@@ -8327,7 +8332,7 @@ declare class QueryUpdate {
8327
8332
  * ]);
8328
8333
  * ```
8329
8334
  */
8330
- updateManyBy<T extends UpdateManyBySelf, Keys extends UpdateManyByKeys<T>, K extends string = UpdateManyByKeyColumns<Keys>>(this: T, keys: Keys, data: UpdateManyByData<T, K>): UpdateManyResult<T> & QueryHasWhere;
8335
+ updateManyBy<T extends UpdateManyBySelf, Keys extends UpdateManyByKeys<T>, K = UpdateManyByKeyColumns<Keys>>(this: T, keys: Keys, data: UpdateManyByData<T, K>): UpdateManyResult<T> & QueryHasWhere;
8331
8336
  /**
8332
8337
  * Same as {@link updateManyBy}, but skips records with no matching key rather than throwing.
8333
8338
  *
@@ -8338,7 +8343,7 @@ declare class QueryUpdate {
8338
8343
  * ]);
8339
8344
  * ```
8340
8345
  */
8341
- updateManyByOptional<T extends UpdateManyBySelf, Keys extends UpdateManyByKeys<T>, K extends string = UpdateManyByKeyColumns<Keys>>(this: T, keys: Keys, data: UpdateManyByData<T, K>): UpdateManyResult<T> & QueryHasWhere;
8346
+ updateManyByOptional<T extends UpdateManyBySelf, Keys extends UpdateManyByKeys<T>, K = UpdateManyByKeyColumns<Keys>>(this: T, keys: Keys, data: UpdateManyByData<T, K>): UpdateManyResult<T> & QueryHasWhere;
8342
8347
  }
8343
8348
  declare abstract class VirtualColumn<Schema extends ColumnSchemaConfig, InputSchema extends Schema['type'] = ReturnType<Schema['never']>> extends Column<Schema, unknown, InputSchema, OperatorsAny> {
8344
8349
  dataType: string;
@@ -8708,6 +8713,8 @@ interface QueryData extends QueryDataAliases, PickQueryDataParsers, HasHookSelec
8708
8713
  /** upsert **/
8709
8714
  upsertUpdate?: boolean;
8710
8715
  upsertSecond?: boolean;
8716
+ upsertCreateAppendQueries?: SubQueryForSql[];
8717
+ upsertCreateAsFns?: AsFn[];
8711
8718
  upsertInsert?(): unknown;
8712
8719
  /** insert **/
8713
8720
  columns: string[];
@@ -9338,7 +9345,7 @@ type UpsertData<T extends UpsertThis, Update extends UpdateData<T>> = {
9338
9345
  data: Update;
9339
9346
  create: UpsertCreate<keyof Update, CreateData<T>> | ((update: Update) => UpsertCreate<keyof Update, CreateData<T>>);
9340
9347
  };
9341
- declare const _queryUpsert: (q: Query, data: UpsertData<UpsertThis, UpdateData<Query>>) => Query;
9348
+ declare const _queryUpsert: (q: Query, data: UpsertData<UpsertThis, UpdateData<UpdateSelf>>) => Query;
9342
9349
  declare class QueryUpsert {
9343
9350
  /**
9344
9351
  * `upsert` tries to update a single record, and then it creates the record if it doesn't yet exist.
@@ -9725,7 +9732,7 @@ declare class QueryTruncate {
9725
9732
  *
9726
9733
  * @param options - truncate options, may have `cascade: true` and `restartIdentity: true`
9727
9734
  */
9728
- truncate<T>(this: T, options?: {
9735
+ truncate<T extends Query.Pick.IsNotReadOnly>(this: T, options?: {
9729
9736
  restartIdentity?: boolean;
9730
9737
  cascade?: boolean;
9731
9738
  }): SetQueryReturnsVoid<T>;
@@ -10281,8 +10288,12 @@ interface Query extends IsQuery, PickQueryTable, PickQueryShape, PickQuerySelect
10281
10288
  relations: RelationsBase;
10282
10289
  relationQueries: IsQueries;
10283
10290
  error: new (message: string, length: number, name: QueryErrorName) => QueryError;
10291
+ readOnly: true | undefined;
10284
10292
  }
10285
10293
  declare namespace Query {
10294
+ interface NotReadOnlyQuery extends Query {
10295
+ readOnly: undefined;
10296
+ }
10286
10297
  namespace Order {
10287
10298
  type Arg<T extends Order.ArgThis> = Order.Arg<T>;
10288
10299
  type Args<T extends Order.ArgThis> = Order.Args<T>;
@@ -10294,6 +10305,9 @@ declare namespace Query {
10294
10305
  };
10295
10306
  returnType: 'value' | 'valueOrThrow';
10296
10307
  }
10308
+ interface IsNotReadOnly {
10309
+ readOnly: undefined;
10310
+ }
10297
10311
  }
10298
10312
  }
10299
10313
  type SelectableOfType<T extends PickQuerySelectable, Type> = { [K in keyof T['__selectable']]: T['__selectable'][K]['column']['type'] extends Type | null ? K : never }[keyof T['__selectable']];
@@ -10364,7 +10378,7 @@ interface RelationConfigBase extends IsQuery {
10364
10378
  modifyRelatedQuery?(relatedQuery: IsQuery): (query: IsQuery) => void;
10365
10379
  maybeSingle: PickQuerySelectableReturnType;
10366
10380
  omitForeignKeyInCreate: PropertyKey;
10367
- dataForCreate?: RelationConfigDataForCreate;
10381
+ dataForCreate: RelationConfigDataForCreate | undefined;
10368
10382
  optionalDataForCreate: unknown;
10369
10383
  dataForUpdate: unknown;
10370
10384
  dataForUpdateOne: unknown;
@@ -10527,6 +10541,7 @@ declare abstract class QueryAsMethods {
10527
10541
  as<T extends AsQueryArg, As extends string>(this: T, as: As): SetQueryTableAlias<T, As>;
10528
10542
  }
10529
10543
  declare const _appendQuery: (main: Query, append: Query, asFn: (as: string) => void) => Query;
10544
+ declare const _appendQueryOnUpsertCreate: (main: Query, append: Query, asFn: (as: string) => void) => Query;
10530
10545
  declare const getPrimaryKeys: (q: Query) => string[];
10531
10546
  /**
10532
10547
  * Set value into the object in query data, create the object if it doesn't yet exist.
@@ -10682,4 +10697,4 @@ declare const testTransaction: {
10682
10697
  */
10683
10698
  close(arg: Arg$1): Promise<void>;
10684
10699
  };
10685
- export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
10700
+ export { type Adapter, AdapterClass, type AdapterConfigBase, type AdapterParams, type AdapterSchemaConfigOptions, type AfterCommitStandaloneHook, type AfterHook, ArrayColumn, type ArrayColumnValue, type ArrayData, type AsyncState, type BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnSchemaConfig, type ColumnSchemaGetterColumns, type ColumnSchemaGetterTableClass, type ColumnToCodeCtx, type ColumnTypeSchemaArg, type ColumnsByType, type ColumnsShape, type ComputedColumnsFromOptions, type ComputedOptionsConfig, type ComputedOptionsFactory, type CreateCtx, type CreateData, type CreateManyMethodsNames, type CreateMethodsNames, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnData, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbSqlMethod, type DbStructureDomainsMap, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultPrivileges, type DefaultSchemaConfig, type DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, type DriverAdapter, DynamicRawSQL, type EmptyObject, type EmptyTuple, EnumColumn, Expression, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinQueryMethod, type JoinedShapes, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, Operators, type OperatorsArray, type OperatorsJson, type OperatorsOrdinalText, OrchidOrmInternalError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type Query, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, QueryError, type QueryHasWhere, type QueryHelperResult, QueryHookUtils, QueryHooks, type QueryInternal, type QueryLogObject, type QueryLogOptions, type QueryLogger, type QueryManyTake, type QueryManyTakeOptional, type QueryOrExpression, type QueryResult, type QueryResultRow, type QueryReturnType, type QuerySchema, type QueryScopes, RawSql, type RawSqlBase, RealColumn, type RecordKeyTrue, type RecordOptionalString, type RecordString, type RecordStringOrNumber, type RecordUnknown, type RelationConfigBase, type RelationJoinQuery, type RelationsBase, type Rls, type RlsPolicy, type SchemaConfigFnWithOptions, type SearchWeight, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextBaseColumn, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _orCreate, _prependWith, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, consumeColumnName, copyTableData, createDbWithAdapter, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnInfo, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, tableDataMethods, testTransaction, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
package/dist/index.js CHANGED
@@ -3501,6 +3501,11 @@ var NestedSqlSessionError = class extends OrchidOrmInternalError {
3501
3501
  super(query, "Cannot nest SQL session scopes. Outer scope already has role or setConfig defined.");
3502
3502
  }
3503
3503
  };
3504
+ var CannotMutateReadOnlyTableError = class extends OrchidOrmInternalError {
3505
+ constructor(query) {
3506
+ super(query, "Cannot mutate a readonly table.");
3507
+ }
3508
+ };
3504
3509
  const escape = (value, migration, nested) => {
3505
3510
  const type = typeof value;
3506
3511
  if (type === "number" || type === "bigint") return String(value);
@@ -4558,7 +4563,11 @@ const loadRelations = async (state, result, savepointState, renames) => {
4558
4563
  const q = state.query;
4559
4564
  const primaryKeys = requirePrimaryKeys(q, "Cannot select a relation of a table that has no primary keys");
4560
4565
  const selectQuery = _unscope(q, "nonDeleted");
4561
- selectQuery.q.type = selectQuery.q.returnType = void 0;
4566
+ selectQuery.q.type = void 0;
4567
+ selectQuery.q.returnType = void 0;
4568
+ selectQuery.q.with = void 0;
4569
+ selectQuery.q.appendQueries = void 0;
4570
+ selectQuery.q.valuesJoinedAs = void 0;
4562
4571
  const matchSourceTableIds = {};
4563
4572
  for (const pkey of primaryKeys) matchSourceTableIds[pkey] = { in: result.map((row) => row[pkey]) };
4564
4573
  (selectQuery.q.and ??= []).push(matchSourceTableIds);
@@ -5183,6 +5192,9 @@ const throwIfNoWhere = (q, method) => {
5183
5192
  const throwIfJoinLateral = (q, method) => {
5184
5193
  if (q.q.join?.some((x) => Array.isArray(x) || "s" in x.args && x.args.s)) throw new OrchidOrmInternalError(q, `Cannot join a complex query in ${method}`);
5185
5194
  };
5195
+ const throwIfReadOnly = (query) => {
5196
+ if (query.internal.readOnly) throw new CannotMutateReadOnlyTableError(query);
5197
+ };
5186
5198
  const throwOnReadOnlyUpdate = (query, column, key) => {
5187
5199
  if (column.data.appReadOnly || column.data.readOnly) throw new OrchidOrmInternalError(query, "Trying to update a readonly column", { column: key });
5188
5200
  };
@@ -6953,22 +6965,33 @@ const setMutativeQueriesSelectRelationsSqlState = (d, as, rel) => {
6953
6965
  const handleInsertAndUpdateSelectRelationsSqlState = (ctx, state) => {
6954
6966
  if (state) ctx.topCtx.mutativeQueriesSelectRelationsSqlState = state;
6955
6967
  };
6968
+ const unsetValuesJoinedAsForMutativeSelectRelations = (query) => {
6969
+ if (!query.q.selectRelation || !query.q.valuesJoinedAs) return;
6970
+ const { valuesJoinedAs } = query.q;
6971
+ query.q.valuesJoinedAs = void 0;
6972
+ return valuesJoinedAs;
6973
+ };
6974
+ const restoreValuesJoinedAsForMutativeSelectRelations = (query, valuesJoinedAs) => {
6975
+ if (valuesJoinedAs) query.q.valuesJoinedAs = valuesJoinedAs;
6976
+ };
6956
6977
  const handleDeleteSelectRelationsSqlState = (ctx, query, relationSelectState) => {
6957
6978
  const selectRelations = relationSelectState?.value;
6958
6979
  if (!selectRelations) return;
6959
6980
  const selectPrimaryKeysQuery = prepareSubQueryForSql(query, _clone(query));
6981
+ selectPrimaryKeysQuery.q.valuesJoinedAs = void 0;
6960
6982
  const primaryKeys = requirePrimaryKeys(query, "primary keys are required for selecting relation in delete");
6961
6983
  _addToHookSelect(selectPrimaryKeysQuery, primaryKeys, true);
6962
6984
  const { as: cteAs } = moveQueryToCte(ctx, selectPrimaryKeysQuery, void 0, true);
6963
6985
  const relKeys = Object.keys(selectRelations);
6964
6986
  const hookSelect = selectPrimaryKeysQuery.q.hookSelect;
6987
+ const queryAs = getQueryAs(query);
6965
6988
  const join = {
6966
6989
  type: "JOIN",
6967
6990
  args: {
6968
6991
  w: cteAs,
6969
6992
  a: [Object.fromEntries(primaryKeys.map((key) => {
6970
6993
  const selected = hookSelect.get(key);
6971
- return [cteAs + "." + (selected.as || selected.select), key];
6994
+ return [cteAs + "." + (selected.as || selected.select), `${queryAs}.${key}`];
6972
6995
  }))]
6973
6996
  }
6974
6997
  };
@@ -7703,6 +7726,14 @@ function pushLimitSQL(sql, values, q) {
7703
7726
  }
7704
7727
  }
7705
7728
  const pushUpdateSql = (ctx, query, q, quotedAs, isSubSql) => {
7729
+ const valuesJoinedAs = unsetValuesJoinedAsForMutativeSelectRelations(query);
7730
+ try {
7731
+ return pushUpdateSqlWithoutValuesJoinedAs(ctx, query, q, quotedAs, isSubSql);
7732
+ } finally {
7733
+ restoreValuesJoinedAsForMutativeSelectRelations(query, valuesJoinedAs);
7734
+ }
7735
+ };
7736
+ const pushUpdateSqlWithoutValuesJoinedAs = (ctx, query, q, quotedAs, isSubSql) => {
7706
7737
  const quotedTable = `"${query.table || q.from}"`;
7707
7738
  const from = quoteTableWithSchema(query);
7708
7739
  const set = [];
@@ -8480,6 +8511,7 @@ var AggregateMethods = class {
8480
8511
  * @param data - optionally passed custom data when creating a single record.
8481
8512
  */
8482
8513
  const insertFrom = (query, from, many, queryMany, data) => {
8514
+ throwIfReadOnly(query);
8483
8515
  const ctx = createCtx();
8484
8516
  const obj = data && (Array.isArray(data) ? handleManyData(query, data, ctx) : handleOneData(query, data, ctx));
8485
8517
  return insert(query, {
@@ -8935,17 +8967,21 @@ const insert = (self, { columns, insertFrom, values }, many, queryMany) => {
8935
8967
  return self;
8936
8968
  };
8937
8969
  const _queryCreate = (q, data) => {
8970
+ throwIfReadOnly(q);
8938
8971
  createSelect(q);
8939
8972
  return _queryInsert(q, data);
8940
8973
  };
8941
8974
  const _queryInsert = (query, data) => {
8975
+ throwIfReadOnly(query);
8942
8976
  return insert(query, handleOneData(query, data, createCtx()));
8943
8977
  };
8944
8978
  const _queryCreateMany = (q, data) => {
8979
+ throwIfReadOnly(q);
8945
8980
  createSelect(q);
8946
8981
  return _queryInsertMany(q, data);
8947
8982
  };
8948
8983
  const _queryInsertMany = (q, data) => {
8984
+ throwIfReadOnly(q);
8949
8985
  let result = insert(q, handleManyData(q, data, createCtx()), true);
8950
8986
  if (!data.length) result = result.none();
8951
8987
  return result;
@@ -9556,6 +9592,8 @@ const toSql = (table, type, topCtx, isSubSql, cteName, calledByThen, dontAddTabl
9556
9592
  _queryInsert(upsertOrCreate, query.upsertInsert());
9557
9593
  upsertOrCreate.q.type = "upsert";
9558
9594
  }
9595
+ upsertOrCreate.q.appendQueries = query.upsertCreateAppendQueries;
9596
+ upsertOrCreate.q.asFns = query.upsertCreateAsFns;
9559
9597
  const { makeSql: makeSecondSql } = moveMutativeQueryToCteBase(toSql, ctx, upsertOrCreate, "insert");
9560
9598
  sql.push(makeFirstSql(isSubSql), "UNION ALL", makeSecondSql(isSubSql));
9561
9599
  } else {
@@ -9711,9 +9749,9 @@ const addTopCteInternal = (place, ctx, item, type, dontAddTableHook) => {
9711
9749
  topCTE.stack.pop();
9712
9750
  };
9713
9751
  const addWithToSql = (ctx, sql, isSubSql) => {
9714
- if (!isSubSql && ctx.topCtx.topCTE) {
9752
+ if (!isSubSql && ctx.topCtx.topCTE?.append.length) {
9715
9753
  const sqls = [];
9716
- if (!isSubSql && ctx.topCtx.topCTE) for (const append of ctx.topCtx.topCTE.append) sqls.push(...append);
9754
+ for (const append of ctx.topCtx.topCTE.append) sqls.push(...append);
9717
9755
  sql.text = "WITH " + sqls.join(", ") + " " + sql.text;
9718
9756
  }
9719
9757
  };
@@ -11294,6 +11332,7 @@ var QueryGet = class {
11294
11332
  }
11295
11333
  };
11296
11334
  const _queryDelete = (query) => {
11335
+ throwIfReadOnly(query);
11297
11336
  const q = query.q;
11298
11337
  if (!q.select) {
11299
11338
  if (q.returnType === "oneOrThrow" || q.returnType === "valueOrThrow") q.throwOnNotFound = true;
@@ -11477,6 +11516,7 @@ var RefExpression = class extends Expression {
11477
11516
  };
11478
11517
  const _queryUpdateMany = (self, primaryKeys, data, strict) => {
11479
11518
  const query = self;
11519
+ throwIfReadOnly(query);
11480
11520
  const { q } = query;
11481
11521
  const { shape } = q;
11482
11522
  q.type = "update";
@@ -11496,6 +11536,7 @@ const _queryUpdateMany = (self, primaryKeys, data, strict) => {
11496
11536
  return query;
11497
11537
  };
11498
11538
  const _queryChangeCounter = (self, op, data) => {
11539
+ throwIfReadOnly(self);
11499
11540
  const q = self.q;
11500
11541
  q.type = "update";
11501
11542
  if (!q.select) {
@@ -11528,6 +11569,7 @@ const _queryChangeCounter = (self, op, data) => {
11528
11569
  };
11529
11570
  const _queryUpdate = (updateSelf, arg) => {
11530
11571
  const query = updateSelf;
11572
+ throwIfReadOnly(query);
11531
11573
  const { q } = query;
11532
11574
  q.type = "update";
11533
11575
  const set = { ...arg };
@@ -11855,6 +11897,7 @@ var QueryUpdate = class {
11855
11897
  */
11856
11898
  updateFrom(arg, ...args) {
11857
11899
  const q = _clone(this);
11900
+ throwIfReadOnly(q);
11858
11901
  const joinArgs = _joinReturningArgs(q, true, arg, args, true);
11859
11902
  if (!joinArgs) return _queryNone(q);
11860
11903
  joinArgs.u = true;
@@ -12352,6 +12395,9 @@ var QueryExpressions = class {
12352
12395
  const _appendQuery = (main, append, asFn) => {
12353
12396
  return pushQueryValueImmutable(pushQueryValueImmutable(main, "appendQueries", prepareSubQueryForSql(main, append)), "asFns", asFn);
12354
12397
  };
12398
+ const _appendQueryOnUpsertCreate = (main, append, asFn) => {
12399
+ return pushQueryValueImmutable(pushQueryValueImmutable(main, "upsertCreateAppendQueries", prepareSubQueryForSql(main, append)), "upsertCreateAsFns", asFn);
12400
+ };
12355
12401
  const mergableObjects = new Set([
12356
12402
  "shape",
12357
12403
  "withShapes",
@@ -13123,6 +13169,7 @@ var QueryTruncate = class {
13123
13169
  * @param options - truncate options, may have `cascade: true` and `restartIdentity: true`
13124
13170
  */
13125
13171
  truncate(options) {
13172
+ throwIfReadOnly(this);
13126
13173
  const query = Object.create(_clone(this));
13127
13174
  query.toSQL = () => makeTruncateSql(query, options);
13128
13175
  return _queryExec(query);
@@ -13786,6 +13833,7 @@ var Db = class extends QueryMethods {
13786
13833
  snakeCase: options.snakeCase,
13787
13834
  noPrimaryKey: options.noPrimaryKey === "ignore",
13788
13835
  comment: options.comment,
13836
+ readOnly: options.readOnly,
13789
13837
  nowSQL: options.nowSQL,
13790
13838
  tableData,
13791
13839
  selectAllCount
@@ -14381,6 +14429,7 @@ exports.VarCharColumn = VarCharColumn;
14381
14429
  exports.VirtualColumn = VirtualColumn;
14382
14430
  exports.XMLColumn = XMLColumn;
14383
14431
  exports._appendQuery = _appendQuery;
14432
+ exports._appendQueryOnUpsertCreate = _appendQueryOnUpsertCreate;
14384
14433
  exports._clone = _clone;
14385
14434
  exports._createDbSqlMethod = _createDbSqlMethod;
14386
14435
  exports._hookSelectColumns = _hookSelectColumns;