@@ -31,6 +31,9 @@ import { Mixin } from "../Mixin";
3131/** @inline */
3232type VariableLike = Variable | Literal | PropertyRef ;
3333
34+ /** @inline */
35+ type WhereInputOrTarget = Predicate | Variable | PropertyRef | undefined ;
36+
3437export abstract class WithWhere extends Mixin {
3538 protected whereSubClause : Where | undefined ;
3639
@@ -39,25 +42,22 @@ export abstract class WithWhere extends Mixin {
3942 */
4043 public where ( input : Predicate | undefined ) : this;
4144 public where ( target : Variable | PropertyRef , params : Record < string , VariableLike > ) : this;
42- public where ( input : Predicate | Variable | PropertyRef | undefined , params ?: Record < string , VariableLike > ) : this {
43- this . updateOrCreateWhereClause ( input , params ) ;
45+ public where ( inputOrTarget : WhereInputOrTarget , params ?: Record < string , VariableLike > ) : this {
46+ this . updateOrCreateWhereClause ( inputOrTarget , params ) ;
4447 return this ;
4548 }
4649
4750 /** Shorthand for `AND` operation after a `WHERE` subclause
4851 */
4952 public and ( input : Predicate | undefined ) : this;
5053 public and ( target : Variable | PropertyRef , params : Record < string , VariableLike > ) : this;
51- public and ( input : Predicate | Variable | PropertyRef | undefined , params ?: Record < string , VariableLike > ) : this {
52- this . updateOrCreateWhereClause ( input , params ) ;
54+ public and ( inputOrTarget : WhereInputOrTarget , params ?: Record < string , VariableLike > ) : this {
55+ this . updateOrCreateWhereClause ( inputOrTarget , params ) ;
5356 return this ;
5457 }
5558
56- private updateOrCreateWhereClause (
57- input : Predicate | Variable | PropertyRef | undefined ,
58- params ?: Record < string , VariableLike >
59- ) : void {
60- const whereInput = this . createWhereInput ( input , params ) ;
59+ private updateOrCreateWhereClause ( inputOrTarget : WhereInputOrTarget , params ?: Record < string , VariableLike > ) : void {
60+ const whereInput = this . createWhereInput ( inputOrTarget , params ) ;
6161 if ( ! whereInput ) {
6262 return ;
6363 }
@@ -71,17 +71,17 @@ export abstract class WithWhere extends Mixin {
7171 }
7272
7373 private createWhereInput (
74- input : Predicate | Variable | PropertyRef | undefined ,
74+ inputOrTarget : WhereInputOrTarget ,
7575 params : Record < string , VariableLike > | undefined
7676 ) : Predicate | undefined {
77- if ( ! input ) {
77+ if ( ! inputOrTarget ) {
7878 return undefined ;
7979 }
80- if ( input instanceof Variable || input instanceof PropertyRef ) {
81- const generatedOp = this . variableAndObjectToOperation ( input , params ?? { } ) ;
80+ if ( inputOrTarget instanceof Variable || inputOrTarget instanceof PropertyRef ) {
81+ const generatedOp = this . variableAndObjectToOperation ( inputOrTarget , params ?? { } ) ;
8282 return generatedOp ;
8383 }
84- return input ;
84+ return inputOrTarget ;
8585 }
8686
8787 /** Transforms a simple input into an operation sub tree */
0 commit comments