pqb 0.51.0 → 0.51.1
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 +18 -8
- package/dist/index.js +69 -86
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +69 -86
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PoolConfig, Pool, PoolClient } from 'pg';
|
|
2
2
|
import * as orchid_core from 'orchid-core';
|
|
3
|
-
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, IsQuery, PickQueryMetaReturnType, RecordUnknown, Expression, MaybeArray, ColumnTypesBase, TemplateLiteralArgs, EmptyObject, QueryColumns, QueryColumn, MaybePromise, FnUnknownToUnknown, QueryMetaBase, QueryReturnType, RecordString, ColumnsShapeBase, ColumnsParsers, PickQueryTable, HookSelect, BatchParsers, QueryLogObject, QueryLogger, QueryDataTransform, ExpressionChain, PickQueryShape, ColumnSchemaConfig, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, ExpressionData, StaticSQLArgs, SQLQueryArgs, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, QueryThenByQuery, ColumnShapeInput, SelectableBase, PickQueryMetaShape, PickQueryTableMetaResultShape, PickQueryMetaResultWindows, PickOutputTypeAndOperators, PickQueryResult, ValExpression, PickOutputType, QueryThen, DateColumnData, ColumnToCodeCtx, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ColumnTypeBase, ParseColumn, ParseNullColumn, EncodeColumn, QueryColumnsInit, QueryLogOptions, DefaultSelectColumns, DefaultSelectOutput, QueryThenShallowSimplifyArr, QueryCatch, TransactionState, QueryColumnOfDataType, PickQueryUniqueProperties, PickQueryMetaResult, PickQueryTableMetaResultInputType, UnionToIntersection, getValueKey, QueryThenByReturnType, QueryMetaIsSubQuery, PickQueryReturnType, QueryReturnTypeAll, QueryReturnTypeOptional, QueryThenShallowSimplifyOptional, QueryThenShallowSimplify, PickQueryResultReturnType, PickQueryResultReturnTypeUniqueColumns, QueryInternalBase, PickType, RecordKeyTrue, ColumnShapeOutput, OperatorsNullable, UniqueColumn, TimestampHelpers, ShallowSimplify, Codes, ColumnDataCheckBase } from 'orchid-core';
|
|
3
|
+
import { QueryResultRow, AdapterConfigBase, AdapterBase, QueryInput, SingleSqlItem, Sql, IsQuery, PickQueryMetaReturnType, RecordUnknown, Expression, MaybeArray, ColumnTypesBase, TemplateLiteralArgs, EmptyObject, QueryColumns, QueryColumn, MaybePromise, FnUnknownToUnknown, QueryMetaBase, QueryReturnType, RecordString, ColumnsShapeBase, ColumnsParsers, PickQueryTable, HookSelect, BatchParsers, QueryLogObject, QueryLogger, QueryDataTransform, ExpressionChain, PickQueryShape, ColumnSchemaConfig, RawSQLBase, RawSQLValues, ExpressionTypeMethod, DynamicSQLArg, ExpressionData, StaticSQLArgs, SQLQueryArgs, PickQueryTableMetaResult, EmptyTuple, PickQueryMeta, PickQueryMetaResultReturnType, QueryColumnToNullable, QueryThenByQuery, ColumnShapeInput, SelectableBase, PickQueryMetaShape, PickQueryTableMetaResultShape, PickQueryMetaResultWindows, PickOutputTypeAndOperators, PickQueryResult, ValExpression, PickOutputType, QueryThen, DateColumnData, ColumnToCodeCtx, Code, TimeInterval, ColumnTypeSchemaArg, ColumnDataBase, ArrayMethodsData, ForeignKeyTable, ColumnNameOfTable, BaseNumberData, PickColumnBaseData, ColumnWithDefault, StringTypeData, PrimaryKeyColumn, ColumnTypeBase, ParseColumn, ParseNullColumn, EncodeColumn, QueryColumnsInit, QueryLogOptions, DefaultSelectColumns, DefaultSelectOutput, QueryThenShallowSimplifyArr, QueryCatch, TransactionState, QueryColumnOfDataType, PickQueryUniqueProperties, PickQueryMetaResult, PickQueryTableMetaResultInputType, UnionToIntersection, getValueKey, QueryThenByReturnType, QueryMetaIsSubQuery, PickQueryReturnType, QueryReturnTypeAll, QueryReturnTypeOptional, QueryThenShallowSimplifyOptional, QueryThenShallowSimplify, PickQueryResultReturnType, PickQueryResultReturnTypeUniqueColumns, PickQueryTableMetaShape, QueryInternalBase, PickType, RecordKeyTrue, ColumnShapeOutput, OperatorsNullable, UniqueColumn, TimestampHelpers, ShallowSimplify, Codes, ColumnDataCheckBase } from 'orchid-core';
|
|
4
4
|
import { inspect } from 'node:util';
|
|
5
5
|
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
6
6
|
|
|
@@ -257,8 +257,10 @@ declare module 'orchid-core' {
|
|
|
257
257
|
computed?: Expression;
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
type ComputedColumnsFromOptions<T extends ComputedOptionsFactory<never, never> | undefined> = T extends (...args: any[]) =>
|
|
261
|
-
[K
|
|
260
|
+
type ComputedColumnsFromOptions<T extends ComputedOptionsFactory<never, never> | undefined> = T extends ((...args: any[]) => infer R extends {
|
|
261
|
+
[K: string]: QueryOrExpression<unknown>;
|
|
262
|
+
}) ? {
|
|
263
|
+
[K in keyof R]: R[K]['result']['value'];
|
|
262
264
|
} : EmptyObject;
|
|
263
265
|
type ComputedOptionsFactory<ColumnTypes, Shape extends QueryColumns> = (t: ComputedMethods<ColumnTypes, Shape>) => {
|
|
264
266
|
[K: string]: QueryOrExpression<unknown>;
|
|
@@ -1915,9 +1917,9 @@ type WhereArg<T extends PickQueryMetaRelations> = {
|
|
|
1915
1917
|
* ```
|
|
1916
1918
|
*/
|
|
1917
1919
|
type WhereQueryBuilder<T extends PickQueryRelations> = EmptyObject extends T['relations'] ? {
|
|
1918
|
-
[K in keyof T]: K extends keyof Where | keyof ExpressionMethods | 'get' | 'columnTypes' | 'meta' | 'relations' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then' ? T[K] : never;
|
|
1920
|
+
[K in keyof T]: K extends keyof Where | keyof ExpressionMethods | 'table' | 'get' | 'columnTypes' | 'meta' | 'relations' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then' ? T[K] : never;
|
|
1919
1921
|
} : {
|
|
1920
|
-
[K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K] : K extends keyof T & (keyof Where | keyof ExpressionMethods | 'get' | 'columnTypes' | 'meta' | 'relations' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then') ? T[K] : never;
|
|
1922
|
+
[K in keyof T['relations'] | keyof T]: K extends keyof T['relations'] ? T['relations'][K] : K extends keyof T & (keyof Where | keyof ExpressionMethods | 'table' | 'get' | 'columnTypes' | 'meta' | 'relations' | 'modify' | 'result' | 'returnType' | 'withData' | 'windows' | 'then') ? T[K] : never;
|
|
1921
1923
|
};
|
|
1922
1924
|
type WhereArgs<T extends PickQueryMetaRelations> = WhereArg<T>[];
|
|
1923
1925
|
type WhereNotArgs<T extends PickQueryMetaRelations> = [WhereArg<T>];
|
|
@@ -7176,11 +7178,16 @@ interface QueryHelperQuery<T extends PickQueryMetaShape> {
|
|
|
7176
7178
|
}
|
|
7177
7179
|
interface IsQueryHelper {
|
|
7178
7180
|
isQueryHelper: true;
|
|
7181
|
+
table: string | undefined;
|
|
7179
7182
|
args: unknown[];
|
|
7180
7183
|
result: unknown;
|
|
7181
7184
|
}
|
|
7182
|
-
interface
|
|
7185
|
+
interface IsQueryHelperForTable<Table extends string | undefined> extends IsQueryHelper {
|
|
7186
|
+
table: Table;
|
|
7187
|
+
}
|
|
7188
|
+
interface QueryHelper<T extends PickQueryTableMetaShape, Args extends any[], Result> extends IsQueryHelper {
|
|
7183
7189
|
<Q extends QueryHelperQuery<T>>(q: Q, ...args: Args): Result extends PickQueryMetaResultReturnTypeWithDataWindowsThen ? MergeQuery<Q, Result> : Result;
|
|
7190
|
+
table: T['table'];
|
|
7184
7191
|
args: Args;
|
|
7185
7192
|
result: Result;
|
|
7186
7193
|
}
|
|
@@ -7761,7 +7768,7 @@ declare class QueryMethods<ColumnTypes> {
|
|
|
7761
7768
|
*
|
|
7762
7769
|
* @param fn - function to modify the query with. The result type will be merged with the main query as if the `merge` method was used.
|
|
7763
7770
|
*/
|
|
7764
|
-
modify<T extends
|
|
7771
|
+
modify<T extends PickQueryTableMetaResultReturnTypeWithDataWindowsThen, Fn extends IsQueryHelperForTable<T['table']>>(this: T, fn: Fn, ...args: Fn['args']): Fn['result'] extends PickQueryMetaResultReturnTypeWithDataWindowsThen ? MergeQuery<T, Fn['result']> : Fn['result'];
|
|
7765
7772
|
/**
|
|
7766
7773
|
* Narrows a part of the query output type.
|
|
7767
7774
|
* Use with caution, type-safety isn't guaranteed with it.
|
|
@@ -7963,6 +7970,8 @@ interface PickQueryMetaResultReturnTypeWithDataWindows extends PickQueryMetaResu
|
|
|
7963
7970
|
interface PickQueryMetaResultReturnTypeWithDataWindowsThen extends PickQueryMetaResultReturnTypeWithDataWindows {
|
|
7964
7971
|
then: unknown;
|
|
7965
7972
|
}
|
|
7973
|
+
interface PickQueryTableMetaResultReturnTypeWithDataWindowsThen extends PickQueryMetaResultReturnTypeWithDataWindowsThen, PickQueryTable {
|
|
7974
|
+
}
|
|
7966
7975
|
interface PickQueryQAndInternal extends PickQueryQ, PickQueryInternal {
|
|
7967
7976
|
}
|
|
7968
7977
|
interface PickQueryQAndBaseQuery extends PickQueryQ, PickQueryBaseQuery {
|
|
@@ -8649,6 +8658,7 @@ declare abstract class VirtualColumn<Schema extends ColumnSchemaConfig, InputSch
|
|
|
8649
8658
|
|
|
8650
8659
|
declare class UnknownColumn<Schema extends ColumnSchemaConfig> extends VirtualColumn<Schema> {
|
|
8651
8660
|
static instance: UnknownColumn<DefaultSchemaConfig>;
|
|
8661
|
+
selectable: boolean;
|
|
8652
8662
|
constructor(schema: Schema);
|
|
8653
8663
|
}
|
|
8654
8664
|
|
|
@@ -8868,4 +8878,4 @@ type CopyResult<T extends PickQueryMeta> = SetQueryKind<T, 'copy'>;
|
|
|
8868
8878
|
*/
|
|
8869
8879
|
declare function copyTableData<T extends PickQueryMetaShape>(query: T, arg: CopyArg<T>): CopyResult<T>;
|
|
8870
8880
|
|
|
8871
|
-
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 GeneratedColumn, 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 JoinResultRequireMain, 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 PickQueryMetaColumnTypes, type PickQueryMetaRelations, type PickQueryMetaRelationsResult, type PickQueryMetaRelationsResultReturnType, type PickQueryMetaRelationsReturnType, type PickQueryMetaResultRelations, type PickQueryMetaResultRelationsWindows, type PickQueryMetaResultRelationsWindowsColumnTypes, type PickQueryMetaResultRelationsWithDataReturnType, type PickQueryMetaResultRelationsWithDataReturnTypeShape, type PickQueryMetaResultReturnTypeWithDataWindows, type PickQueryMetaResultReturnTypeWithDataWindowsThen, type PickQueryMetaShapeRelationsReturnType, 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 PickQueryShapeResultReturnTypeSinglePrimaryKey, 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 QueryIfResultThen, type QueryInternal, QueryLog, type QueryMetaHasSelect, type QueryMetaHasWhere, QueryMethods, type QueryOrExpression, type QueryOrExpressionBooleanOrNullResult, type QueryResult, type QueryScopeData, type QueryScopes, type QuerySourceItem, type QueryTake, type QueryTakeOptional, 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 SetQueryReturnsOneKind, type SetQueryReturnsOneKindResult, 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, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnExcludesToCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, 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, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArrayImmutable, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValueImmutable, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallbackV2, rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValueImmutable, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL };
|
|
8881
|
+
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 GeneratedColumn, 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 JoinResultRequireMain, 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 PickQueryMetaColumnTypes, type PickQueryMetaRelations, type PickQueryMetaRelationsResult, type PickQueryMetaRelationsResultReturnType, type PickQueryMetaRelationsReturnType, type PickQueryMetaResultRelations, type PickQueryMetaResultRelationsWindows, type PickQueryMetaResultRelationsWindowsColumnTypes, type PickQueryMetaResultRelationsWithDataReturnType, type PickQueryMetaResultRelationsWithDataReturnTypeShape, type PickQueryMetaResultReturnTypeWithDataWindows, type PickQueryMetaResultReturnTypeWithDataWindowsThen, type PickQueryMetaShapeRelationsReturnType, 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 PickQueryShapeResultReturnTypeSinglePrimaryKey, type PickQueryShapeResultSinglePrimaryKey, type PickQueryShapeSinglePrimaryKey, type PickQuerySinglePrimaryKey, type PickQueryTableMetaResultReturnTypeWithDataWindowsThen, 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 QueryIfResultThen, type QueryInternal, QueryLog, type QueryMetaHasSelect, type QueryMetaHasWhere, QueryMethods, type QueryOrExpression, type QueryOrExpressionBooleanOrNullResult, type QueryResult, type QueryScopeData, type QueryScopes, type QuerySourceItem, type QueryTake, type QueryTakeOptional, 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 SetQueryReturnsOneKind, type SetQueryReturnsOneKindResult, 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, cloneQueryBaseUnscoped, columnCheckToCode, columnCode, columnExcludesToCode, columnForeignKeysToCode, columnIndexesToCode, columnsShapeToCode, commitSql, constraintInnerToCode, constraintToCode, copyTableData, countSelect, createDb, defaultSchemaConfig, escapeForLog, escapeForMigration, escapeString, excludeInnerToCode, excludeToCode, 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, parseRecord, parseTableData, parseTableDataInput, postgisTypmodToSql, primaryKeyInnerToCode, processComputedBatches, processComputedResult, processSelectArg, pushLimitSQL, pushQueryArrayImmutable, pushQueryOn, pushQueryOnForOuter, pushQueryOrOn, pushQueryValueImmutable, pushTableDataCode, queryFrom, queryFromSql, queryJson, queryMethodByReturnType, queryTypeWithLimitOne, queryWrap, raw, referencesArgsToCode, resolveSubQueryCallbackV2, rollbackSql, saveSearchAlias, setColumnDefaultParse, setColumnEncode, setColumnParse, setColumnParseNull, setParserForSelectedString, setQueryObjectValueImmutable, setQueryOperators, simplifyColumnDefault, sqlFn, sqlQueryArgsToExpression, tableDataMethods, templateLiteralToSQL, testTransaction, throwIfJoinLateral, throwIfNoWhere, toSQL };
|
package/dist/index.js
CHANGED
|
@@ -2001,18 +2001,14 @@ const getFullColumnTable = (q, column, index, as) => {
|
|
|
2001
2001
|
return as && table !== as && q.q.aliases?.[table] === as ? as : table;
|
|
2002
2002
|
};
|
|
2003
2003
|
|
|
2004
|
-
|
|
2005
|
-
addColumnParserToQuery(q, as, computed.result.value);
|
|
2006
|
-
return computed.toSQL(ctx, quotedAs);
|
|
2007
|
-
};
|
|
2008
|
-
function simpleColumnToSQL(ctx, q, key, column, quotedAs) {
|
|
2004
|
+
function simpleColumnToSQL(ctx, key, column, quotedAs) {
|
|
2009
2005
|
if (!column) return `"${key}"`;
|
|
2010
2006
|
const { data } = column;
|
|
2011
|
-
return data.computed ?
|
|
2007
|
+
return data.computed ? data.computed.toSQL(ctx, quotedAs) : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
2012
2008
|
}
|
|
2013
|
-
function simpleExistingColumnToSQL(ctx,
|
|
2009
|
+
function simpleExistingColumnToSQL(ctx, key, column, quotedAs) {
|
|
2014
2010
|
const { data } = column;
|
|
2015
|
-
return data.computed ?
|
|
2011
|
+
return data.computed ? data.computed.toSQL(ctx, quotedAs) : `${quotedAs ? `${quotedAs}.` : ""}"${data.name || key}"`;
|
|
2016
2012
|
}
|
|
2017
2013
|
const columnToSql = (ctx, data, shape, column, quotedAs, select) => {
|
|
2018
2014
|
const index = column.indexOf(".");
|
|
@@ -2030,7 +2026,7 @@ const columnToSql = (ctx, data, shape, column, quotedAs, select) => {
|
|
|
2030
2026
|
if (!select && data.joinedShapes?.[column]) {
|
|
2031
2027
|
return `"${column}".r`;
|
|
2032
2028
|
}
|
|
2033
|
-
return simpleColumnToSQL(ctx,
|
|
2029
|
+
return simpleColumnToSQL(ctx, column, shape[column], quotedAs);
|
|
2034
2030
|
};
|
|
2035
2031
|
const maybeSelectedColumnToSql = (ctx, data, column, quotedAs) => {
|
|
2036
2032
|
const index = column.indexOf(".");
|
|
@@ -2044,12 +2040,12 @@ const maybeSelectedColumnToSql = (ctx, data, column, quotedAs) => {
|
|
|
2044
2040
|
for (const s of data.select) {
|
|
2045
2041
|
if (typeof s === "object" && "selectAs" in s) {
|
|
2046
2042
|
if (column in s.selectAs) {
|
|
2047
|
-
return simpleColumnToSQL(ctx,
|
|
2043
|
+
return simpleColumnToSQL(ctx, column, data.shape[column]);
|
|
2048
2044
|
}
|
|
2049
2045
|
}
|
|
2050
2046
|
}
|
|
2051
2047
|
}
|
|
2052
|
-
return simpleColumnToSQL(ctx,
|
|
2048
|
+
return simpleColumnToSQL(ctx, column, data.shape[column], quotedAs);
|
|
2053
2049
|
}
|
|
2054
2050
|
};
|
|
2055
2051
|
const columnWithDotToSql = (ctx, data, shape, column, index, quotedAs, select) => {
|
|
@@ -2067,7 +2063,7 @@ const columnWithDotToSql = (ctx, data, shape, column, index, quotedAs, select) =
|
|
|
2067
2063
|
return `"${tableName}"."${col.data.name}"`;
|
|
2068
2064
|
}
|
|
2069
2065
|
if (col.data.computed) {
|
|
2070
|
-
return
|
|
2066
|
+
return col.data.computed.toSQL(ctx, quoted);
|
|
2071
2067
|
}
|
|
2072
2068
|
return `"${tableName}"."${key}"`;
|
|
2073
2069
|
}
|
|
@@ -2107,13 +2103,7 @@ const tableColumnToSqlWithAs = (ctx, data, column, table, key, as, quotedAs, sel
|
|
|
2107
2103
|
return `"${tableName}"."${col.data.name}" "${as}"`;
|
|
2108
2104
|
}
|
|
2109
2105
|
if (col.data.computed) {
|
|
2110
|
-
return `${
|
|
2111
|
-
ctx,
|
|
2112
|
-
data,
|
|
2113
|
-
col.data.computed,
|
|
2114
|
-
as,
|
|
2115
|
-
quoted
|
|
2116
|
-
)} "${as}"`;
|
|
2106
|
+
return `${col.data.computed.toSQL(ctx, quoted)} "${as}"`;
|
|
2117
2107
|
}
|
|
2118
2108
|
}
|
|
2119
2109
|
return `"${tableName}"."${key}"${key === as ? "" : ` "${as}"`}`;
|
|
@@ -2126,13 +2116,7 @@ const ownColumnToSqlWithAs = (ctx, data, column, as, quotedAs, select, jsonList)
|
|
|
2126
2116
|
return `${quotedAs ? `${quotedAs}.` : ""}"${col.data.name}"${col.data.name === as ? "" : ` "${as}"`}`;
|
|
2127
2117
|
}
|
|
2128
2118
|
if (col.data.computed) {
|
|
2129
|
-
return `${
|
|
2130
|
-
ctx,
|
|
2131
|
-
data,
|
|
2132
|
-
col.data.computed,
|
|
2133
|
-
as,
|
|
2134
|
-
quotedAs
|
|
2135
|
-
)} "${as}"`;
|
|
2119
|
+
return `${col.data.computed.toSQL(ctx, quotedAs)} "${as}"`;
|
|
2136
2120
|
}
|
|
2137
2121
|
}
|
|
2138
2122
|
return `${quotedAs ? `${quotedAs}.` : ""}"${column}"${column === as ? "" : ` "${as}"`}`;
|
|
@@ -2148,7 +2132,7 @@ const makeRowToJson = (table, shape, aliasName) => {
|
|
|
2148
2132
|
const list = [];
|
|
2149
2133
|
for (const key in shape) {
|
|
2150
2134
|
const column = shape[key];
|
|
2151
|
-
if (column.data.explicitSelect
|
|
2135
|
+
if (column.data.explicitSelect) {
|
|
2152
2136
|
continue;
|
|
2153
2137
|
}
|
|
2154
2138
|
if (aliasName && column.data.name || column.data.jsonCast) {
|
|
@@ -3079,10 +3063,23 @@ const applyComputedColumns = (q, fn) => {
|
|
|
3079
3063
|
[key]: item
|
|
3080
3064
|
};
|
|
3081
3065
|
} else {
|
|
3082
|
-
|
|
3066
|
+
let col = item.result.value;
|
|
3067
|
+
if (!col) {
|
|
3068
|
+
item.result.value = col = Object.create(
|
|
3069
|
+
UnknownColumn.instance
|
|
3070
|
+
);
|
|
3071
|
+
col.data = { ...col.data };
|
|
3072
|
+
}
|
|
3073
|
+
q.shape[key] = col;
|
|
3074
|
+
const { data } = col;
|
|
3083
3075
|
data.computed = item;
|
|
3084
3076
|
data.explicitSelect = true;
|
|
3085
3077
|
data.readonly = true;
|
|
3078
|
+
addColumnParserToQuery(
|
|
3079
|
+
q.q,
|
|
3080
|
+
key,
|
|
3081
|
+
item.result.value
|
|
3082
|
+
);
|
|
3086
3083
|
}
|
|
3087
3084
|
}
|
|
3088
3085
|
q.computeAtRuntime = q.computeBatchAtRuntime = void 0;
|
|
@@ -4181,58 +4178,49 @@ const processSelectArg = (q, as, arg, columnAs) => {
|
|
|
4181
4178
|
const setParserForSelectedString = (query, arg, as, columnAs) => {
|
|
4182
4179
|
const { q } = query;
|
|
4183
4180
|
const index = arg.indexOf(".");
|
|
4184
|
-
if (index
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
if (parser) orchidCore.setParserToQuery(q, columnAs || column, parser);
|
|
4205
|
-
const batchParsers = q.joinedBatchParsers?.[table];
|
|
4206
|
-
if (batchParsers) {
|
|
4207
|
-
let cloned = false;
|
|
4208
|
-
for (const bp of batchParsers) {
|
|
4209
|
-
if (bp.path[0] === column) {
|
|
4210
|
-
if (!cloned) {
|
|
4211
|
-
q.batchParsers = [...q.batchParsers || []];
|
|
4212
|
-
cloned = true;
|
|
4213
|
-
}
|
|
4214
|
-
q.batchParsers.push(bp);
|
|
4181
|
+
if (index === -1) return selectColumn(query, q, arg, columnAs);
|
|
4182
|
+
const table = getFullColumnTable(query, arg, index, as);
|
|
4183
|
+
const column = arg.slice(index + 1);
|
|
4184
|
+
if (column === "*") {
|
|
4185
|
+
addParsersForSelectJoined(query, table, columnAs);
|
|
4186
|
+
return table === as ? column : arg;
|
|
4187
|
+
}
|
|
4188
|
+
if (table === as) {
|
|
4189
|
+
return selectColumn(query, q, column, columnAs);
|
|
4190
|
+
}
|
|
4191
|
+
const parser = q.joinedParsers?.[table]?.[column];
|
|
4192
|
+
if (parser) orchidCore.setParserToQuery(q, columnAs || column, parser);
|
|
4193
|
+
const batchParsers = q.joinedBatchParsers?.[table];
|
|
4194
|
+
if (batchParsers) {
|
|
4195
|
+
let cloned = false;
|
|
4196
|
+
for (const bp of batchParsers) {
|
|
4197
|
+
if (bp.path[0] === column) {
|
|
4198
|
+
if (!cloned) {
|
|
4199
|
+
q.batchParsers = [...q.batchParsers || []];
|
|
4200
|
+
cloned = true;
|
|
4215
4201
|
}
|
|
4202
|
+
q.batchParsers.push(bp);
|
|
4216
4203
|
}
|
|
4217
4204
|
}
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
}
|
|
4225
|
-
orchidCore.setObjectValueImmutable(q, "selectedComputeds", column, computed);
|
|
4226
|
-
return;
|
|
4227
|
-
}
|
|
4228
|
-
return arg;
|
|
4229
|
-
} else {
|
|
4230
|
-
if (columnAs && q.parsers) {
|
|
4231
|
-
const parser = q.parsers?.[arg];
|
|
4232
|
-
if (parser) orchidCore.setObjectValueImmutable(q, "parsers", columnAs, parser);
|
|
4205
|
+
}
|
|
4206
|
+
const computeds = q.joinedComputeds?.[table];
|
|
4207
|
+
if (computeds?.[column]) {
|
|
4208
|
+
const computed = computeds[column];
|
|
4209
|
+
const map = q.hookSelect = new Map(q.hookSelect);
|
|
4210
|
+
for (const column2 of computed.deps) {
|
|
4211
|
+
map.set(column2, { select: `${table}.${column2}` });
|
|
4233
4212
|
}
|
|
4234
|
-
|
|
4213
|
+
orchidCore.setObjectValueImmutable(q, "selectedComputeds", column, computed);
|
|
4214
|
+
return;
|
|
4235
4215
|
}
|
|
4216
|
+
return arg;
|
|
4217
|
+
};
|
|
4218
|
+
const selectColumn = (query, q, key, columnAs) => {
|
|
4219
|
+
if (columnAs && q.parsers) {
|
|
4220
|
+
const parser = q.parsers[key];
|
|
4221
|
+
if (parser) orchidCore.setObjectValueImmutable(q, "parsers", columnAs, parser);
|
|
4222
|
+
}
|
|
4223
|
+
return handleComputed(query, q.computeds, key);
|
|
4236
4224
|
};
|
|
4237
4225
|
const handleComputed = (q, computeds, column) => {
|
|
4238
4226
|
if (computeds?.[column]) {
|
|
@@ -4954,7 +4942,7 @@ const selectToSql = (ctx, table, query, quotedAs, hookSelect = query.hookSelect,
|
|
|
4954
4942
|
quotedTable = quotedAs;
|
|
4955
4943
|
columnName = select;
|
|
4956
4944
|
col = query.shape[select];
|
|
4957
|
-
sql = simpleColumnToSQL(ctx,
|
|
4945
|
+
sql = simpleColumnToSQL(ctx, select, col, quotedAs);
|
|
4958
4946
|
}
|
|
4959
4947
|
} else {
|
|
4960
4948
|
columnName = column;
|
|
@@ -5836,13 +5824,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
5836
5824
|
let column = query.shape[key];
|
|
5837
5825
|
let quotedColumn;
|
|
5838
5826
|
if (column) {
|
|
5839
|
-
quotedColumn = simpleExistingColumnToSQL(
|
|
5840
|
-
ctx,
|
|
5841
|
-
query,
|
|
5842
|
-
key,
|
|
5843
|
-
column,
|
|
5844
|
-
quotedAs
|
|
5845
|
-
);
|
|
5827
|
+
quotedColumn = simpleExistingColumnToSQL(ctx, key, column, quotedAs);
|
|
5846
5828
|
} else if (!column) {
|
|
5847
5829
|
const index = key.indexOf(".");
|
|
5848
5830
|
if (index !== -1) {
|
|
@@ -5850,7 +5832,7 @@ const processWhere = (ands, ctx, table, query, data, quotedAs) => {
|
|
|
5850
5832
|
const quoted = `"${table2}"`;
|
|
5851
5833
|
const name = key.slice(index + 1);
|
|
5852
5834
|
column = quotedAs === quoted ? query.shape[name] : query.joinedShapes?.[table2]?.[name];
|
|
5853
|
-
quotedColumn = simpleColumnToSQL(ctx,
|
|
5835
|
+
quotedColumn = simpleColumnToSQL(ctx, name, column, quoted);
|
|
5854
5836
|
} else {
|
|
5855
5837
|
column = query.joinedShapes?.[key]?.value;
|
|
5856
5838
|
quotedColumn = `"${key}".r`;
|
|
@@ -7390,6 +7372,7 @@ class VirtualColumn extends ColumnType {
|
|
|
7390
7372
|
super(schema, inputSchema);
|
|
7391
7373
|
this.dataType = "";
|
|
7392
7374
|
this.operators = Operators.any;
|
|
7375
|
+
this.data.explicitSelect = true;
|
|
7393
7376
|
}
|
|
7394
7377
|
toCode() {
|
|
7395
7378
|
throw new Error(`toCode is not implemented for virtual column`);
|
|
@@ -7399,6 +7382,8 @@ class VirtualColumn extends ColumnType {
|
|
|
7399
7382
|
const _UnknownColumn = class _UnknownColumn extends VirtualColumn {
|
|
7400
7383
|
constructor(schema) {
|
|
7401
7384
|
super(schema, schema.unknown());
|
|
7385
|
+
this.selectable = true;
|
|
7386
|
+
this.data.explicitSelect = void 0;
|
|
7402
7387
|
}
|
|
7403
7388
|
};
|
|
7404
7389
|
_UnknownColumn.instance = new _UnknownColumn(defaultSchemaConfig);
|
|
@@ -11722,8 +11707,6 @@ class ColumnRefExpression extends orchidCore.Expression {
|
|
|
11722
11707
|
makeSQL(ctx, quotedAs) {
|
|
11723
11708
|
return simpleExistingColumnToSQL(
|
|
11724
11709
|
ctx,
|
|
11725
|
-
// it's for parsers for computed SQL. In the column ref case, parsers should be set when selecting the column ref.
|
|
11726
|
-
{},
|
|
11727
11710
|
this.name,
|
|
11728
11711
|
this.result.value,
|
|
11729
11712
|
quotedAs
|