pqb 0.42.5 → 0.42.7
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 +7 -2
- package/dist/index.js +110 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -57
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -7833,10 +7833,14 @@ interface ColumnData extends ColumnDataBase {
|
|
|
7833
7833
|
compression?: string;
|
|
7834
7834
|
foreignKeys?: TableData.ColumnReferences[];
|
|
7835
7835
|
identity?: TableData.Identity;
|
|
7836
|
-
generated
|
|
7836
|
+
generated?: ColumnDataGenerated;
|
|
7837
|
+
}
|
|
7838
|
+
interface ColumnDataGenerated {
|
|
7839
|
+
toSQL(ctx: {
|
|
7837
7840
|
values: unknown[];
|
|
7838
7841
|
snakeCase: boolean | undefined;
|
|
7839
7842
|
}, quotedAs?: string): string;
|
|
7843
|
+
toCode(): string;
|
|
7840
7844
|
}
|
|
7841
7845
|
interface ColumnFromDbParams {
|
|
7842
7846
|
isNullable?: boolean;
|
|
@@ -8383,6 +8387,7 @@ declare const _queryExec: <T extends IsQuery>(q: T) => never;
|
|
|
8383
8387
|
declare const _queryFindBy: <T extends PickQueryMetaRelationsResult>(q: T, args: WhereArgs<T>) => SetQueryReturnsOne<WhereResult<T>>;
|
|
8384
8388
|
declare const _queryFindByOptional: <T extends PickQueryMetaRelationsResult>(q: T, args: WhereArgs<T>) => SetQueryReturnsOneOptional<WhereResult<T>>;
|
|
8385
8389
|
declare const _queryRows: <T extends PickQueryResult>(q: T) => SetQueryReturnsRows<T>;
|
|
8390
|
+
declare const getFullColumnTable: (q: IsQuery, column: string, index: number, as: string | getValueKey | undefined) => string;
|
|
8386
8391
|
|
|
8387
8392
|
type Arg = {
|
|
8388
8393
|
$queryBuilder: Query;
|
|
@@ -8506,4 +8511,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
|
|
|
8506
8511
|
*/
|
|
8507
8512
|
declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
|
|
8508
8513
|
|
|
8509
|
-
export { Adapter, type AdapterConfig, type AdapterOptions, type AddQueryDefaults, AfterCommitError, type AfterCommitErrorFulfilledResult, type AfterCommitErrorRejectedResult, type AfterCommitErrorResult, type AfterHook, type AggregateArgTypes, AggregateMethods, type AggregateOptions, type AliasOrTable, ArrayColumn, type ArrayColumnValue, type ArrayData, AsMethods, type AsQueryArg, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, type BooleanQueryColumn, BoxColumn, ByteaColumn, type ChangeCountArg, CidrColumn, CircleColumn, CitextColumn, Clear, type ClearStatement, type ColumnData, type ColumnFromDbParams, type ColumnInfoQueryData, ColumnRefExpression, ColumnType, type ColumnsByType, type ColumnsShape, type ColumnsShapeToNullableObject, type ColumnsShapeToObject, type ColumnsShapeToObjectArray, type ColumnsShapeToPluck, type CommonQueryData, ComputedColumn, type ComputedColumns, type ComputedColumnsFromOptions, type ComputedMethods, type ComputedOptionsFactory, type CopyOptions, type CopyQueryData, Create, type CreateBelongsToData, type CreateColumn, type CreateCtx, type CreateData, type CreateKind, type CreateMethodsNames, type CreateRelationsData, type CreateRelationsDataOmittingFKeys, type CreateResult, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbDomainArgRecord, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbTableConstructor, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultSchemaConfig, Delete, type DeleteArgs, type DeleteMethodsNames, type DeleteQueryData, type DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, type ExpressionOutput, FnExpression, type FnExpressionArgs, type FnExpressionArgsPairs, type FnExpressionArgsValue, For, type FromArg, FromMethods, type FromQuerySelf, type FromResult, type GeneratorIgnore, type GetArg, type GetColumnInfo, type GetResult, type GetResultOptional, type GetStringArg, type GroupArgs, type HandleResult, Having, type HavingItem, type HookAction, type HookSelectArg, type IdentityColumn, InetColumn, type InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsolationLevel, JSONColumn, JSONTextColumn, Join, type JoinArgToQuery, type JoinArgs, type JoinCallback, type JoinFirstArg, type JoinItem, type JoinItemArgs, type JoinLateralItem, type JoinLateralResult, type JoinQueryBuilder, type JoinQueryMethod, type JoinResult, type JoinedParsers, type JoinedShapes, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, type NumericColumns, type OnConflictMerge, OnConflictQueryBuilder, type OnConflictSet, type OnConflictTarget, OnMethods, type Operator, Operators, type OperatorsAny, type OperatorsArray, type OperatorsBoolean, type OperatorsDate, type OperatorsJson, type OperatorsNumber, type OperatorsText, type OperatorsTime, type OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, type OrderArg, type OrderArgSelf, type OrderArgs, type OrderItem, type OrderTsQueryConfig, type Over, PathColumn, type PickColumnData, type PickQueryBaseQuery, type PickQueryColumnTypes, type PickQueryDataShapeAndJoinedShapes, type PickQueryInternal, type PickQueryMetaRelations, type PickQueryMetaRelationsResult, type PickQueryMetaResultRelations, type PickQueryMetaResultRelationsWindows, type PickQueryMetaResultRelationsWindowsColumnTypes, type PickQueryMetaResultRelationsWithDataReturnType, type PickQueryMetaResultRelationsWithDataReturnTypeShape, type PickQueryMetaResultReturnTypeWithDataWindows, type PickQueryMetaResultReturnTypeWithDataWindowsTable, type PickQueryMetaShapeRelationsWithData, type PickQueryMetaTable, type PickQueryMetaTableShape, type PickQueryMetaTableShapeReturnTypeWithData, type PickQueryMetaWithData, type PickQueryMetaWithDataColumnTypes, type PickQueryQ, type PickQueryQAndBaseQuery, type PickQueryQAndInternal, type PickQueryRelations, type PickQueryRelationsWithData, type PickQueryResultColumnTypes, type PickQueryShapeResultSinglePrimaryKey, type PickQueryShapeSinglePrimaryKey, type PickQuerySinglePrimaryKey, type PickQueryWindows, type PickQueryWithData, type PickQueryWithDataColumnTypes, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type PostgisPoint, type Query, type QueryAfterHook, type QueryArraysResult, type QueryBatchResult, type QueryBeforeHook, type QueryComputedArg, type QueryData, type QueryDataFromItem, type QueryDataJoinTo, type QueryDefaultReturnData, QueryError, type QueryErrorName, QueryGet, type QueryGetSelf, type QueryHelperResult, QueryHooks, type QueryInternal, QueryLog, type QueryMetaHasSelect, type QueryMetaHasWhere, QueryMethods, type QueryOrExpression, type QueryOrExpressionBooleanOrNullResult, type QueryResult, type QueryScopeData, type QueryScopes, type QuerySourceItem, QueryUpsertOrCreate, RawSQL, RealColumn, type RecordOfColumnsShapeBase, RefExpression, type RelationConfigBase, type RelationConfigDataForCreate, type RelationJoinQuery, type RelationQueryBase, type RelationsBase, type RuntimeComputedQueryColumn, type SearchArg, SearchMethods, type SearchWeight, type SearchWeightRecord, Select, type SelectArg, type SelectArgs, type SelectAs, type SelectAsValue, type SelectItem, type SelectQueryData, type SelectSubQueryResult, type SelectableFromShape, type SelectableOfType, type SelectableOrExpression, type SelectableOrExpressionOfType, type SelectableOrExpressions, SerialColumn, type SerialColumnData, type SetQueryKind, type SetQueryKindResult, type SetQueryReturnsAll, type SetQueryReturnsAllKind, type SetQueryReturnsAllKindResult, type SetQueryReturnsColumnInfo, type SetQueryReturnsColumnKind, type SetQueryReturnsColumnKindResult, type SetQueryReturnsColumnOptional, type SetQueryReturnsColumnOrThrow, type SetQueryReturnsOne, type SetQueryReturnsOneKind, type SetQueryReturnsOneKindResult, type SetQueryReturnsOneOptional, type SetQueryReturnsPluck, type SetQueryReturnsPluckColumn, type SetQueryReturnsPluckColumnKind, type SetQueryReturnsPluckColumnKindResult, type SetQueryReturnsRowCount, type SetQueryReturnsRowCountMany, type SetQueryReturnsRows, type SetQueryReturnsValueOptional, type SetQueryReturnsValueOrThrow, type SetQueryReturnsVoid, type SetQueryReturnsVoidKind, type SetQueryTableAlias, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SimpleJoinItem, type SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, type SortDir, type SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, TextBaseColumn, TextColumn, type TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, type ToSQLCtx, type ToSQLOptions, type ToSQLQuery, Transaction, TransactionAdapter, type TransactionOptions, TransformMethods, type TruncateQueryData, TsQueryColumn, TsVectorColumn, type TypeParsers, UUIDColumn, UnhandledTypeError, Union, type UnionArgs, type UnionItem, type UnionKind, type UnionSet, type UniqueConstraints, type UniqueQueryTypeOrExpression, type UniqueTableDataItem, UnknownColumn, Update, type UpdateArg, type UpdateCtx, type UpdateCtxCollect, type UpdateData, type UpdateQueryData, type UpdateQueryDataItem, type UpdateQueryDataObject, type UpdateSelf, type UpdatedAtDataInjector, type UpsertResult, type UpsertThis, VarCharColumn, VirtualColumn, Where, type WhereArg, type WhereArgs, type WhereInArg, type WhereInColumn, type WhereInItem, type WhereInValues, type WhereItem, type WhereJsonPathEqualsItem, type WhereNotArgs, type WhereOnItem, type WhereOnJoinItem, type WhereQueryBuilder, type WhereResult, type WhereSearchItem, type WhereSearchResult, type WindowArg, type WindowArgDeclaration, type WindowDeclaration, type WindowItem, type WithArgsOptions, type WithConfigs, type WithDataItem, type WithDataItems, type WithItem, WithMethods, type WithOptions, type WithQueryBuilder, type WithRecursiveOptions, type WithResult, type WithSqlResult, type WrapQueryArg, XMLColumn, _afterCommitError, _clone, _getSelectableColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryResolveAlias, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, addColumnParserToQuery, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL, toSQLCacheKey };
|
|
8514
|
+
export { Adapter, type AdapterConfig, type AdapterOptions, type AddQueryDefaults, AfterCommitError, type AfterCommitErrorFulfilledResult, type AfterCommitErrorRejectedResult, type AfterCommitErrorResult, type AfterHook, type AggregateArgTypes, AggregateMethods, type AggregateOptions, type AliasOrTable, ArrayColumn, type ArrayColumnValue, type ArrayData, AsMethods, type AsQueryArg, BigIntColumn, BigSerialColumn, BitColumn, BitVaryingColumn, BooleanColumn, type BooleanQueryColumn, BoxColumn, ByteaColumn, type ChangeCountArg, CidrColumn, CircleColumn, CitextColumn, Clear, type ClearStatement, type ColumnData, type ColumnDataGenerated, type ColumnFromDbParams, type ColumnInfoQueryData, ColumnRefExpression, ColumnType, type ColumnsByType, type ColumnsShape, type ColumnsShapeToNullableObject, type ColumnsShapeToObject, type ColumnsShapeToObjectArray, type ColumnsShapeToPluck, type CommonQueryData, ComputedColumn, type ComputedColumns, type ComputedColumnsFromOptions, type ComputedMethods, type ComputedOptionsFactory, type CopyOptions, type CopyQueryData, Create, type CreateBelongsToData, type CreateColumn, type CreateCtx, type CreateData, type CreateKind, type CreateMethodsNames, type CreateRelationsData, type CreateRelationsDataOmittingFKeys, type CreateResult, type CreateSelf, CustomTypeColumn, DateBaseColumn, DateColumn, type DateColumnInput, DateTimeBaseClass, DateTimeTzBaseClass, Db, type DbDomainArg, type DbDomainArgRecord, type DbExtension, type DbOptions, type DbResult, type DbSharedOptions, type DbTableConstructor, type DbTableOptionScopes, type DbTableOptions, DecimalColumn, type DecimalColumnData, type DefaultColumnTypes, type DefaultSchemaConfig, Delete, type DeleteArgs, type DeleteMethodsNames, type DeleteQueryData, type DeleteResult, DomainColumn, DoublePrecisionColumn, DynamicRawSQL, EnumColumn, ExpressionMethods, type ExpressionOutput, FnExpression, type FnExpressionArgs, type FnExpressionArgsPairs, type FnExpressionArgsValue, For, type FromArg, FromMethods, type FromQuerySelf, type FromResult, type GeneratorIgnore, type GetArg, type GetColumnInfo, type GetResult, type GetResultOptional, type GetStringArg, type GroupArgs, type HandleResult, Having, type HavingItem, type HookAction, type HookSelectArg, type IdentityColumn, InetColumn, type InsertQueryData, IntegerBaseColumn, IntegerColumn, IntervalColumn, type IsolationLevel, JSONColumn, JSONTextColumn, Join, type JoinArgToQuery, type JoinArgs, type JoinCallback, type JoinFirstArg, type JoinItem, type JoinItemArgs, type JoinLateralItem, type JoinLateralResult, type JoinQueryBuilder, type JoinQueryMethod, type JoinResult, type JoinedParsers, type JoinedShapes, JsonMethods, LimitedTextBaseColumn, LineColumn, LsegColumn, MacAddr8Column, MacAddrColumn, type MapTableScopesOption, type MergeQuery, MergeQueryMethods, MoneyColumn, MoreThanOneRowError, type NoPrimaryKeyOption, type NonUniqDataItem, NotFoundError, NumberAsStringBaseColumn, NumberBaseColumn, type NumberColumnData, type NumericColumns, type OnConflictMerge, OnConflictQueryBuilder, type OnConflictSet, type OnConflictTarget, OnMethods, type Operator, Operators, type OperatorsAny, type OperatorsArray, type OperatorsBoolean, type OperatorsDate, type OperatorsJson, type OperatorsNumber, type OperatorsText, type OperatorsTime, type OrCreateArg, OrExpression, OrchidOrmError, OrchidOrmInternalError, type OrderArg, type OrderArgSelf, type OrderArgs, type OrderItem, type OrderTsQueryConfig, type Over, PathColumn, type PickColumnData, type PickQueryBaseQuery, type PickQueryColumnTypes, type PickQueryDataShapeAndJoinedShapes, type PickQueryInternal, type PickQueryMetaRelations, type PickQueryMetaRelationsResult, type PickQueryMetaResultRelations, type PickQueryMetaResultRelationsWindows, type PickQueryMetaResultRelationsWindowsColumnTypes, type PickQueryMetaResultRelationsWithDataReturnType, type PickQueryMetaResultRelationsWithDataReturnTypeShape, type PickQueryMetaResultReturnTypeWithDataWindows, type PickQueryMetaResultReturnTypeWithDataWindowsTable, type PickQueryMetaShapeRelationsWithData, type PickQueryMetaTable, type PickQueryMetaTableShape, type PickQueryMetaTableShapeReturnTypeWithData, type PickQueryMetaWithData, type PickQueryMetaWithDataColumnTypes, type PickQueryQ, type PickQueryQAndBaseQuery, type PickQueryQAndInternal, type PickQueryRelations, type PickQueryRelationsWithData, type PickQueryResultColumnTypes, type PickQueryShapeResultSinglePrimaryKey, type PickQueryShapeSinglePrimaryKey, type PickQuerySinglePrimaryKey, type PickQueryWindows, type PickQueryWithData, type PickQueryWithDataColumnTypes, PointColumn, PolygonColumn, PostgisGeographyPointColumn, type PostgisPoint, type Query, type QueryAfterHook, type QueryArraysResult, type QueryBatchResult, type QueryBeforeHook, type QueryComputedArg, type QueryData, type QueryDataFromItem, type QueryDataJoinTo, type QueryDefaultReturnData, QueryError, type QueryErrorName, QueryGet, type QueryGetSelf, type QueryHelperResult, QueryHooks, type QueryInternal, QueryLog, type QueryMetaHasSelect, type QueryMetaHasWhere, QueryMethods, type QueryOrExpression, type QueryOrExpressionBooleanOrNullResult, type QueryResult, type QueryScopeData, type QueryScopes, type QuerySourceItem, QueryUpsertOrCreate, RawSQL, RealColumn, type RecordOfColumnsShapeBase, RefExpression, type RelationConfigBase, type RelationConfigDataForCreate, type RelationJoinQuery, type RelationQueryBase, type RelationsBase, type RuntimeComputedQueryColumn, type SearchArg, SearchMethods, type SearchWeight, type SearchWeightRecord, Select, type SelectArg, type SelectArgs, type SelectAs, type SelectAsValue, type SelectItem, type SelectQueryData, type SelectSubQueryResult, type SelectableFromShape, type SelectableOfType, type SelectableOrExpression, type SelectableOrExpressionOfType, type SelectableOrExpressions, SerialColumn, type SerialColumnData, type SetQueryKind, type SetQueryKindResult, type SetQueryReturnsAll, type SetQueryReturnsAllKind, type SetQueryReturnsAllKindResult, type SetQueryReturnsColumnInfo, type SetQueryReturnsColumnKind, type SetQueryReturnsColumnKindResult, type SetQueryReturnsColumnOptional, type SetQueryReturnsColumnOrThrow, type SetQueryReturnsOne, type SetQueryReturnsOneKind, type SetQueryReturnsOneKindResult, type SetQueryReturnsOneOptional, type SetQueryReturnsPluck, type SetQueryReturnsPluckColumn, type SetQueryReturnsPluckColumnKind, type SetQueryReturnsPluckColumnKindResult, type SetQueryReturnsRowCount, type SetQueryReturnsRowCountMany, type SetQueryReturnsRows, type SetQueryReturnsValueOptional, type SetQueryReturnsValueOrThrow, type SetQueryReturnsVoid, type SetQueryReturnsVoidKind, type SetQueryTableAlias, type ShapeColumnPrimaryKeys, type ShapeUniqueColumns, type SimpleJoinItem, type SimpleJoinItemNonSubQueryArgs, SmallIntColumn, SmallSerialColumn, type SortDir, type SqlFn, SqlMethod, StringColumn$1 as StringColumn, TableData, type TableDataFn, type TableDataInput, type TableDataItem, type TableDataItemsUniqueColumnTuples, type TableDataItemsUniqueColumns, type TableDataItemsUniqueConstraints, type TableDataMethods, TextBaseColumn, TextColumn, type TextColumnData, Then, TimeColumn, TimestampColumn, TimestampTZColumn, type ToSQLCtx, type ToSQLOptions, type ToSQLQuery, Transaction, TransactionAdapter, type TransactionOptions, TransformMethods, type TruncateQueryData, TsQueryColumn, TsVectorColumn, type TypeParsers, UUIDColumn, UnhandledTypeError, Union, type UnionArgs, type UnionItem, type UnionKind, type UnionSet, type UniqueConstraints, type UniqueQueryTypeOrExpression, type UniqueTableDataItem, UnknownColumn, Update, type UpdateArg, type UpdateCtx, type UpdateCtxCollect, type UpdateData, type UpdateQueryData, type UpdateQueryDataItem, type UpdateQueryDataObject, type UpdateSelf, type UpdatedAtDataInjector, type UpsertResult, type UpsertThis, VarCharColumn, VirtualColumn, Where, type WhereArg, type WhereArgs, type WhereInArg, type WhereInColumn, type WhereInItem, type WhereInValues, type WhereItem, type WhereJsonPathEqualsItem, type WhereNotArgs, type WhereOnItem, type WhereOnJoinItem, type WhereQueryBuilder, type WhereResult, type WhereSearchItem, type WhereSearchResult, type WindowArg, type WindowArgDeclaration, type WindowDeclaration, type WindowItem, type WithArgsOptions, type WithConfigs, type WithDataItem, type WithDataItems, type WithItem, WithMethods, type WithOptions, type WithQueryBuilder, type WithRecursiveOptions, type WithResult, type WithSqlResult, type WrapQueryArg, XMLColumn, _afterCommitError, _clone, _getSelectableColumn, _initQueryBuilder, _queryAfterSaveCommit, _queryAll, _queryAs, _queryChangeCounter, _queryCreate, _queryCreateFrom, _queryCreateMany, _queryCreateManyFrom, _queryCreateManyRaw, _queryCreateRaw, _queryDefaults, _queryDelete, _queryExec, _queryFindBy, _queryFindByOptional, _queryGet, _queryGetOptional, _queryHookAfterCreate, _queryHookAfterCreateCommit, _queryHookAfterDelete, _queryHookAfterDeleteCommit, _queryHookAfterQuery, _queryHookAfterSave, _queryHookAfterUpdate, _queryHookAfterUpdateCommit, _queryHookBeforeCreate, _queryHookBeforeDelete, _queryHookBeforeQuery, _queryHookBeforeSave, _queryHookBeforeUpdate, _queryInsert, _queryInsertFrom, _queryInsertMany, _queryInsertManyFrom, _queryInsertManyRaw, _queryInsertRaw, _queryJoinOn, _queryJoinOnJsonPathEquals, _queryJoinOrOn, _queryOr, _queryOrNot, _queryResolveAlias, _queryRows, _querySelect, _queryTake, _queryTakeOptional, _queryUnion, _queryUpdate, _queryUpdateOrThrow, _queryUpdateRaw, _queryWhere, _queryWhereExists, _queryWhereIn, _queryWhereNot, _queryWhereNotOneOf, _queryWhereNotSql, _queryWhereOneOf, _queryWhereSql, addColumnParserToQuery, addParserForRawExpression, addParserForSelectItem, addQueryOn, anyShape, applyComputedColumns, checkIfASimpleQuery, cloneQuery, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, extendQuery, filterResult, foreignKeyArgumentToCode, getClonedQueryData, getColumnInfo, getColumnTypes, getFullColumnTable, getPrimaryKeys, getQueryAs, getShapeFromSelect, getSqlText, handleResult, identityToCode, indexInnerToCode, indexToCode, instantiateColumn, isDefaultTimeStamp, isQueryReturnsAll, isSelectingCount, joinSubQuery, logParamToLogObject, makeColumnTypes, makeColumnsByType, makeFnExpression, makeRegexToFindInSql, makeSQL, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArray, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValue, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallback, rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValue, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL, toSQLCacheKey };
|
package/dist/index.js
CHANGED
|
@@ -364,7 +364,21 @@ class ColumnType extends orchidCore.ColumnTypeBase {
|
|
|
364
364
|
*/
|
|
365
365
|
generated(...args) {
|
|
366
366
|
const sql = raw(...args);
|
|
367
|
-
return orchidCore.setColumnData(this, "generated",
|
|
367
|
+
return orchidCore.setColumnData(this, "generated", {
|
|
368
|
+
toSQL(ctx, quoted) {
|
|
369
|
+
return sql.toSQL(ctx, quoted);
|
|
370
|
+
},
|
|
371
|
+
toCode() {
|
|
372
|
+
let sql2 = ".generated";
|
|
373
|
+
if (Array.isArray(args[0])) {
|
|
374
|
+
sql2 += orchidCore.templateLiteralToSQL(args);
|
|
375
|
+
} else {
|
|
376
|
+
const { raw: raw2, values } = args[0];
|
|
377
|
+
sql2 += `({ raw: '${raw2.replace(/'/g, "\\'")}'${values ? `, values: ${JSON.stringify(values)}` : ""} })`;
|
|
378
|
+
}
|
|
379
|
+
return sql2;
|
|
380
|
+
}
|
|
381
|
+
});
|
|
368
382
|
}
|
|
369
383
|
}
|
|
370
384
|
|
|
@@ -728,6 +742,9 @@ const columnCode = (type, ctx, key, code) => {
|
|
|
728
742
|
} else {
|
|
729
743
|
code[0].unshift(prepend);
|
|
730
744
|
}
|
|
745
|
+
if (data.generated) {
|
|
746
|
+
orchidCore.addCode(code, data.generated.toCode());
|
|
747
|
+
}
|
|
731
748
|
if (data.primaryKey) {
|
|
732
749
|
orchidCore.addCode(
|
|
733
750
|
code,
|
|
@@ -1322,32 +1339,59 @@ class TsVectorColumn extends ColumnType {
|
|
|
1322
1339
|
* @param args
|
|
1323
1340
|
*/
|
|
1324
1341
|
generated(...args) {
|
|
1325
|
-
|
|
1342
|
+
const arg = args[0];
|
|
1343
|
+
if (typeof arg === "object" && "raw" in arg) {
|
|
1344
|
+
return super.generated(...args);
|
|
1345
|
+
}
|
|
1346
|
+
const toSQL = (ctx) => {
|
|
1326
1347
|
const first = args[0];
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1348
|
+
const target = typeof first === "string" ? args[1] : first;
|
|
1349
|
+
const language = typeof first === "string" ? first : this.defaultLanguage;
|
|
1350
|
+
const { snakeCase } = ctx;
|
|
1351
|
+
let sql;
|
|
1352
|
+
if (Array.isArray(target)) {
|
|
1353
|
+
const columns = target.length === 1 ? `"${snakeCase ? orchidCore.toSnakeCase(target[0]) : target[0]}"` : target.map(
|
|
1354
|
+
(column) => `coalesce("${snakeCase ? orchidCore.toSnakeCase(column) : column}", '')`
|
|
1355
|
+
).join(` || ' ' || `);
|
|
1356
|
+
sql = `to_tsvector('${language}', ${columns})`;
|
|
1357
|
+
} else {
|
|
1358
|
+
for (const key in target) {
|
|
1359
|
+
sql = (sql ? sql + " || " : "(") + `setweight(to_tsvector('${language}', coalesce("${snakeCase ? orchidCore.toSnakeCase(key) : key}", '')), '${target[key]}')`;
|
|
1360
|
+
}
|
|
1361
|
+
if (sql) {
|
|
1362
|
+
sql += ")";
|
|
1337
1363
|
} else {
|
|
1338
|
-
|
|
1339
|
-
sql = (sql ? sql + " || " : "(") + `setweight(to_tsvector('${language}', coalesce("${snakeCase ? orchidCore.toSnakeCase(key) : key}", '')), '${target[key]}')`;
|
|
1340
|
-
}
|
|
1341
|
-
if (sql) {
|
|
1342
|
-
sql += ")";
|
|
1343
|
-
} else {
|
|
1344
|
-
throw new Error("Empty target in the text search generated column");
|
|
1345
|
-
}
|
|
1364
|
+
throw new Error("Empty target in the text search generated column");
|
|
1346
1365
|
}
|
|
1347
|
-
|
|
1366
|
+
}
|
|
1367
|
+
return sql;
|
|
1368
|
+
};
|
|
1369
|
+
const toCode = () => {
|
|
1370
|
+
let code = ".generated(";
|
|
1371
|
+
const first = args[0];
|
|
1372
|
+
let target;
|
|
1373
|
+
if (typeof first === "string") {
|
|
1374
|
+
code += `'${first}', `;
|
|
1375
|
+
target = args[1];
|
|
1348
1376
|
} else {
|
|
1349
|
-
|
|
1377
|
+
target = args[0];
|
|
1350
1378
|
}
|
|
1379
|
+
if (Array.isArray(target)) {
|
|
1380
|
+
code += `[${target.map((x) => `'${x}'`).join(", ")}]`;
|
|
1381
|
+
} else {
|
|
1382
|
+
const pairs = [];
|
|
1383
|
+
for (const key in target) {
|
|
1384
|
+
pairs.push(
|
|
1385
|
+
`${orchidCore.quoteObjectKey(key)}: '${target[key]}'`
|
|
1386
|
+
);
|
|
1387
|
+
}
|
|
1388
|
+
code += `{ ${pairs.join(", ")} }`;
|
|
1389
|
+
}
|
|
1390
|
+
return code + ")";
|
|
1391
|
+
};
|
|
1392
|
+
return orchidCore.setColumnData(this, "generated", {
|
|
1393
|
+
toSQL,
|
|
1394
|
+
toCode
|
|
1351
1395
|
});
|
|
1352
1396
|
}
|
|
1353
1397
|
}
|
|
@@ -3289,6 +3333,10 @@ const _queryRows = (q) => {
|
|
|
3289
3333
|
q.q.returnType = "rows";
|
|
3290
3334
|
return q;
|
|
3291
3335
|
};
|
|
3336
|
+
const getFullColumnTable = (q, column, index, as) => {
|
|
3337
|
+
const table = column.slice(0, index);
|
|
3338
|
+
return as && table !== as && q.q.aliases?.[table] === as ? as : table;
|
|
3339
|
+
};
|
|
3292
3340
|
|
|
3293
3341
|
const _join = (query, require, type, first, args) => {
|
|
3294
3342
|
var _a;
|
|
@@ -5056,43 +5104,43 @@ const setParserForSelectedString = (q, arg, as, columnAs) => {
|
|
|
5056
5104
|
var _a, _b;
|
|
5057
5105
|
const index = arg.indexOf(".");
|
|
5058
5106
|
if (index !== -1) {
|
|
5059
|
-
const table =
|
|
5107
|
+
const table = getFullColumnTable(q, arg, index, as);
|
|
5060
5108
|
const column = arg.slice(index + 1);
|
|
5061
5109
|
if (column === "*") {
|
|
5062
5110
|
addParsersForSelectJoined(q, table, columnAs);
|
|
5063
5111
|
return table === as ? column : arg;
|
|
5064
|
-
}
|
|
5112
|
+
}
|
|
5113
|
+
if (table === as) {
|
|
5065
5114
|
if (columnAs) {
|
|
5066
|
-
const
|
|
5067
|
-
if (
|
|
5115
|
+
const parser2 = q.q.parsers?.[column];
|
|
5116
|
+
if (parser2) q.q.parsers[columnAs] = parser2;
|
|
5068
5117
|
}
|
|
5069
5118
|
return handleComputed(q, q.q.computeds, column);
|
|
5070
|
-
}
|
|
5071
|
-
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
}
|
|
5119
|
+
}
|
|
5120
|
+
const parser = q.q.joinedParsers?.[table]?.[column];
|
|
5121
|
+
if (parser) orchidCore.setParserToQuery(q.q, columnAs || column, parser);
|
|
5122
|
+
const batchParsers = q.q.joinedBatchParsers?.[table];
|
|
5123
|
+
if (batchParsers) {
|
|
5124
|
+
for (const bp of batchParsers) {
|
|
5125
|
+
if (bp.path[0] === column) {
|
|
5126
|
+
((_a = q.q).batchParsers ?? (_a.batchParsers = [])).push(bp);
|
|
5079
5127
|
}
|
|
5080
5128
|
}
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
|
-
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5087
|
-
}
|
|
5088
|
-
q.q.selectedComputeds = {
|
|
5089
|
-
...q.q.selectedComputeds,
|
|
5090
|
-
[column]: computed
|
|
5091
|
-
};
|
|
5092
|
-
return;
|
|
5129
|
+
}
|
|
5130
|
+
const computeds = q.q.joinedComputeds?.[table];
|
|
5131
|
+
if (computeds?.[column]) {
|
|
5132
|
+
const computed = computeds[column];
|
|
5133
|
+
const map = (_b = q.q).hookSelect ?? (_b.hookSelect = /* @__PURE__ */ new Map());
|
|
5134
|
+
for (const column2 of computed.deps) {
|
|
5135
|
+
map.set(column2, { select: `${table}.${column2}` });
|
|
5093
5136
|
}
|
|
5094
|
-
|
|
5137
|
+
q.q.selectedComputeds = {
|
|
5138
|
+
...q.q.selectedComputeds,
|
|
5139
|
+
[column]: computed
|
|
5140
|
+
};
|
|
5141
|
+
return;
|
|
5095
5142
|
}
|
|
5143
|
+
return arg;
|
|
5096
5144
|
} else {
|
|
5097
5145
|
if (columnAs) {
|
|
5098
5146
|
const parser = q.q.parsers?.[arg];
|
|
@@ -5168,9 +5216,10 @@ const getShapeFromSelect = (q, isSubQuery) => {
|
|
|
5168
5216
|
const addColumnToShapeFromSelect = (q, arg, shape, query, result, isSubQuery, key) => {
|
|
5169
5217
|
const index = arg.indexOf(".");
|
|
5170
5218
|
if (index !== -1) {
|
|
5171
|
-
const
|
|
5219
|
+
const as = q.q.as || q.table;
|
|
5220
|
+
const table = getFullColumnTable(q, arg, index, as);
|
|
5172
5221
|
const column = arg.slice(index + 1);
|
|
5173
|
-
if (table ===
|
|
5222
|
+
if (table === as) {
|
|
5174
5223
|
result[key || column] = shape[column];
|
|
5175
5224
|
} else {
|
|
5176
5225
|
const it = query.joinedShapes?.[table]?.[column];
|
|
@@ -5264,9 +5313,10 @@ const _getSelectableColumn = (q, arg) => {
|
|
|
5264
5313
|
if (!type) {
|
|
5265
5314
|
const index = arg.indexOf(".");
|
|
5266
5315
|
if (index !== -1) {
|
|
5267
|
-
const
|
|
5316
|
+
const as = q.q.as || q.table;
|
|
5317
|
+
const table = getFullColumnTable(q, arg, index, as);
|
|
5268
5318
|
const column = arg.slice(index + 1);
|
|
5269
|
-
if (table ===
|
|
5319
|
+
if (table === as) {
|
|
5270
5320
|
type = q.shape[column];
|
|
5271
5321
|
} else {
|
|
5272
5322
|
type = q.q.joinedShapes?.[table]?.[column];
|
|
@@ -11185,9 +11235,10 @@ class ExpressionMethods {
|
|
|
11185
11235
|
let column;
|
|
11186
11236
|
const index = arg.indexOf(".");
|
|
11187
11237
|
if (index !== -1) {
|
|
11188
|
-
const
|
|
11238
|
+
const as = q.q.as || q.table;
|
|
11239
|
+
const table = getFullColumnTable(q, arg, index, as);
|
|
11189
11240
|
const col = arg.slice(index + 1);
|
|
11190
|
-
if (table ===
|
|
11241
|
+
if (table === as) {
|
|
11191
11242
|
column = shape[col];
|
|
11192
11243
|
} else {
|
|
11193
11244
|
column = q.q.joinedShapes[table][col];
|
|
@@ -11869,9 +11920,12 @@ class QueryMethods {
|
|
|
11869
11920
|
* @param fn - helper function
|
|
11870
11921
|
*/
|
|
11871
11922
|
makeHelper(fn) {
|
|
11923
|
+
const as = this.q.as || this.table;
|
|
11872
11924
|
return (query, ...args) => {
|
|
11873
11925
|
const q = _clone(query);
|
|
11874
|
-
q.q.as
|
|
11926
|
+
if (q.q.as) {
|
|
11927
|
+
setQueryObjectValue(q, "aliases", as, q.q.as);
|
|
11928
|
+
}
|
|
11875
11929
|
return fn(q, ...args);
|
|
11876
11930
|
};
|
|
11877
11931
|
}
|
|
@@ -12683,6 +12737,7 @@ exports.foreignKeyArgumentToCode = foreignKeyArgumentToCode;
|
|
|
12683
12737
|
exports.getClonedQueryData = getClonedQueryData;
|
|
12684
12738
|
exports.getColumnInfo = getColumnInfo;
|
|
12685
12739
|
exports.getColumnTypes = getColumnTypes;
|
|
12740
|
+
exports.getFullColumnTable = getFullColumnTable;
|
|
12686
12741
|
exports.getPrimaryKeys = getPrimaryKeys;
|
|
12687
12742
|
exports.getQueryAs = getQueryAs;
|
|
12688
12743
|
exports.getShapeFromSelect = getShapeFromSelect;
|