-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3252 from SeedCompany/bugfix/filter-merge
- Loading branch information
Showing
7 changed files
with
85 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
ParameterBag, | ||
Precedence, | ||
stringCons, | ||
WhereOp, | ||
} from 'cypher-query-builder'; | ||
import { AnyConditions } from 'cypher-query-builder/dist/typings/clauses/where-utils'; | ||
|
||
export class WhereAndList extends WhereOp { | ||
constructor(public conditions: AnyConditions[]) { | ||
super(); | ||
} | ||
|
||
evaluate(params: ParameterBag, precedence = Precedence.None, name = '') { | ||
// If this operator will not be used, precedence should not be altered | ||
const newPrecedence = | ||
this.conditions.length < 2 ? precedence : Precedence.And; | ||
const strings = this.conditions.map((condition) => | ||
stringCons(params, condition, newPrecedence, name), | ||
); | ||
|
||
const string = strings.join(' AND '); | ||
const braces = precedence !== 0 && precedence > newPrecedence; | ||
return braces ? `(${string})` : string; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters