-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add ability for escaping for Raw() find operator (#6850)
* feat: add ability for escaping for Raw() find operator * fix: update Raw() find operator * fix: fix tests for Raw() find operator * feat: add ability for escaping with object literal parameters for Raw() find operator * docs: correct the example comment of Raw() find operator * fix: delete redundant functional
- Loading branch information
Showing
4 changed files
with
155 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,32 @@ | ||
import {FindOperator} from "../FindOperator"; | ||
import {ObjectLiteral} from "../../common/ObjectLiteral"; | ||
|
||
/** | ||
* Find Options Operator. | ||
* Example: { someField: Raw([...]) } | ||
* Example: { someField: Raw("12") } | ||
*/ | ||
export function Raw<T>(value: string|((columnAlias: string) => string)): FindOperator<any> { | ||
return new FindOperator("raw", value as any, false); | ||
export function Raw<T>(value: string): FindOperator<any>; | ||
|
||
/** | ||
* Find Options Operator. | ||
* Example: { someField: Raw((columnAlias) => `${columnAlias} = 5`) } | ||
*/ | ||
export function Raw<T>(sqlGenerator: ((columnAlias: string) => string)): FindOperator<any>; | ||
|
||
/** | ||
* Find Options Operator. | ||
* For escaping parameters use next syntax: | ||
* Example: { someField: Raw((columnAlias) => `${columnAlias} = :value`, { value: 5 }) } | ||
*/ | ||
export function Raw<T>(sqlGenerator: ((columnAlias: string) => string), parameters: ObjectLiteral): FindOperator<any>; | ||
|
||
export function Raw<T>( | ||
valueOrSqlGenerator: string | ((columnAlias: string) => string), | ||
sqlGeneratorParameters?: ObjectLiteral, | ||
): FindOperator<any> { | ||
if (typeof valueOrSqlGenerator !== 'function') { | ||
return new FindOperator("raw", valueOrSqlGenerator, false); | ||
} | ||
|
||
return new FindOperator("raw", [], true, true, valueOrSqlGenerator, sqlGeneratorParameters); | ||
} |
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