-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dca3c12
commit 1605493
Showing
7 changed files
with
164 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,44 @@ | ||
import { InsertBuilder } from 'sij-core'; | ||
import { InsertBuilder, QueryBuilder } from 'sij-core'; | ||
import { PgExtension } from '../ast'; | ||
import { TableOf, TypedAst, UnQualifiedTable, WithAlias } from 'sij-core/util'; | ||
import { Expr } from 'sij-core/ast'; | ||
import { DefaultValue, Expr } from 'sij-core/ast'; | ||
|
||
class PgInsertBuilder<Schema, Table, Return> extends InsertBuilder<Schema, Table, Return, PgExtension> {} | ||
class PgInsertBuilder<Schema, Table, Return> extends InsertBuilder<Schema, Table, Return, PgExtension> { | ||
override apply<T>(fn: (arg: PgInsertBuilder<Schema, Table, Return>) => T): T { | ||
return fn(this); | ||
} | ||
|
||
override lit<Return extends number | string | boolean | null>( | ||
l: Return, | ||
): TypedAst<Schema, Return, Expr<PgExtension>> { | ||
return super.lit(l); | ||
} | ||
|
||
override values( | ||
...vs: Array<{ [Key in keyof Table]?: Table[Key] | DefaultValue | TypedAst<Schema, Table[Key], Expr<PgExtension>> }> | ||
): Omit<PgInsertBuilder<Schema, Table, Return>, 'fromQuery' | 'columns'> { | ||
return super.values(...vs); | ||
} | ||
|
||
override values1( | ||
...vs: Array<{ [Key in keyof Table]?: Table[Key] | DefaultValue | TypedAst<Schema, Table[Key], Expr<PgExtension>> }> | ||
): Omit<PgInsertBuilder<Schema, Table, Return>, 'fromQuery' | 'columns'> { | ||
return super.values1(...vs); | ||
} | ||
|
||
override columns(...columns: Array<keyof Table>): Omit<PgInsertBuilder<Schema, Table, Return>, 'columns'> { | ||
return super.columns(...columns); | ||
} | ||
|
||
override fromQuery<QReturn extends { [Key in keyof Table]?: Table[Key] }>( | ||
query: QueryBuilder<Schema, any, QReturn, PgExtension>, | ||
): Omit<PgInsertBuilder<Schema, Table, Return>, 'values' | 'values1' | 'columns'> { | ||
return super.fromQuery(query); | ||
} | ||
} | ||
// Merges with above class to provide calling as a function | ||
interface PgInsertBuilder<Schema, Table, Return> extends InsertBuilder<Schema, Table, Return, PgExtension> { | ||
<T>(fn: (arg: PgInsertBuilder<Schema, Table, Return>) => T): T; | ||
} | ||
|
||
export { PgInsertBuilder }; |
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
Oops, something went wrong.