diff --git a/src/expressions/delete.ts b/src/expressions/delete.ts index fc2fc6c..9ba178f 100644 --- a/src/expressions/delete.ts +++ b/src/expressions/delete.ts @@ -1,4 +1,4 @@ -import type { AnyValueSource, IBooleanValueSource, IExecutableDeleteQuery, IIfValueSource, ValueSourceOf, ValueSourceValueTypeForResult } from "./values" +import type { AnyValueSource, IAnyBooleanValueSource, IExecutableDeleteQuery, ValueSourceOf, ValueSourceValueTypeForResult } from "./values" import type { ForUseInLeftJoin, HasSource, IRawFragment, ITableOrView, OfDB, OfSameDB } from "../utils/ITableOrView" import type { ResultObjectValues, ResultObjectValuesProjectedAsNullable } from "../utils/resultUtils" import type { NNoTableOrViewRequiredFrom, NSource } from "../utils/sourceName" @@ -28,16 +28,13 @@ export interface CustomizableExecutableDelete, /*in|out*/ USING extends HasSource> extends ReturnableExecutableDelete { - and(condition: IIfValueSource ): DynamicExecutableDeleteExpression - and(condition: IBooleanValueSource ): DynamicExecutableDeleteExpression - or(condition: IIfValueSource ): DynamicExecutableDeleteExpression - or(condition: IBooleanValueSource ): DynamicExecutableDeleteExpression + and(condition: IAnyBooleanValueSource): DynamicExecutableDeleteExpression + or(condition: IAnyBooleanValueSource): DynamicExecutableDeleteExpression } export interface DeleteWhereExpression, /*in|out*/ USING extends HasSource> extends DeleteExpressionBase { dynamicWhere() : DynamicExecutableDeleteExpression - where(condition: IIfValueSource ): DynamicExecutableDeleteExpression - where(condition: IBooleanValueSource ): DynamicExecutableDeleteExpression + where(condition: IAnyBooleanValueSource): DynamicExecutableDeleteExpression } export interface DeleteExpression, /*in|out*/ USING extends HasSource> extends DeleteWhereExpression { @@ -50,8 +47,7 @@ export interface DeleteExpression, /*in| export interface DeleteWhereExpressionAllowingNoWhere, /*in|out*/ USING extends HasSource> extends ReturnableExecutableDelete { dynamicWhere() : DynamicExecutableDeleteExpression - where(condition: IIfValueSource ): DynamicExecutableDeleteExpression - where(condition: IBooleanValueSource ): DynamicExecutableDeleteExpression + where(condition: IAnyBooleanValueSource): DynamicExecutableDeleteExpression } export interface DeleteExpressionAllowingNoWhere, /*in|out*/ USING extends HasSource> extends DeleteWhereExpressionAllowingNoWhere { @@ -74,16 +70,13 @@ export interface DeleteWhereJoinExpression, /*in|out*/ USING extends HasSource> extends DeleteWhereJoinExpression { - and(condition: IIfValueSource ): DynamicOnExpression - and(condition: IBooleanValueSource ): DynamicOnExpression - or(condition: IIfValueSource ): DynamicOnExpression - or(condition: IBooleanValueSource ): DynamicOnExpression + and(condition: IAnyBooleanValueSource): DynamicOnExpression + or(condition: IAnyBooleanValueSource): DynamicOnExpression } export interface OnExpression, /*in|out*/ USING extends HasSource> extends DeleteWhereJoinExpression { dynamicOn(): DynamicOnExpression - on(condition: IIfValueSource ): DynamicOnExpression - on(condition: IBooleanValueSource ): DynamicOnExpression + on(condition: IAnyBooleanValueSource): DynamicOnExpression } export interface DeleteExpressionWithoutJoin, /*in|out*/ USING extends HasSource> extends DeleteWhereExpression { @@ -121,16 +114,13 @@ export interface DeleteWhereJoinExpressionAllowingNoWhere, /*in|out*/ USING extends HasSource> extends DeleteWhereJoinExpressionAllowingNoWhere { - and(condition: IIfValueSource ): DynamicOnExpressionAllowingNoWhere - and(condition: IBooleanValueSource ): DynamicOnExpressionAllowingNoWhere - or(condition: IIfValueSource ): DynamicOnExpressionAllowingNoWhere - or(condition: IBooleanValueSource ): DynamicOnExpressionAllowingNoWhere + and(condition: IAnyBooleanValueSource): DynamicOnExpressionAllowingNoWhere + or(condition: IAnyBooleanValueSource): DynamicOnExpressionAllowingNoWhere } export interface OnExpressionAllowingNoWhere, /*in|out*/ USING extends HasSource> extends DeleteWhereJoinExpressionAllowingNoWhere { dynamicOn(): DynamicOnExpressionAllowingNoWhere - on(condition: IIfValueSource ): DynamicOnExpressionAllowingNoWhere - on(condition: IBooleanValueSource ): DynamicOnExpressionAllowingNoWhere + on(condition: IAnyBooleanValueSource): DynamicOnExpressionAllowingNoWhere } export interface DeleteExpressionWithoutJoinAllowingNoWhere, /*in|out*/ USING extends HasSource> extends DeleteWhereExpressionAllowingNoWhere { diff --git a/src/expressions/fragment.ts b/src/expressions/fragment.ts index 3ba356f..b4d12e4 100644 --- a/src/expressions/fragment.ts +++ b/src/expressions/fragment.ts @@ -1,4 +1,4 @@ -import type { BooleanValueSource, NumberValueSource, StringValueSource, LocalDateValueSource, LocalTimeValueSource, LocalDateTimeValueSource, EqualableValueSource, ComparableValueSource, RemapValueSourceType, TypeOfArgument, MapArgumentToValueSource, ArgForFn, IfValueSource, ArgForBuilderIfValue, IBooleanValueSource, IIfValueSource, BigintValueSource, OptionalType, ValueSourceOf, UuidValueSource, CustomIntValueSource, CustomDoubleValueSource, CustomUuidValueSource, CustomLocalDateTimeValueSource, CustomLocalDateValueSource, CustomLocalTimeValueSource, IValueSource, RemapValueSourceTypeWithOptionalType, OptionalTypeOfValue, ArgBaseTypeForFn, MergeOptionalUnion } from "../expressions/values" +import type { BooleanValueSource, NumberValueSource, StringValueSource, LocalDateValueSource, LocalTimeValueSource, LocalDateTimeValueSource, EqualableValueSource, ComparableValueSource, RemapValueSourceType, TypeOfArgument, MapArgumentToValueSource, ArgForFn, IfValueSource, ArgForBuilderIfValue, IAnyBooleanValueSource, BigintValueSource, OptionalType, ValueSourceOf, UuidValueSource, CustomIntValueSource, CustomDoubleValueSource, CustomUuidValueSource, CustomLocalDateTimeValueSource, CustomLocalDateValueSource, CustomLocalTimeValueSource, IValueSource, RemapValueSourceTypeWithOptionalType, OptionalTypeOfValue, ArgBaseTypeForFn, MergeOptionalUnion } from "../expressions/values" import type { optionalType, source } from "../utils/symbols" import type { NSource } from "../utils/sourceName" @@ -285,27 +285,27 @@ export interface FragmentFunction5 { - as | IIfValueSource>(impl: () => RESULT): () => IfValueSource + as>(impl: () => RESULT): () => IfValueSource } export interface FragmentBuilder1IfValue { - as | IIfValueSource>(impl: (a1: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue1 + as>(impl: (a1: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue1 } export interface FragmentBuilder2IfValue { - as | IIfValueSource>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue2 + as>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue2 } export interface FragmentBuilder3IfValue { - as | IIfValueSource>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue, a3: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue3 + as>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue, a3: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue3 } export interface FragmentBuilder4IfValue { - as | IIfValueSource>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue, a3: ArgForBuilderIfValue, a4: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue4 + as>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue, a3: ArgForBuilderIfValue, a4: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue4 } export interface FragmentBuilder5IfValue { - as | IIfValueSource>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue, a3: ArgForBuilderIfValue, a4: ArgForBuilderIfValue, a5: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue5 + as>(impl: (a1: ArgForBuilderIfValue, a2: ArgForBuilderIfValue, a3: ArgForBuilderIfValue, a4: ArgForBuilderIfValue, a5: ArgForBuilderIfValue) => RESULT): FragmentFunctionIfValue5 } export interface FragmentFunctionIfValue1 { diff --git a/src/expressions/insert.ts b/src/expressions/insert.ts index af59284..a9c4f4c 100644 --- a/src/expressions/insert.ts +++ b/src/expressions/insert.ts @@ -1,4 +1,4 @@ -import type { IExecutableSelectQuery, RemapIValueSourceType, ValueSourceValueType, AnyValueSource, ValueSourceOf, ValueSourceValueTypeForResult, RemapIValueSourceTypeWithOptionalType, IExecutableInsertQuery, IIfValueSource, IBooleanValueSource, IStringValueSource } from "./values" +import type { IExecutableSelectQuery, RemapIValueSourceType, ValueSourceValueType, AnyValueSource, ValueSourceOf, ValueSourceValueTypeForResult, RemapIValueSourceTypeWithOptionalType, IExecutableInsertQuery, IAnyBooleanValueSource, IStringValueSource } from "./values" import type { HasSource, IRawFragment, OfDB, ResolvedShape } from "../utils/ITableOrView" import type { from, source, using } from "../utils/symbols" import type { ColumnWithDefaultValue } from "../utils/Column" @@ -882,16 +882,13 @@ export interface ShapedInsertOnConflictSetsExpression, /*in|out*/ USING extends HasSource, NEXT> { - and(condition: IIfValueSource): DynamicOnConflictWhereExpression & NEXT - and(condition: IBooleanValueSource): DynamicOnConflictWhereExpression & NEXT - or(condition: IIfValueSource): DynamicOnConflictWhereExpression & NEXT - or(condition: IBooleanValueSource): DynamicOnConflictWhereExpression & NEXT + and(condition: IAnyBooleanValueSource): DynamicOnConflictWhereExpression & NEXT + or(condition: IAnyBooleanValueSource): DynamicOnConflictWhereExpression & NEXT } export interface OnConflictOnColumnWhere, /*in|out*/ USING extends HasSource, NEXT> { dynamicWhere() : DynamicOnConflictWhereExpression & NEXT - where(condition: IIfValueSource): DynamicOnConflictWhereExpression & NEXT - where(condition: IBooleanValueSource): DynamicOnConflictWhereExpression & NEXT + where(condition: IAnyBooleanValueSource): DynamicOnConflictWhereExpression & NEXT } type OnConflictDoNothingFnType, _USING extends HasSource, NEXT> = @@ -934,8 +931,7 @@ type OnConflictDoUpdateWhereFnType
, USING extends H : never interface OnConflictDoUpdateWhereFnTypeInterface, /*in|out*/ USING extends HasSource, /*in|out*/ NEXT> { - (condition: IIfValueSource): DynamicOnConflictWhereExpression & NEXT - (condition: IBooleanValueSource): DynamicOnConflictWhereExpression & NEXT + (condition: IAnyBooleanValueSource): DynamicOnConflictWhereExpression & NEXT } type OnConflictOnColumnFnType
, USING extends HasSource, NEXT> = diff --git a/src/expressions/select.ts b/src/expressions/select.ts index 619da4a..110872c 100644 --- a/src/expressions/select.ts +++ b/src/expressions/select.ts @@ -1,4 +1,4 @@ -import type { IBooleanValueSource, INumberValueSource, IIfValueSource, IExecutableSelectQuery, AnyValueSource, ValueSourceOf, ValueSourceValueTypeForResult, RemapValueSourceType, RemapValueSourceTypeWithOptionalType, AggregatedArrayValueSource, IValueSource, RemapIValueSourceType } from "./values" +import type { IBooleanValueSource, INumberValueSource, IAnyBooleanValueSource, IExecutableSelectQuery, AnyValueSource, ValueSourceOf, ValueSourceValueTypeForResult, RemapValueSourceType, RemapValueSourceTypeWithOptionalType, AggregatedArrayValueSource, IValueSource, RemapIValueSourceType } from "./values" import type { ForUseInLeftJoin, HasSource, IRawFragment, ITableOrView, NoTableOrViewRequiredOfSameDB, OfDB, OfSameDB } from "../utils/ITableOrView" import type { WithView } from "../utils/tableOrViewUtils" import type { resultType, compoundableColumns, valueType, from, using, source, selectColumnsType } from "../utils/symbols" @@ -146,15 +146,12 @@ export interface CompoundableExecutableSelectExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends CompoundableExecutableSelectExpressionWithoutWhere { dynamicWhere(): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression - where(condition: IIfValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression - where(condition: IBooleanValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression + where(condition: IAnyBooleanValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression } export interface DynamicWhereLastCompoundableCustomizableExecutableSelectExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends WithableExecutableSelect { - and(condition: IIfValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression - and(condition: IBooleanValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression - or(condition: IIfValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression - or(condition: IBooleanValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression + and(condition: IAnyBooleanValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression + or(condition: IAnyBooleanValueSource): DynamicWhereLastCompoundableCustomizableExecutableSelectExpression } export interface CompoundableCustomizableExecutableSelectExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends CompoundableExecutableSelectExpression { @@ -214,8 +211,7 @@ export interface OrderableExecutableSelectExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends CompoundableCustomizableExecutableSelectExpressionWitoutWhere { dynamicWhere(): DynamicWhereLimitExecutableSelectExpression - where(condition: IIfValueSource): DynamicWhereLimitExecutableSelectExpression - where(condition: IBooleanValueSource): DynamicWhereLimitExecutableSelectExpression + where(condition: IAnyBooleanValueSource): DynamicWhereLimitExecutableSelectExpression limit(limit: number): OffsetExecutableSelectExpressionWithoutWhere limitIfValue(limit: number | null | undefined): OffsetExecutableSelectExpressionWithoutWhere @@ -238,31 +234,25 @@ export interface OffsetExecutableSelectExpressionWithoutWhere dynamicWhere(): DynamicWhereCompoundableCustomizableExecutableSelectExpression - where(condition: IIfValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression - where(condition: IBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression + where(condition: IAnyBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression } export interface CompoundableCustomizableExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends CompoundableCustomizableExecutableSelectExpressionWitoutWhere { dynamicWhere(): DynamicWhereCompoundableCustomizableExecutableSelectExpression - where(condition: IIfValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression - where(condition: IBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression + where(condition: IAnyBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression } export interface DynamicWhereLimitExecutableSelectExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends CompoundableCustomizableExecutableSelectExpression { - and(condition: IIfValueSource): DynamicWhereLimitExecutableSelectExpression - and(condition: IBooleanValueSource): DynamicWhereLimitExecutableSelectExpression - or(condition: IIfValueSource): DynamicWhereLimitExecutableSelectExpression - or(condition: IBooleanValueSource): DynamicWhereLimitExecutableSelectExpression + and(condition: IAnyBooleanValueSource): DynamicWhereLimitExecutableSelectExpression + or(condition: IAnyBooleanValueSource): DynamicWhereLimitExecutableSelectExpression limit(limit: number): OffsetExecutableSelectExpression limitIfValue(limit: number | null | undefined): OffsetExecutableSelectExpression } export interface DynamicWhereCompoundableCustomizableExecutableSelectExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends CompoundableCustomizableExecutableSelectExpression { - and(condition: IIfValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression - and(condition: IBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression - or(condition: IIfValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression - or(condition: IBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression + and(condition: IAnyBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression + or(condition: IAnyBooleanValueSource): DynamicWhereCompoundableCustomizableExecutableSelectExpression } export interface RecursivelyConnectedExecutableSelectExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends OrderByExecutableSelectExpression { @@ -285,27 +275,22 @@ export interface GroupByOrderByHavingExecutableSelectExpression[]): GroupByOrderByHavingExecutableSelectExpression dynamicHaving(): DynamicHavingExecutableSelectExpression - having(condition: IIfValueSource): DynamicHavingExecutableSelectExpression - having(condition: IBooleanValueSource): DynamicHavingExecutableSelectExpression + having(condition: IAnyBooleanValueSource): DynamicHavingExecutableSelectExpression } export interface DynamicHavingExecutableSelectExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends OrderByExecutableSelectExpression { - and(condition: IIfValueSource): DynamicHavingExecutableSelectExpression - and(condition: IBooleanValueSource): DynamicHavingExecutableSelectExpression - or(condition: IIfValueSource): DynamicHavingExecutableSelectExpression - or(condition: IBooleanValueSource): DynamicHavingExecutableSelectExpression + and(condition: IAnyBooleanValueSource): DynamicHavingExecutableSelectExpression + or(condition: IAnyBooleanValueSource): DynamicHavingExecutableSelectExpression } export interface GroupByOrderHavingByExpressionWithoutSelect, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends SelectExpressionBase { groupBy(...columns: ValueSourceOf[]): GroupByOrderHavingByExpressionWithoutSelect dynamicHaving(): DynamicHavingExpressionWithoutSelect - having(condition: IIfValueSource): DynamicHavingExpressionWithoutSelect - having(condition: IBooleanValueSource): DynamicHavingExpressionWithoutSelect + having(condition: IAnyBooleanValueSource): DynamicHavingExpressionWithoutSelect dynamicWhere(): DynamicWhereSelectExpressionWithoutSelect - where(condition: IIfValueSource): DynamicWhereSelectExpressionWithoutSelect - where(condition: IBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect + where(condition: IAnyBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect select>(columns: COLUMNS): WhereableExecutableSelectExpressionWithGroupByProjectableAsNullable, FEATURES> selectOneColumn>(column: COLUMN): WhereableExecutableSelectExpressionWithGroupBy, FEATURES> @@ -313,14 +298,11 @@ export interface GroupByOrderHavingByExpressionWithoutSelect, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends SelectExpressionBase { - and(condition: IIfValueSource): DynamicHavingExpressionWithoutSelect - and(condition: IBooleanValueSource): DynamicHavingExpressionWithoutSelect - or(condition: IIfValueSource): DynamicHavingExpressionWithoutSelect - or(condition: IBooleanValueSource): DynamicHavingExpressionWithoutSelect + and(condition: IAnyBooleanValueSource): DynamicHavingExpressionWithoutSelect + or(condition: IAnyBooleanValueSource): DynamicHavingExpressionWithoutSelect dynamicWhere(): DynamicWhereSelectExpressionWithoutSelect - where(condition: IIfValueSource): DynamicWhereSelectExpressionWithoutSelect - where(condition: IBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect + where(condition: IAnyBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect select>(columns: COLUMNS): WhereableExecutableSelectExpressionWithGroupByProjectableAsNullable, FEATURES> selectOneColumn>(column: COLUMN): WhereableExecutableSelectExpressionWithGroupBy, FEATURES> @@ -328,10 +310,8 @@ export interface DynamicHavingExpressionWithoutSelect, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends SelectExpressionBase { - and(condition: IIfValueSource): DynamicWhereSelectExpressionWithoutSelect - and(condition: IBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect - or(condition: IIfValueSource): DynamicWhereSelectExpressionWithoutSelect - or(condition: IBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect + and(condition: IAnyBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect + or(condition: IAnyBooleanValueSource): DynamicWhereSelectExpressionWithoutSelect select>(columns: COLUMNS): OrderByExecutableSelectExpressionProjectableAsNullable, FEATURES> selectOneColumn>(column: COLUMN): OrderByExecutableSelectExpression, FEATURES> @@ -347,10 +327,8 @@ export interface RecursivelyConnectedExpressionWithoutSelect, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends RecursivelyConnectedExpressionWithoutSelect { - and(condition: IIfValueSource): DynamicWhereExpressionWithoutSelect - and(condition: IBooleanValueSource): DynamicWhereExpressionWithoutSelect - or(condition: IIfValueSource): DynamicWhereExpressionWithoutSelect - or(condition: IBooleanValueSource): DynamicWhereExpressionWithoutSelect + and(condition: IAnyBooleanValueSource): DynamicWhereExpressionWithoutSelect + or(condition: IAnyBooleanValueSource): DynamicWhereExpressionWithoutSelect startWith: StartWithFnType> connectBy: ConnectByFnType> @@ -358,16 +336,13 @@ export interface DynamicWhereExpressionWithoutSelect, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends GroupByOrderByExecutableSelectExpression { - and(condition: IIfValueSource): DynamicWhereExecutableSelectExpression - and(condition: IBooleanValueSource): DynamicWhereExecutableSelectExpression - or(condition: IIfValueSource): DynamicWhereExecutableSelectExpression - or(condition: IBooleanValueSource): DynamicWhereExecutableSelectExpression + and(condition: IAnyBooleanValueSource): DynamicWhereExecutableSelectExpression + or(condition: IAnyBooleanValueSource): DynamicWhereExecutableSelectExpression } export interface WhereableExecutableSelectExpressionWithGroupBy, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends OrderableExecutableSelectExpressionWithoutWhere { dynamicWhere(): DynamicWhereExecutableSelectExpressionWithGroupBy - where(condition: IIfValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy - where(condition: IBooleanValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy + where(condition: IAnyBooleanValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy } export interface WhereableExecutableSelectExpressionWithGroupByProjectableAsNullable, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends WhereableExecutableSelectExpressionWithGroupBy { @@ -375,10 +350,8 @@ export interface WhereableExecutableSelectExpressionWithGroupByProjectableAsNull } export interface DynamicWhereExecutableSelectExpressionWithGroupBy, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends OrderByExecutableSelectExpression { - and(condition: IIfValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy - and(condition: IBooleanValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy - or(condition: IIfValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy - or(condition: IBooleanValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy + and(condition: IAnyBooleanValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy + or(condition: IAnyBooleanValueSource): DynamicWhereExecutableSelectExpressionWithGroupBy } export interface GroupByOrderByHavingExecutableSelectExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends WhereableExecutableSelectExpressionWithGroupBy { @@ -386,15 +359,12 @@ export interface GroupByOrderByHavingExecutableSelectExpressionWithoutWhere[]): GroupByOrderByHavingExecutableSelectExpressionWithoutWhere dynamicHaving(): DynamicHavingExecutableSelectExpressionWithoutWhere - having(condition: IIfValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere - having(condition: IBooleanValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere + having(condition: IAnyBooleanValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere } export interface DynamicHavingExecutableSelectExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends WhereableExecutableSelectExpressionWithGroupBy { - and(condition: IIfValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere - and(condition: IBooleanValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere - or(condition: IIfValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere - or(condition: IBooleanValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere + and(condition: IAnyBooleanValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere + or(condition: IAnyBooleanValueSource): DynamicHavingExecutableSelectExpressionWithoutWhere } export interface RecursivelyConnectedExecutableSelectExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends OrderableExecutableSelectExpressionWithoutWhere { @@ -402,8 +372,7 @@ export interface RecursivelyConnectedExecutableSelectExpressionWithoutWhere[]): GroupByOrderByHavingExecutableSelectExpressionWithoutWhere dynamicWhere(): DynamicWhereExecutableSelectExpression - where(condition: IIfValueSource): DynamicWhereExecutableSelectExpression - where(condition: IBooleanValueSource): DynamicWhereExecutableSelectExpression + where(condition: IAnyBooleanValueSource): DynamicWhereExecutableSelectExpression } export interface ExecutableSelectExpressionWithoutWhere, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ COLUMNS, /*in|out*/ RESULT, /*in|out*/ FEATURES> extends RecursivelyConnectedExecutableSelectExpressionWithoutWhere { @@ -421,8 +390,7 @@ export interface RecursivelyConnectedSelectWhereExpression>(column: COLUMN): ExecutableSelectExpressionWithoutWhere, FEATURES> selectCountAll(): ExecutableSelectExpressionWithoutWhere, 'required'>, number, FEATURES| 'requiredResult'> dynamicWhere(): DynamicWhereExpressionWithoutSelect - where(condition: IIfValueSource): DynamicWhereExpressionWithoutSelect - where(condition: IBooleanValueSource): DynamicWhereExpressionWithoutSelect + where(condition: IAnyBooleanValueSource): DynamicWhereExpressionWithoutSelect groupBy(...columns: ValueSourceOf[]): GroupByOrderHavingByExpressionWithoutSelect } @@ -444,16 +412,13 @@ export interface SelectWhereJoinExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends SelectWhereJoinExpression { - and(condition: IIfValueSource): DynamicOnExpression - and(condition: IBooleanValueSource): DynamicOnExpression - or(condition: IIfValueSource): DynamicOnExpression - or(condition: IBooleanValueSource): DynamicOnExpression + and(condition: IAnyBooleanValueSource): DynamicOnExpression + or(condition: IAnyBooleanValueSource): DynamicOnExpression } export interface OnExpression, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends SelectWhereJoinExpression { dynamicOn(): DynamicOnExpression - on(condition: IIfValueSource): DynamicOnExpression - on(condition: IBooleanValueSource): DynamicOnExpression + on(condition: IAnyBooleanValueSource): DynamicOnExpression } export interface SelectExpressionWithoutJoin, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ FEATURES> extends SelectWhereExpression { @@ -534,8 +499,7 @@ type StartWithFnType, REQUIRED extends HasSource, /*in|out*/ REQUIRED extends HasSource, /*in|out*/ NEXT> { - (condition: IIfValueSource): ConnectByExpression - (condition: IBooleanValueSource): ConnectByExpression + (condition: IAnyBooleanValueSource): ConnectByExpression } export interface ConnectByExpression, /*in|out*/ _REQUIRED extends HasSource, NEXT> { diff --git a/src/expressions/update.ts b/src/expressions/update.ts index fea7ec3..d56c3ba 100644 --- a/src/expressions/update.ts +++ b/src/expressions/update.ts @@ -1,4 +1,4 @@ -import type { AnyValueSource, IBooleanValueSource, IExecutableUpdateQuery, IIfValueSource, RemapIValueSourceType, RemapIValueSourceTypeWithOptionalType, ValueSourceOf, ValueSourceValueType, ValueSourceValueTypeForResult } from "./values" +import type { AnyValueSource, IExecutableUpdateQuery, IAnyBooleanValueSource, RemapIValueSourceType, RemapIValueSourceTypeWithOptionalType, ValueSourceOf, ValueSourceValueType, ValueSourceValueTypeForResult } from "./values" import type { ForUseInLeftJoin, HasSource, IRawFragment, ITable, ITableOrView, OfDB, OfSameDB, ResolvedShape } from "../utils/ITableOrView" import type { from, source, using } from "../utils/symbols" import type { ColumnsForSetOf, ColumnsForSetOfWithShape, ColumnsKeyOf, OptionalColumnsForSetOf, RequiredColumnsForSetOf, ResolveShape } from "../utils/tableOrViewUtils" @@ -88,8 +88,7 @@ export interface ExecutableUpdateExpression[]): ExecutableUpdateExpression dynamicWhere() : DynamicExecutableUpdateExpression - where(condition: IIfValueSource): DynamicExecutableUpdateExpression - where(condition: IBooleanValueSource): DynamicExecutableUpdateExpression + where(condition: IAnyBooleanValueSource): DynamicExecutableUpdateExpression } export interface ShapedExecutableUpdateExpression, /*in|out*/ USING extends HasSource, /*in|out*/ SHAPE> extends ReturnableExecutableUpdate { @@ -112,8 +111,7 @@ export interface ShapedExecutableUpdateExpression dynamicWhere() : DynamicExecutableUpdateExpression - where(condition: IIfValueSource): DynamicExecutableUpdateExpression - where(condition: IBooleanValueSource): DynamicExecutableUpdateExpression + where(condition: IAnyBooleanValueSource): DynamicExecutableUpdateExpression } export interface NotExecutableUpdateExpression, /*in|out*/ USING extends HasSource> extends UpdateExpressionBase { @@ -135,8 +133,7 @@ export interface NotExecutableUpdateExpression dynamicWhere() : DynamicExecutableUpdateExpression - where(condition: IIfValueSource): DynamicExecutableUpdateExpression - where(condition: IBooleanValueSource): DynamicExecutableUpdateExpression + where(condition: IAnyBooleanValueSource): DynamicExecutableUpdateExpression } export interface ShapedNotExecutableUpdateExpression, /*in|out*/ USING extends HasSource, /*in|out*/ SHAPE> extends UpdateExpressionBase { @@ -159,15 +156,12 @@ export interface ShapedNotExecutableUpdateExpression dynamicWhere() : DynamicExecutableUpdateExpression - where(condition: IIfValueSource): DynamicExecutableUpdateExpression - where(condition: IBooleanValueSource): DynamicExecutableUpdateExpression + where(condition: IAnyBooleanValueSource): DynamicExecutableUpdateExpression } export interface DynamicExecutableUpdateExpression, /*in|out*/ USING extends HasSource> extends ReturnableExecutableUpdate { - and(condition: IIfValueSource): DynamicExecutableUpdateExpression - and(condition: IBooleanValueSource): DynamicExecutableUpdateExpression - or(condition: IIfValueSource): DynamicExecutableUpdateExpression - or(condition: IBooleanValueSource): DynamicExecutableUpdateExpression + and(condition: IAnyBooleanValueSource): DynamicExecutableUpdateExpression + or(condition: IAnyBooleanValueSource): DynamicExecutableUpdateExpression } export interface UpdateSetExpression, /*in|out*/ USING extends HasSource> extends UpdateExpressionBase { @@ -305,16 +299,13 @@ export interface UpdateSetJoinExpression } export interface DynamicOnExpression, /*in|out*/ USING extends HasSource> extends UpdateSetJoinExpression { - and(condition: IIfValueSource): DynamicOnExpression - and(condition: IBooleanValueSource): DynamicOnExpression - or(condition: IIfValueSource): DynamicOnExpression - or(condition: IBooleanValueSource): DynamicOnExpression + and(condition: IAnyBooleanValueSource): DynamicOnExpression + or(condition: IAnyBooleanValueSource): DynamicOnExpression } export interface OnExpression, /*in|out*/ USING extends HasSource> extends UpdateSetJoinExpression { dynamicOn(): DynamicOnExpression - on(condition: IIfValueSource): DynamicOnExpression - on(condition: IBooleanValueSource): DynamicOnExpression + on(condition: IAnyBooleanValueSource): DynamicOnExpression } export interface UpdateExpressionWithoutJoin, /*in|out*/ USING extends HasSource> extends UpdateSetExpression { @@ -352,16 +343,13 @@ export interface UpdateSetJoinExpressionAllowingNoWhere, /*in|out*/ USING extends HasSource> extends UpdateSetJoinExpressionAllowingNoWhere { - and(condition: IIfValueSource): DynamicOnExpressionAllowingNoWhere - and(condition: IBooleanValueSource): DynamicOnExpressionAllowingNoWhere - or(condition: IIfValueSource): DynamicOnExpressionAllowingNoWhere - or(condition: IBooleanValueSource): DynamicOnExpressionAllowingNoWhere + and(condition: IAnyBooleanValueSource): DynamicOnExpressionAllowingNoWhere + or(condition: IAnyBooleanValueSource): DynamicOnExpressionAllowingNoWhere } export interface OnExpressionAllowingNoWhere, /*in|out*/ USING extends HasSource> extends UpdateSetJoinExpressionAllowingNoWhere { dynamicOn(): DynamicOnExpressionAllowingNoWhere - on(condition: IIfValueSource): DynamicOnExpressionAllowingNoWhere - on(condition: IBooleanValueSource): DynamicOnExpressionAllowingNoWhere + on(condition: IAnyBooleanValueSource): DynamicOnExpressionAllowingNoWhere } export interface UpdateExpressionWithoutJoinAllowingNoWhere, /*in|out*/ USING extends HasSource> extends UpdateSetExpressionAllowingNoWhere { diff --git a/src/expressions/values.ts b/src/expressions/values.ts index 175d9a3..d5143c9 100644 --- a/src/expressions/values.ts +++ b/src/expressions/values.ts @@ -186,7 +186,7 @@ export function __getValueSourceOfObject(obj: AnyTableOrView, prop: string): Val } } -export function __getValueSourcePrivate(valueSource: AnyValueSource | IIfValueSource): __ValueSourcePrivate { +export function __getValueSourcePrivate(valueSource: AnyValueSource | IAnyBooleanValueSource): __ValueSourcePrivate { return valueSource as any } @@ -307,19 +307,22 @@ export interface ComparableValueSource } -export interface IBooleanValueSource extends IEqualableValueSource { - [booleanValueSource]: 'BooleanValueSource' +export interface IAnyBooleanValueSource extends HasSource { + [valueType]: boolean + [optionalType]: OPTIONAL_TYPE [anyBooleanValueSource]: 'AnyBooleanValueSource' } +export interface IBooleanValueSource extends IEqualableValueSource, IAnyBooleanValueSource { + [booleanValueSource]: 'BooleanValueSource' +} + export interface BooleanValueSource extends EqualableValueSource, IBooleanValueSource { negate(): BooleanValueSource and(value: boolean): BooleanValueSource - and>(value: VALUE): BooleanValueSource> - and>(value: VALUE): BooleanValueSource> + and>(value: VALUE): BooleanValueSource> or(value: boolean): BooleanValueSource - or>(value: VALUE): BooleanValueSource> - or>(value: VALUE): BooleanValueSource> + or>(value: VALUE): BooleanValueSource> onlyWhen(condition: boolean): IIfValueSource ignoreWhen(condition: boolean): IIfValueSource // Redefined methods @@ -333,53 +336,39 @@ export interface BooleanValueSource } -export interface IIfValueSource { - [source]: SOURCE - [valueType]: boolean - [optionalType]: OPTIONAL_TYPE +export interface IIfValueSource extends IAnyBooleanValueSource { [ifValueSource]: 'IfValueSource' - [anyBooleanValueSource]: 'AnyBooleanValueSource' } export interface IfValueSource extends IIfValueSource { negate(): IIfValueSource and(value: boolean): BooleanValueSource - and>(value: VALUE): IfValueSource> and>(value: VALUE): BooleanValueSource> + and>(value: VALUE): IfValueSource> or(value: boolean): BooleanValueSource - or>(value: VALUE): IfValueSource> or>(value: VALUE): BooleanValueSource> + or>(value: VALUE): IfValueSource> onlyWhen(condition: boolean): IIfValueSource ignoreWhen(condition: boolean): IIfValueSource trueWhenNoValue(): BooleanValueSource falseWhenNoValue(): BooleanValueSource valueWhenNoValue(value: boolean): BooleanValueSource - valueWhenNoValue>(value: VALUE): IIfValueSource> valueWhenNoValue>(value: VALUE): BooleanValueSource> -} - -export interface IAnyBooleanValueSource { - [source]: SOURCE - [valueType]: boolean - [optionalType]: OPTIONAL_TYPE - [anyBooleanValueSource]: 'AnyBooleanValueSource' + valueWhenNoValue>(value: VALUE): IIfValueSource> } export interface AlwaysIfValueSource extends IIfValueSource { negate(): AlwaysIfValueSource and(value: boolean): AlwaysIfValueSource - and>(value: VALUE): AlwaysIfValueSource> - and>(value: VALUE): AlwaysIfValueSource> + and>(value: VALUE): AlwaysIfValueSource> or(value: boolean): AlwaysIfValueSource - or>(value: VALUE): AlwaysIfValueSource> - or>(value: VALUE): AlwaysIfValueSource> + or>(value: VALUE): AlwaysIfValueSource> onlyWhen(condition: boolean): AlwaysIfValueSource ignoreWhen(condition: boolean): AlwaysIfValueSource trueWhenNoValue(): AlwaysIfValueSource falseWhenNoValue(): AlwaysIfValueSource valueWhenNoValue(value: boolean): AlwaysIfValueSource - valueWhenNoValue>(value: VALUE): AlwaysIfValueSource> - valueWhenNoValue>(value: VALUE): AlwaysIfValueSource> + valueWhenNoValue>(value: VALUE): AlwaysIfValueSource> } export interface INumberValueSource extends IComparableValueSource { diff --git a/src/queryBuilders/DeleteQueryBuilder.ts b/src/queryBuilders/DeleteQueryBuilder.ts index 7df5104..c88257f 100644 --- a/src/queryBuilders/DeleteQueryBuilder.ts +++ b/src/queryBuilders/DeleteQueryBuilder.ts @@ -1,6 +1,6 @@ import { SqlBuilder, DeleteData, JoinData, ToSql, isAllowedQueryColumns } from "../sqlBuilders/SqlBuilder" import { AnyTableOrView, ForUseInLeftJoin, HasAddWiths, HasIsValue, ITable, IWithView, __addWiths, __getTableOrViewPrivate, __isAllowed } from "../utils/ITableOrView" -import { IBooleanValueSource, IIfValueSource, AnyValueSource, AlwaysIfValueSource, isValueSource } from "../expressions/values" +import { IAnyBooleanValueSource, AnyValueSource, AlwaysIfValueSource, isValueSource } from "../expressions/values" import type { DeleteExpression, ExecutableDelete, DynamicExecutableDeleteExpression, DeleteExpressionAllowingNoWhere, DeleteCustomization, CustomizableExecutableDelete, ComposableCustomizableExecutableDelete, ReturnableExecutableDelete, ExecutableDeleteReturning, DeleteColumns, DeleteWhereExpression, DeleteWhereExpressionAllowingNoWhere, DeleteWhereJoinExpression, DynamicOnExpression, OnExpression, DeleteExpressionWithoutJoin, DeleteUsingExpression, DeleteWhereJoinExpressionAllowingNoWhere, DynamicOnExpressionAllowingNoWhere, OnExpressionAllowingNoWhere, DeleteExpressionWithoutJoinAllowingNoWhere, DeleteUsingExpressionAllowingNoWhere, CustomizableExecutableDeleteProjectableAsNullable } from "../expressions/delete" import ChainedError from "chained-error" import { attachSource } from "../utils/attachSource" @@ -217,7 +217,7 @@ export class DeleteQueryBuilder extends AbstractQueryBuilder implements HasAddWi this.__query = '' return this } - where(condition: IBooleanValueSource | IIfValueSource): this { + where(condition: IAnyBooleanValueSource): this { this.__finishJoin() this.__query = '' if (this.__where) { @@ -227,7 +227,7 @@ export class DeleteQueryBuilder extends AbstractQueryBuilder implements HasAddWi __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) return this } - and(condition: IBooleanValueSource | IIfValueSource): this { + and(condition: IAnyBooleanValueSource): this { this.__query = '' __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) if (this.__lastJoin) { @@ -245,7 +245,7 @@ export class DeleteQueryBuilder extends AbstractQueryBuilder implements HasAddWi } return this } - or(condition: IBooleanValueSource | IIfValueSource): this { + or(condition: IAnyBooleanValueSource): this { this.__query = '' __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) if (this.__lastJoin) { @@ -332,7 +332,7 @@ export class DeleteQueryBuilder extends AbstractQueryBuilder implements HasAddWi this.__query = '' return this } - on(condition: IBooleanValueSource | IIfValueSource): any { + on(condition: IAnyBooleanValueSource): any { this.__query = '' if (!this.__lastJoin) { throw new Error('Illegal state') diff --git a/src/queryBuilders/InsertQueryBuilder.ts b/src/queryBuilders/InsertQueryBuilder.ts index 8bbc125..1d5eb7d 100644 --- a/src/queryBuilders/InsertQueryBuilder.ts +++ b/src/queryBuilders/InsertQueryBuilder.ts @@ -6,7 +6,7 @@ import { __getColumnOfObject, __getColumnPrivate } from "../utils/Column" import ChainedError from "chained-error" import { attachSource } from "../utils/attachSource" import { from, resultType, source, type, using } from "../utils/symbols" -import { AlwaysIfValueSource, AnyValueSource, asAlwaysIfValueSource, IBooleanValueSource, IExecutableSelectQuery, IIfValueSource, IStringValueSource, isValueSource, __getValueSourcePrivate } from "../expressions/values" +import { AlwaysIfValueSource, AnyValueSource, asAlwaysIfValueSource, IExecutableSelectQuery, IAnyBooleanValueSource, IStringValueSource, isValueSource, __getValueSourcePrivate } from "../expressions/values" import { __addWiths } from "../utils/ITableOrView" import { AbstractQueryBuilder, __setQueryMetadata } from "./AbstractQueryBuilder" import type { RawFragment } from "../utils/RawFragment" @@ -1804,7 +1804,7 @@ export class InsertQueryBuilder extends AbstractQueryBuilder implements HasAddWi this.__query = '' return this } - where(condition: IBooleanValueSource | IIfValueSource): this { + where(condition: IAnyBooleanValueSource): this { this.__query = '' if (this.__onConflictUpdateSets) { @@ -1826,7 +1826,7 @@ export class InsertQueryBuilder extends AbstractQueryBuilder implements HasAddWi } return this } - and(condition: IBooleanValueSource | IIfValueSource): this { + and(condition: IAnyBooleanValueSource): this { this.__query = '' if (this.__onConflictUpdateSets) { if (!this.__onConflictUpdateWhere) { @@ -1849,7 +1849,7 @@ export class InsertQueryBuilder extends AbstractQueryBuilder implements HasAddWi } return this } - or(condition: IBooleanValueSource | IIfValueSource): this { + or(condition: IAnyBooleanValueSource): this { this.__query = '' if (this.__onConflictUpdateSets) { if (!this.__onConflictUpdateWhere) { diff --git a/src/queryBuilders/SelectQueryBuilder.ts b/src/queryBuilders/SelectQueryBuilder.ts index 5c357af..f3c6831 100644 --- a/src/queryBuilders/SelectQueryBuilder.ts +++ b/src/queryBuilders/SelectQueryBuilder.ts @@ -1,7 +1,7 @@ import { SqlBuilder, JoinData, ToSql, SelectData, CompoundOperator, CompoundSelectData, PlainSelectData, QueryColumns, isAllowedQueryColumns, OrderByEntry } from "../sqlBuilders/SqlBuilder" import type { SelectExpression, SelectColumns, OrderByMode, SelectExpressionSubquery, ExecutableSelectExpressionWithoutWhere, DynamicWhereExecutableSelectExpression, GroupByOrderByExecutableSelectExpression, OffsetExecutableSelectExpression, DynamicWhereExpressionWithoutSelect, /*SelectExpressionFromNoTable,*/ SelectWhereJoinExpression, DynamicOnExpression, OnExpression, SelectExpressionWithoutJoin, SelectWhereExpression, OrderByExecutableSelectExpression, GroupByOrderByHavingExecutableSelectExpression, DynamicHavingExecutableSelectExpression, GroupByOrderHavingByExpressionWithoutSelect, DynamicHavingExpressionWithoutSelect, ICompoundableSelect, CompoundableCustomizableExecutableSelectExpression, CompoundedExecutableSelectExpression, ExecutableSelect, WithableExecutableSelect, SelectCustomization, WhereableExecutableSelectExpressionWithGroupBy, DynamicWhereExecutableSelectExpressionWithGroupBy, GroupByOrderByHavingExecutableSelectExpressionWithoutWhere, DynamicHavingExecutableSelectExpressionWithoutWhere, DynamicWhereSelectExpressionWithoutSelect, CompoundableExecutableSelectExpression, CompoundedOrderByExecutableSelectExpression, CompoundedOffsetExecutableSelectExpression, CompoundedCustomizableExecutableSelect, OrderableExecutableSelectExpressionWithoutWhere, OrderByExecutableSelectExpressionWithoutWhere, OffsetExecutableSelectExpressionWithoutWhere, CompoundableCustomizableExpressionWithoutWhere, DynamicWhereLimitExecutableSelectExpression, DynamicWhereCompoundableCustomizableExecutableSelectExpression, WithableExecutableSelectWithoutWhere, CompoundableExecutableSelectExpressionWithoutWhere, CompoundableCustomizableExecutableSelectExpressionWitoutWhere, WhereableCompoundableExecutableSelectExpressionWithoutWhere, RecursivelyConnectedExecutableSelectExpression, RecursivelyConnectedExpressionWithoutSelect, RecursivelyConnectedExecutableSelectExpressionWithoutWhere, CompoundedLimitExecutableSelectExpression, CompoundedOrderedExecutableSelectExpression, LimitExecutableSelectExpression, OrderedExecutableSelectExpression, LimitExecutableSelectExpressionWithoutWhere, OrderedExecutableSelectExpressionWithoutWhere, RecursivelyConnectedSelectWhereExpression, ConnectByExpression, OrderByExecutableSelectExpressionProjectableAsNullable, GroupByOrderByExecutableSelectExpressionProjectableAsNullable, WhereableExecutableSelectExpressionWithGroupByProjectableAsNullable } from "../expressions/select" import { AnyTableOrView, ForUseInLeftJoin, HasAddWiths, HasIsValue, IWithView, __getOldValues, __getValuesForInsert, __isAllowed, __registerRequiredColumn, __registerTableOrView } from "../utils/ITableOrView" -import { IIfValueSource, IBooleanValueSource, INumberValueSource, IExecutableSelectQuery, AnyValueSource, AlwaysIfValueSource, isValueSource } from "../expressions/values" +import { IAnyBooleanValueSource, IBooleanValueSource, INumberValueSource, IExecutableSelectQuery, AnyValueSource, AlwaysIfValueSource, isValueSource } from "../expressions/values" import { __addWiths, __getTableOrViewPrivate } from "../utils/ITableOrView" import { __getValueSourcePrivate } from "../expressions/values" import ChainedError from "chained-error" @@ -862,7 +862,7 @@ export class SelectQueryBuilder extends AbstractSelect implements ToSql, PlainSe this.__query = '' return this } - on(condition: IBooleanValueSource | IIfValueSource): any { + on(condition: IAnyBooleanValueSource): any { this.__query = '' if (!this.__lastJoin) { throw new Error('Illegal state') @@ -883,7 +883,7 @@ export class SelectQueryBuilder extends AbstractSelect implements ToSql, PlainSe this.__query = '' return this } - where(condition: IBooleanValueSource | IIfValueSource): any { + where(condition: IAnyBooleanValueSource): any { this.__finishJoinHaving() this.__query = '' if (this.__where) { @@ -893,7 +893,7 @@ export class SelectQueryBuilder extends AbstractSelect implements ToSql, PlainSe __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) return this } - and(condition: IBooleanValueSource | IIfValueSource): any { + and(condition: IAnyBooleanValueSource): any { this.__query = '' __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) if (this.__lastJoin) { @@ -919,7 +919,7 @@ export class SelectQueryBuilder extends AbstractSelect implements ToSql, PlainSe } return this } - or(condition: IBooleanValueSource | IIfValueSource): any { + or(condition: IAnyBooleanValueSource): any { this.__query = '' __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) if (this.__lastJoin) { @@ -951,7 +951,7 @@ export class SelectQueryBuilder extends AbstractSelect implements ToSql, PlainSe this.__inHaving = true return this } - having(condition: IBooleanValueSource | IIfValueSource): any { + having(condition: IAnyBooleanValueSource): any { this.__finishJoinHaving() this.__query = '' this.__inHaving = true @@ -980,7 +980,7 @@ export class SelectQueryBuilder extends AbstractSelect implements ToSql, PlainSe } return this } - startWith(condition: IBooleanValueSource | IIfValueSource): any { + startWith(condition: IAnyBooleanValueSource): any { this.__finishJoinHaving() this.__query = '' if (this.__startWith) { diff --git a/src/queryBuilders/UpdateQueryBuilder.ts b/src/queryBuilders/UpdateQueryBuilder.ts index 9478c37..166a1cb 100644 --- a/src/queryBuilders/UpdateQueryBuilder.ts +++ b/src/queryBuilders/UpdateQueryBuilder.ts @@ -1,6 +1,6 @@ import { isAllowedQueryColumns, JoinData, SqlBuilder, ToSql, UpdateData } from "../sqlBuilders/SqlBuilder" import { AnyTableOrView, ForUseInLeftJoin, HasAddWiths, HasIsValue, ITable, IWithView, __getTableOrViewPrivate, __isAllowed } from "../utils/ITableOrView" -import { AlwaysIfValueSource, AnyValueSource, IBooleanValueSource, IIfValueSource, isValueSource } from "../expressions/values" +import { AlwaysIfValueSource, AnyValueSource, IAnyBooleanValueSource, isValueSource } from "../expressions/values" import type { UpdateExpression, ExecutableUpdate, ExecutableUpdateExpression, DynamicExecutableUpdateExpression, UpdateExpressionAllowingNoWhere, NotExecutableUpdateExpression, CustomizableExecutableUpdate, UpdateCustomization, CustomizableExecutableUpdateReturning, ReturnableExecutableUpdate, ExecutableUpdateReturning, UpdateColumns, UpdateSetExpression, UpdateSetExpressionAllowingNoWhere, UpdateSetJoinExpression, DynamicOnExpression, OnExpression, UpdateExpressionWithoutJoin, UpdateFromExpression, UpdateSetJoinExpressionAllowingNoWhere, DynamicOnExpressionAllowingNoWhere, OnExpressionAllowingNoWhere, UpdateExpressionWithoutJoinAllowingNoWhere, UpdateFromExpressionAllowingNoWhere, ShapedUpdateSetExpression, ShapedUpdateSetExpressionAllowingNoWhere, ShapedExecutableUpdateExpression, ShapedNotExecutableUpdateExpression, CustomizableExecutableUpdateProjectableAsNullable } from "../expressions/update" import ChainedError from "chained-error" import { attachSource } from "../utils/attachSource" @@ -797,7 +797,7 @@ export class UpdateQueryBuilder extends AbstractQueryBuilder implements HasAddWi this.__query = '' return this } - where(condition: IBooleanValueSource | IIfValueSource): this { + where(condition: IAnyBooleanValueSource): this { this.__query = '' if (this.__where) { throw new Error('Illegal state') @@ -806,7 +806,7 @@ export class UpdateQueryBuilder extends AbstractQueryBuilder implements HasAddWi __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) return this } - and(condition: IBooleanValueSource | IIfValueSource): this { + and(condition: IAnyBooleanValueSource): this { this.__query = '' __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) if (this.__lastJoin) { @@ -824,7 +824,7 @@ export class UpdateQueryBuilder extends AbstractQueryBuilder implements HasAddWi } return this } - or(condition: IBooleanValueSource | IIfValueSource): this { + or(condition: IAnyBooleanValueSource): this { this.__query = '' __getValueSourcePrivate(condition).__addWiths(this.__sqlBuilder, this.__withs) if (this.__lastJoin) { @@ -911,7 +911,7 @@ export class UpdateQueryBuilder extends AbstractQueryBuilder implements HasAddWi this.__query = '' return this } - on(condition: IBooleanValueSource | IIfValueSource): any { + on(condition: IAnyBooleanValueSource): any { this.__query = '' if (!this.__lastJoin) { throw new Error('Illegal state') diff --git a/src/utils/ITableOrView.ts b/src/utils/ITableOrView.ts index 42428a4..5baa1dc 100644 --- a/src/utils/ITableOrView.ts +++ b/src/utils/ITableOrView.ts @@ -6,10 +6,6 @@ export interface HasSource { [source]: SOURCE } -export interface AvailableIn { - [source]: SOURCE -} - export interface OfDB { [source]: NDBWithType }