Skip to content

Commit

Permalink
feat: allow column name in where and having clauses to be a raw query
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Nov 8, 2021
1 parent ed3023a commit 781add7
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 54 deletions.
22 changes: 11 additions & 11 deletions adonis-typings/querybuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ declare module '@ioc:Adonis/Lucid/Database' {
/**
* Key-value pair. The value can also be a subquery
*/
(key: string, value: StrictValues | ChainableContract): Builder
(key: string, operator: string, value: StrictValues | ChainableContract): Builder
(key: string | RawQuery, value: StrictValues | ChainableContract): Builder
(key: string | RawQuery, operator: string, value: StrictValues | ChainableContract): Builder
}

/**
Expand All @@ -152,8 +152,8 @@ declare module '@ioc:Adonis/Lucid/Database' {
/**
* Key-value pair.
*/
(column: string, comparisonColumn: string): Builder
(column: string, operator: string, comparisonColumn: string): Builder
(column: string | RawQuery, comparisonColumn: string): Builder
(column: string | RawQuery, operator: string, comparisonColumn: string): Builder
}

/**
Expand All @@ -163,7 +163,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
/**
* Column name and array of values
*/
(K: string, value: StrictValues[]): Builder
(K: string | RawQuery, value: StrictValues[]): Builder

/**
* Column names and array of values as an 2d array
Expand All @@ -175,7 +175,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* results
*/
(
k: string,
k: string | RawQuery,
subquery: ChainableContract | QueryCallback<Builder> | RawBuilderContract | RawQuery
): Builder

Expand All @@ -189,7 +189,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Possible signatures for adding whereNull clause.
*/
interface WhereNull<Builder extends ChainableContract> {
(key: string): Builder
(key: string | RawQuery): Builder
}

/**
Expand All @@ -207,7 +207,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Accept any string as a key for supporting prefix columns
*/
(
key: string,
key: string | RawQuery,
value: [StrictValues | ChainableContract, StrictValues | ChainableContract]
): Builder
}
Expand Down Expand Up @@ -331,7 +331,7 @@ declare module '@ioc:Adonis/Lucid/Database' {
* Key operator and value. Value can be a subquery as well
*/
(
key: string,
key: string | RawQuery,
operator: string,
value: StrictValues | ChainableContract | RawBuilderContract | RawQuery
): Builder
Expand All @@ -346,14 +346,14 @@ declare module '@ioc:Adonis/Lucid/Database' {
* subqueries.
*/
(
key: string,
key: string | RawQuery,
value: (StrictValues | ChainableContract | RawBuilderContract | RawQuery)[]
): Builder

/**
* Key, along with a query callback
*/
(key: string, callback: QueryCallback<Builder>): Builder
(key: string | RawQuery, callback: QueryCallback<Builder>): Builder
}

/**
Expand Down
Loading

0 comments on commit 781add7

Please sign in to comment.