pqb 0.72.2 → 0.73.0
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 +14 -6
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +25 -9
- package/dist/index.mjs.map +1 -1
- package/dist/internal.d.ts +13 -6
- package/dist/internal.js +28 -7
- package/dist/internal.js.map +1 -1
- package/dist/internal.mjs +24 -9
- package/dist/internal.mjs.map +1 -1
- package/package.json +1 -1
package/dist/internal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Adapter, AdapterClass, AdapterConfigBase, AdapterParams, AdapterSchemaConfigOptions, AfterCommitStandaloneHook, AfterHook, ArrayColumn, ArrayColumnValue, ArrayData, AsyncState, BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, BrandColumn, BrandColumnsShape, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Code, Codes, Column, ColumnFromDbParams, ColumnRefExpression, ColumnSchemaConfig, ColumnSchemaGetterColumns, ColumnSchemaGetterTableClass, ColumnToCodeCtx, ColumnTypeSchemaArg, ColumnsByType, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateCtx, CreateData, CreateManyMethodsNames, CreateMethodsNames, CreateSelf, CustomTypeColumn, DateColumn, DateColumnData, DateColumnInput, DbDomainArg, DbExtension, DbOptions, DbResult, DbSharedOptions, DbSqlMethod, DbStructureDomainsMap, DbTableOptionScopes, DbTableOptions, DecimalColumn, DecimalColumnData, DefaultColumnTypes, DefaultPrivileges, DefaultSchemaConfig, DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, DriverAdapter, DynamicRawSQL, EmptyObject, EmptyTuple, EnumColumn, Expression, ExpressionData, FromArg, FromResult, GeneratorIgnore, HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, IsQuery, IsolationLevel, JSONColumn, JSONTextColumn, JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MapTableScopesOption, MaybeArray, MaybePromise, MergeQuery, MoneyColumn, NoPrimaryKeyOption, NonUniqDataItem, NumberColumnData, Operators, OperatorsArray, OperatorsDate, OperatorsJson, OperatorsNumber, OperatorsOrdinalText, OperatorsText, Ord, PathColumn, PickQueryInputType, PickQueryInternal, PickQueryQ, PickQueryRelations, PickQuerySelectableRelations, PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryAfterHook, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere, QueryHookUtils, QueryHooks, QueryInternal, QueryLogObject, QueryLogOptions, QueryLogger, QueryManyTake, QueryManyTakeOptional, QueryOrExpression, QueryResult, QueryResultRow, QueryReturnType, QuerySchema, QueryScopes, RawSql, RawSqlBase, RealColumn, RecordKeyTrue, RecordOptionalString, RecordString, RecordStringOrNumber, RecordUnknown, RelationConfigBase, RelationJoinQuery, RelationsBase, Rls, RlsPolicy, SchemaConfigFnWithOptions, SearchWeight, SelectSqlColumn, SelectableFromShape, SerialColumn, SerialColumnData, ShallowSimplify, ShapeUniqueColumns, SingleSql, SingleSqlItem, SmallIntColumn, SmallSerialColumn, Sql, SqlFn, SqlSessionState, StaticSQLArgs, StorageOptions, StringColumn, StringData, TableData, TableDataFn, TableDataInput, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableDataMethods, TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, Timestamps, ToSQLCtx, ToSqlValues, TransactionAdapter, TransactionAdapterClass, TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, UniqueConstraints, UniqueTableDataItem, UnknownColumn, UpdateData, UpsertData, UpsertThis, VarCharColumn, VirtualColumn, WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _onUpsertUpdate, _orCreate, _prependWith, _prependWithOnUpsertCreate, _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, constraintToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, indexToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry } from "./index.d.ts";
|
|
1
|
+
import { Adapter, AdapterClass, AdapterConfigBase, AdapterParams, AdapterSchemaConfigOptions, AfterCommitStandaloneHook, AfterHook, ArrayColumn, ArrayColumnValue, ArrayData, AsyncState, BaseNumberData, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, BoxColumn, BrandColumn, BrandColumnsShape, ByteaColumn, CidrColumn, CircleColumn, CitextColumn, Code, Codes, Column, ColumnFromDbParams, ColumnRefExpression, ColumnSchemaConfig, ColumnSchemaGetterColumns, ColumnSchemaGetterTableClass, ColumnToCodeCtx, ColumnTypeSchemaArg, ColumnsByType, ColumnsShape, ComputedColumnsFromOptions, ComputedOptionsConfig, ComputedOptionsFactory, CreateCtx, CreateData, CreateManyMethodsNames, CreateMethodsNames, CreateSelf, CustomTypeColumn, DateColumn, DateColumnData, DateColumnInput, DbDomainArg, DbExtension, DbOptions, DbResult, DbSharedOptions, DbSqlMethod, DbStructureDomainsMap, DbTableOptionScopes, DbTableOptions, DecimalColumn, DecimalColumnData, DefaultColumnTypes, DefaultPrivileges, DefaultSchemaConfig, DeleteMethodsNames, DomainColumn, DoublePrecisionColumn, DriverAdapter, DynamicRawSQL, EmptyObject, EmptyTuple, EnumColumn, Expression, ExpressionData, FromArg, FromResult, GeneratorIgnore, HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, IsQuery, IsolationLevel, JSONColumn, JSONTextColumn, JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, MapTableScopesOption, MaybeArray, MaybePromise, MergeQuery, MoneyColumn, NoPrimaryKeyOption, NonUniqDataItem, NumberColumnData, Operators, OperatorsArray, OperatorsDate, OperatorsJson, OperatorsNumber, OperatorsOrdinalText, OperatorsText, Ord, PathColumn, PickQueryInputType, PickQueryInternal, PickQueryQ, PickQueryRelations, PickQuerySelectableRelations, PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, QueryAfterHook, QueryBeforeActionHook, QueryBeforeHook, QueryData, QueryHasWhere, QueryHookUtils, QueryHooks, QueryInternal, QueryLogObject, QueryLogOptions, QueryLogger, QueryManyTake, QueryManyTakeOptional, QueryOrExpression, QueryResult, QueryResultRow, QueryReturnType, QuerySchema, QueryScopes, RawSql, RawSqlBase, RealColumn, RecordKeyTrue, RecordOptionalString, RecordString, RecordStringOrNumber, RecordUnknown, RelationConfigBase, RelationJoinQuery, RelationsBase, Rls, RlsPolicy, SchemaConfigFnWithOptions, SearchWeight, SelectSqlColumn, SelectableFromShape, SerialColumn, SerialColumnData, ShallowSimplify, ShapeUniqueColumns, SingleSql, SingleSqlItem, SmallIntColumn, SmallSerialColumn, Sql, SqlFn, SqlSessionState, StaticSQLArgs, StorageOptions, StringColumn, StringData, TableData, TableDataFn, TableDataInput, TableDataItem, TableDataItemsUniqueColumnTuples, TableDataItemsUniqueColumns, TableDataItemsUniqueConstraints, TableDataMethods, TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, Timestamps, ToSQLCtx, ToSqlValues, TransactionAdapter, TransactionAdapterClass, TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, UniqueConstraints, UniqueTableDataItem, UnknownColumn, UpdateData, UpsertData, UpsertThis, VarCharColumn, VirtualColumn, WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _onUpsertUpdate, _orCreate, _prependWith, _prependWithOnUpsertCreate, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertForEachFrom, _queryInsertMany, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, constraintToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, indexToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry } from "./index.d.ts";
|
|
2
2
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
3
3
|
import "node:util";
|
|
4
4
|
import "tagged-tag";
|
|
@@ -150,8 +150,10 @@ interface EnsureCount {
|
|
|
150
150
|
}
|
|
151
151
|
type EnsureCountItem = {
|
|
152
152
|
count: number;
|
|
153
|
+
message?: string;
|
|
153
154
|
} | {
|
|
154
155
|
jsonNotNull: string;
|
|
156
|
+
message?: string;
|
|
155
157
|
};
|
|
156
158
|
interface CteTableHooks {
|
|
157
159
|
[K: string]: CteTableHook;
|
|
@@ -300,6 +302,9 @@ type SimpleJoinItemNonSubQueryArgs = [{
|
|
|
300
302
|
[K: string]: string | Expression$1;
|
|
301
303
|
} | Expression$1 | true] | [leftColumn: string | Expression$1, rightColumn: string | Expression$1] | [leftColumn: string | Expression$1, op: string, rightColumn: string | Expression$1];
|
|
302
304
|
type JoinItemArgs = {
|
|
305
|
+
u?: true;
|
|
306
|
+
x: RawSql$1;
|
|
307
|
+
} | {
|
|
303
308
|
u?: true;
|
|
304
309
|
c?: Column$1.QueryColumns;
|
|
305
310
|
l: SubQueryForSql;
|
|
@@ -2172,7 +2177,7 @@ type WhereArg$1<T extends PickQuerySelectableRelations$1> = { [K in keyof T['__s
|
|
|
2172
2177
|
* db.table.where((q) => q.relation.count().equals(10))
|
|
2173
2178
|
* ```
|
|
2174
2179
|
*/
|
|
2175
|
-
type WhereQueryBuilder<T extends PickQueryRelations$1> = EmptyObject$1 extends T['relations'] ? { [K in keyof T]: K extends keyof Where | keyof QueryExpressions | 'table' | 'get' | 'columnTypes' | '__selectable' | 'relations' | 'useHelper' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then' ? T[K] : never; } : { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['query'] : K extends keyof T & (keyof Where | keyof QueryExpressions | 'table' | 'get' | 'columnTypes' | '__selectable' | 'relations' | 'useHelper' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then') ? T[K] : never; };
|
|
2180
|
+
type WhereQueryBuilder<T extends PickQueryRelations$1> = EmptyObject$1 extends T['relations'] ? { [K in keyof T]: K extends keyof Where | keyof QueryExpressions | 'table' | 'get' | 'columnTypes' | '__selectable' | 'relations' | 'useHelper' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then' | 'none' ? T[K] : never; } : { [K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K]['query'] : K extends keyof T & (keyof Where | keyof QueryExpressions | 'table' | 'get' | 'columnTypes' | '__selectable' | 'relations' | 'useHelper' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then' | 'none') ? T[K] : never; };
|
|
2176
2181
|
type WhereArgs<T extends PickQuerySelectableRelations$1> = WhereArg$1<T>[];
|
|
2177
2182
|
type WhereNotArgs<T extends PickQuerySelectableRelations$1> = [WhereArg$1<T>];
|
|
2178
2183
|
type WhereInColumn<T extends PickQuerySelectableRelations$1> = keyof T['__selectable'] | [keyof T['__selectable'], ...(keyof T['__selectable'])[]];
|
|
@@ -7530,9 +7535,8 @@ declare class UUIDColumn$1<Schema extends ColumnSchemaConfig$1> extends Column$1
|
|
|
7530
7535
|
T & {
|
|
7531
7536
|
data: {
|
|
7532
7537
|
primaryKey: Name;
|
|
7533
|
-
default: true;
|
|
7534
7538
|
};
|
|
7535
|
-
};
|
|
7539
|
+
} & Column$1.Data.Default;
|
|
7536
7540
|
toCode(ctx: ColumnToCodeCtx$1, key: string): Code$1;
|
|
7537
7541
|
}
|
|
7538
7542
|
declare class XMLColumn$1<Schema extends ColumnSchemaConfig$1> extends Column$1 {
|
|
@@ -7767,7 +7771,10 @@ interface QueryData$1 extends QueryDataAliases, PickQueryDataParsers, HasHookSel
|
|
|
7767
7771
|
wrapInTransaction?: boolean;
|
|
7768
7772
|
throwOnNotFound?: boolean;
|
|
7769
7773
|
cteThrowOnNotFound?: boolean;
|
|
7770
|
-
ensureCount?:
|
|
7774
|
+
ensureCount?: {
|
|
7775
|
+
expected: number;
|
|
7776
|
+
message?: string;
|
|
7777
|
+
};
|
|
7771
7778
|
with?: WithItems;
|
|
7772
7779
|
withShapes?: WithConfigs;
|
|
7773
7780
|
joinTo?: QueryDataJoinTo;
|
|
@@ -10023,4 +10030,4 @@ declare abstract class Column$1 {
|
|
|
10023
10030
|
*/
|
|
10024
10031
|
generated<T extends Column.Pick.Data>(this: T, ...args: StaticSQLArgs$1): Column.Generated<T>;
|
|
10025
10032
|
}
|
|
10026
|
-
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, type BrandColumn, type BrandColumnsShape, ByteaColumn, CannotMutateReadOnlyTableError, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnRefExpression, 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, DateColumn, type DateColumnData, type DateColumnInput, 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 ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, type NumberColumnData, Operators, type OperatorsArray, type OperatorsDate, type OperatorsJson, type OperatorsNumber, type OperatorsOrdinalText, type OperatorsText, OrchidOrmError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, type QueryHasWhere, 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 SelectSqlColumn, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StaticSQLArgs, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpdateSelf, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _onUpsertUpdate, _orCreate, _prependWith, _prependWithOnUpsertCreate, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertMany, _queryInsertManyFrom, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, constraintToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getForeignKeyTableInstance, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, indexToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|
|
10033
|
+
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, type BrandColumn, type BrandColumnsShape, ByteaColumn, CannotMutateReadOnlyTableError, CidrColumn, CircleColumn, CitextColumn, type Code, type Codes, Column, type ColumnFromDbParams, type ColumnRefExpression, 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, DateColumn, type DateColumnData, type DateColumnInput, 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 ExpressionData, type FromArg, type FromResult, type GeneratorIgnore, type Grant, type HookSelectValue, InetColumn, IntegerColumn, IntervalColumn, type IsQuery, type IsolationLevel, JSONColumn, JSONTextColumn, type JoinedShapes, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MaybeArray, type MaybePromise, type MergeQuery, MoneyColumn, type NoPrimaryKeyOption, type NonUniqDataItem, type NumberColumnData, Operators, type OperatorsArray, type OperatorsDate, type OperatorsJson, type OperatorsNumber, type OperatorsOrdinalText, type OperatorsText, OrchidOrmError, type Ord, PathColumn, type PickQueryInputType, type PickQueryInternal, type PickQueryQ, type PickQueryRelations, type PickQuerySelectableRelations, type PickQueryShape, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type QueryAfterHook, type QueryBeforeActionHook, type QueryBeforeHook, type QueryData, type QueryHasWhere, 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 SelectSqlColumn, type SelectableFromShape, SerialColumn, type SerialColumnData, type ShallowSimplify, type ShapeUniqueColumns, type SingleSql, type SingleSqlItem, SmallIntColumn, SmallSerialColumn, type Sql, type SqlFn, type SqlSessionState, type StaticSQLArgs, type StorageOptions, StringColumn, type StringData, type TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, type TemplateLiteralArgs, TextColumn, TimeColumn, TimestampColumn, TimestampTZColumn, type Timestamps, type ToSQLCtx, type ToSqlValues, type TransactionAdapter, TransactionAdapterClass, type TransactionOptions, TsQueryColumn, TsVectorColumn, UUIDColumn, type UniqueConstraints, type UniqueTableDataItem, UnknownColumn, type UpdateData, type UpdateSelf, type UpsertData, type UpsertThis, VarCharColumn, VirtualColumn, type WhereArg, XMLColumn, _appendQuery, _appendQueryOnUpsertCreate, _clone, _createDbSqlMethod, _hookSelectColumns, _initQueryBuilder, _onUpsertUpdate, _orCreate, _prependWith, _prependWithOnUpsertCreate, _queryCreate, _queryCreateMany, _queryCreateManyFrom, _queryDefaults, _queryDelete, _queryFindBy, _queryFindByOptional, _queryHookAfterCreate, _queryHookAfterUpdate, _queryInsert, _queryInsertForEachFrom, _queryInsertMany, _queryInsertManyFrom, _queryJoinOn, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUpdate, _queryUpdateOrThrow, _queryUpsert, _queryWhere, _queryWhereExists, _queryWhereIn, addCode, addTopCte, addTopCteSql, applyMixins, assignDbDataToColumn, backtickQuote, cloneQueryBaseUnscoped, codeToString, colors, columnsShapeToCode, constraintInnerToCode, constraintToCode, consumeColumnName, deepCompare, defaultSchemaConfig, emptyArray, emptyObject, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, exhaustive, getCallerFilePath, getClonedQueryData, getColumnBaseType, getColumnTypes, getDateAsDateFn, getDateAsNumberFn, getDriverErrorCode, getForeignKeyTableInstance, getFreeAlias, getFreeSetAlias, getImportPath, getPrimaryKeys, getQueryAs, getQuerySchema, getShapeFromSelect, getSqlText, getStackTrace, getSupportedDefaultPrivileges, indexInnerToCode, indexToCode, internalSchemaConfig, isExpression, isQueryReturnsAll, isRawSQL, logColors, logParamToLogObject, makeColumnNullable, makeColumnTypes, makeColumnsByType, makeConnectRetryConfig, noop, objectHasValues, omit, parseTableData, parseTableDataInput, pathToLog, pick, pluralize, prepareSubQueryForSql, primaryKeyInnerToCode, pushQueryOnForOuter, pushQueryValueImmutable, pushTableDataCode, queryToSql, quoteIdentifier, quoteObjectKey, quoteTableWithSchema, raw, rawSqlToCode, rawSqlToSql, referencesArgsToCode, returnArg, setColumnData, setColumnEncode, setColumnParse, setColumnParseNull, setCurrentColumnName, setDataValue, setDefaultLanguage, setFreeAlias, setQueryObjectValueImmutable, singleQuote, sqlToRawSql, tableDataMethods, toArray, toCamelCase, toPascalCase, toSnakeCase, wrapAdapterFnWithConnectRetry };
|
package/dist/internal.js
CHANGED
|
@@ -2733,7 +2733,8 @@ const processJoinItem = (ctx, table, query, args, quotedAs) => {
|
|
|
2733
2733
|
if (alias) target += ` ${alias}`;
|
|
2734
2734
|
if (r && s) target = subJoinToSql(ctx, j, `"${joinTable}"`, !forbidLateral, joinAs, true);
|
|
2735
2735
|
else on = whereToSql(ctx, j, j.q, joinAs);
|
|
2736
|
-
} else if ("
|
|
2736
|
+
} else if ("x" in args) target = args.x.makeSQL(ctx, quotedAs);
|
|
2737
|
+
else if ("w" in args) {
|
|
2737
2738
|
const { w } = args;
|
|
2738
2739
|
target = `"${w}"`;
|
|
2739
2740
|
if ("r" in args) {
|
|
@@ -3425,8 +3426,12 @@ const then = async (q, adapter, state, beforeHooks, afterHooks, afterSaveHooks,
|
|
|
3425
3426
|
} catch (err) {
|
|
3426
3427
|
let error;
|
|
3427
3428
|
if (err instanceof adapter.errorClass) {
|
|
3428
|
-
|
|
3429
|
-
|
|
3429
|
+
const code = getDriverErrorCode$1(err);
|
|
3430
|
+
const notFound = err.message.match(/"(.*):not-found:(\d+):(\d+)"$/);
|
|
3431
|
+
if (code === "22P02" && notFound) {
|
|
3432
|
+
const [, message, expected, actual] = notFound;
|
|
3433
|
+
error = Number(expected) === 1 && !message ? new NotFoundError(q) : new NotFoundError(q, `Expected to find at least ${expected} record(s)${message ? ` ${message}` : ""}, but found ${actual}`);
|
|
3434
|
+
} else {
|
|
3430
3435
|
error = new q.error();
|
|
3431
3436
|
adapter.assignError(error, err);
|
|
3432
3437
|
}
|
|
@@ -4307,7 +4312,10 @@ const moveMutativeQueryToCteBase = (toSql, ctx, query, type = query.q.type) => {
|
|
|
4307
4312
|
const addTableHook = (ctx, q, data, select, hookPurpose, dontAddTableHook) => {
|
|
4308
4313
|
if (data.ensureCount !== void 0 && ctx.cteName) {
|
|
4309
4314
|
const cteHooks = setCteHooks(ctx, true);
|
|
4310
|
-
(cteHooks.ensureCount ??= {})[ctx.cteName] = {
|
|
4315
|
+
(cteHooks.ensureCount ??= {})[ctx.cteName] = {
|
|
4316
|
+
count: data.ensureCount.expected,
|
|
4317
|
+
message: data.ensureCount.message
|
|
4318
|
+
};
|
|
4311
4319
|
}
|
|
4312
4320
|
const afterCreate = data.afterCreate;
|
|
4313
4321
|
const afterUpdate = data.afterUpdate;
|
|
@@ -4472,8 +4480,10 @@ const selectToSqlList = (ctx, table, query, quotedAs, hookSelect = query.hookSel
|
|
|
4472
4480
|
list.push(`${sql} "${as}"`);
|
|
4473
4481
|
if (jsonList) jsonList[as] = value.result.value;
|
|
4474
4482
|
aliases?.push(as);
|
|
4475
|
-
} else if (delayedRelationSelect && isRelationQuery(value))
|
|
4476
|
-
|
|
4483
|
+
} else if (delayedRelationSelect && isRelationQuery(value)) {
|
|
4484
|
+
if (delayedRelationSelect.query.q.type !== "delete") ctx.selectedCount--;
|
|
4485
|
+
setMutativeQueriesSelectRelationsSqlState(delayedRelationSelect, as, value);
|
|
4486
|
+
} else {
|
|
4477
4487
|
pushSubQuerySql(ctx, query, value, as, list, quotedAs, aliases);
|
|
4478
4488
|
if (jsonList) jsonList[as] = value.q.returnType === "value" || value.q.returnType === "valueOrThrow" ? value.q.expr?.result.value || value.result?.value : void 0;
|
|
4479
4489
|
}
|
|
@@ -5669,7 +5679,12 @@ const toSql = (table, type, topCtx, isSubSql, cteName, calledByThen, dontAddTabl
|
|
|
5669
5679
|
if (ctx.topCtx.cteHooks.hasSelect) {
|
|
5670
5680
|
if (prependedSelectParenthesis) result.text += ")";
|
|
5671
5681
|
const { tableHooks, ensureCount } = ctx.topCtx.cteHooks;
|
|
5672
|
-
const keyValues = [...tableHooks ? Object.entries(tableHooks).map(([cteName, data]) => `'${cteName}', (SELECT json_agg(${makeRowToJson(ctx, cteName, data.shape, false, true)}) FROM "${cteName}")`) : emptyArray$1, ...ensureCount ? Object.entries(ensureCount).map(([cteName, item]) =>
|
|
5682
|
+
const keyValues = [...tableHooks ? Object.entries(tableHooks).map(([cteName, data]) => `'${cteName}', (SELECT json_agg(${makeRowToJson(ctx, cteName, data.shape, false, true)}) FROM "${cteName}")`) : emptyArray$1, ...ensureCount ? Object.entries(ensureCount).map(([cteName, item]) => {
|
|
5683
|
+
const expected = "count" in item ? item.count : 1;
|
|
5684
|
+
const message = (item.message || "").replace(/'/g, "''");
|
|
5685
|
+
const notFound = "count" in item && item.count > 1 ? `(SELECT '${message}:not-found:${expected}:' || (SELECT count(*) FROM "${cteName}"))::int` : `(SELECT '${message}:not-found:${expected}:0')::int`;
|
|
5686
|
+
return `'#${cteName}', CASE WHEN ${"count" in item ? `(SELECT count(*) FROM "${cteName}") < ${item.count}` : `(SELECT "${cteName}"."${item.jsonNotNull}" FROM "${cteName}") IS NULL`} THEN ${notFound} END`;
|
|
5687
|
+
}) : emptyArray$1];
|
|
5673
5688
|
result.text += ` UNION ALL SELECT ${"NULL, ".repeat(ctx.selectedCount || 0)}json_build_object(${keyValues.join(", ")})`;
|
|
5674
5689
|
}
|
|
5675
5690
|
}
|
|
@@ -6604,6 +6619,12 @@ Object.defineProperty(exports, "_queryInsert", {
|
|
|
6604
6619
|
return src_index_ts._queryInsert;
|
|
6605
6620
|
}
|
|
6606
6621
|
});
|
|
6622
|
+
Object.defineProperty(exports, "_queryInsertForEachFrom", {
|
|
6623
|
+
enumerable: true,
|
|
6624
|
+
get: function() {
|
|
6625
|
+
return src_index_ts._queryInsertForEachFrom;
|
|
6626
|
+
}
|
|
6627
|
+
});
|
|
6607
6628
|
Object.defineProperty(exports, "_queryInsertMany", {
|
|
6608
6629
|
enumerable: true,
|
|
6609
6630
|
get: function() {
|