Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ff00ff/mammoth

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ff00ff/mammoth - npm Package Compare versions

Comparing version 2.0.0-beta.7 to 2.0.0-beta.8

.build/bootstrap.d.ts

13

.build/case.d.ts
import { BooleanQuery, Query } from './query';
import { Expression } from './expression';
import { Token } from './tokens';
import { Expression } from './expression';
export declare class CaseStatement<DataType> {
import { DbConfig } from './config';
export declare class CaseStatement<Config extends DbConfig, DataType, IsNotNull extends boolean = false> {
private readonly tokens;
constructor(tokens: Token[]);
when<Q extends Query<any>>(expression: Expression<boolean, boolean, string> | BooleanQuery<Q>): {
then<T>(result: T): CaseStatement<DataType | T>;
when<Q extends Query<any>>(expression: Expression<Config, boolean, boolean, string> | BooleanQuery<Config, Q>): {
then<T>(result: T): CaseStatement<Config, DataType | T, false>;
};
else<T>(result: T): CaseStatement<DataType | T>;
end(): Expression<DataType, true, 'case'>;
else<T>(result: T): CaseStatement<Config, DataType | T, true>;
end(): Expression<Config, DataType, IsNotNull, 'case'>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CaseStatement = void 0;
const expression_1 = require("./expression");
const tokens_1 = require("./tokens");
const expression_1 = require("./expression");
class CaseStatement {

@@ -32,5 +32,5 @@ constructor(tokens) {

end() {
return new expression_1.Expression(this.tokens, `case`);
return new expression_1.InternalExpression(this.tokens, `case`);
}
}
exports.CaseStatement = CaseStatement;

@@ -1,3 +0,5 @@

import { Expression } from './expression';
import { Expression, InternalExpression } from './expression';
import { DbConfig } from './config';
import { TableDefinition } from './table';
import { Uuid } from './data-types';
export interface ColumnDefinitionFormat {

@@ -15,16 +17,21 @@ dataType: string;

}
export interface ColumnDefinition<DataType, IsNotNull extends boolean = false, HasDefault extends boolean = false> {
notNull(): ColumnDefinition<DataType, true, HasDefault>;
primaryKey(): ColumnDefinition<DataType, true, HasDefault>;
default<IsAlwaysSettingAValue extends boolean = true>(expression: string): ColumnDefinition<DataType, IsNotNull, IsAlwaysSettingAValue>;
check(expression: string): ColumnDefinition<DataType, IsNotNull, HasDefault>;
unique(): ColumnDefinition<DataType, IsNotNull, HasDefault>;
references<T extends TableDefinition<any>, ColumnName extends T extends TableDefinition<infer Columns> ? keyof Columns extends string ? keyof Columns : never : never>(table: T, columnName: ColumnName): ColumnDefinition<DataType, IsNotNull, HasDefault>;
referencesSelf(columnName: string): ColumnDefinition<DataType, IsNotNull, HasDefault>;
export interface ColumnDefinition<DataType, IsNotNull extends boolean = false, HasDefault extends boolean = false, IsPrimaryKey extends boolean = false> {
notNull(): ColumnDefinition<DataType, true, HasDefault, IsPrimaryKey>;
primaryKey(): ColumnDefinition<DataType, true, HasDefault, true>;
default(expression: string): ColumnDefinition<DataType, IsNotNull, true, IsPrimaryKey>;
check(expression: string): ColumnDefinition<DataType, IsNotNull, HasDefault, IsPrimaryKey>;
unique(): ColumnDefinition<DataType, IsNotNull, HasDefault, IsPrimaryKey>;
references<T extends TableDefinition<any>, ColumnName extends T extends TableDefinition<infer Columns> ? keyof Columns extends string ? keyof Columns : never : never>(table: T, columnName: ColumnName): ColumnDefinition<DataType extends Uuid<any> ? Uuid<T> : DataType, IsNotNull, HasDefault, IsPrimaryKey>;
referencesSelf(columnName: string): ColumnDefinition<DataType, IsNotNull, HasDefault, IsPrimaryKey>;
}
export declare const makeColumnDefinition: <DataType, IsNotNull extends boolean = false, HasDefault extends boolean = false>(dataType: string, enumValues?: string[] | undefined) => ColumnDefinition<DataType, IsNotNull, HasDefault>;
export declare const makeColumnDefinition: <DataType, IsNotNull extends boolean = false, HasDefault extends boolean = false>(dataType: string, enumValues?: string[] | undefined) => ColumnDefinition<DataType, IsNotNull, HasDefault, false>;
export declare class ColumnSet<Columns> {
private _columnSetBrand;
}
export declare class Column<Name extends string, TableName, DataType, IsNotNull extends boolean, HasDefault extends boolean, JoinType> extends Expression<DataType, IsNotNull, Name> {
export interface SharedColumn<Config extends DbConfig, Name extends string, TableName, DataType, IsNotNull extends boolean, HasDefault extends boolean, JoinType> {
as<AliasName extends string>(alias: AliasName): Column<Config, AliasName, TableName, DataType, IsNotNull, HasDefault, JoinType>;
}
export declare type AnyColumn = Column<any, any, any, any, any, any, any>;
export declare type Column<Config extends DbConfig, Name extends string, TableName, DataType, IsNotNull extends boolean, HasDefault extends boolean, JoinType> = SharedColumn<Config, Name, TableName, DataType, IsNotNull, HasDefault, JoinType> & Expression<Config, DataType, IsNotNull, Name>;
export declare class InternalColumn<Config extends DbConfig, Name extends string, TableName, DataType, IsNotNull extends boolean, HasDefault extends boolean, JoinType> extends InternalExpression<Config, DataType, IsNotNull, Name> {
private readonly columnName;

@@ -35,3 +42,3 @@ private readonly tableName;

constructor(columnName: Name, tableName: TableName, originalColumnName: string | undefined);
as<AliasName extends string>(alias: AliasName): Column<AliasName, TableName, DataType, IsNotNull, HasDefault, JoinType>;
as<AliasName extends string>(alias: AliasName): Column<Config, AliasName, TableName, DataType, IsNotNull, HasDefault, JoinType>;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Column = exports.ColumnSet = exports.makeColumnDefinition = void 0;
exports.InternalColumn = exports.ColumnSet = exports.makeColumnDefinition = void 0;
const expression_1 = require("./expression");
const tokens_1 = require("./tokens");
const naming_1 = require("./naming");
const expression_1 = require("./expression");
const makeColumnDefinition = (dataType, enumValues) => {

@@ -72,3 +72,3 @@ let isNotNull = false;

exports.ColumnSet = ColumnSet;
class Column extends expression_1.Expression {
class InternalColumn extends expression_1.InternalExpression {
constructor(columnName, tableName, originalColumnName) {

@@ -95,3 +95,3 @@ super(originalColumnName

as(alias) {
return new Column(alias, this.tableName, this.columnName);
return new InternalColumn(alias, this.tableName, this.columnName);
}

@@ -120,2 +120,2 @@ /** @internal */

}
exports.Column = Column;
exports.InternalColumn = InternalColumn;

@@ -0,3 +1,28 @@

import { Uuid } from './data-types';
export interface DefaultDbConfig {
Null: null;
Int4: number;
Int8: string;
Float4: number;
Float8: number;
Numeric: string;
Text: string;
Date: Date;
DateTime: Date;
Time: string;
}
export declare type NullType = Extract<keyof DefaultDbConfig, 'NullType'> extends never ? null : DefaultDbConfig[Extract<keyof DefaultDbConfig, 'NullType'>];
export interface DbConfig {
Null: any;
Int4: any;
Int8: any;
Float4: any;
Float8: any;
Numeric: any;
Text: any;
Date: any;
DateTime: any;
Time: any;
}
declare type GetSingleResultType<Config extends DbConfig, T> = T extends Uuid<any> ? string : T extends keyof Config ? Config[T] : T;
export declare type GetResultType<Config extends DbConfig, T> = T extends Array<any> ? GetSingleResultType<Config, T[number]>[] : GetSingleResultType<Config, T>;
export {};
/// <reference types="node" />
import { ColumnDefinition } from './column';
export declare type Int4 = number;
export declare type Int8 = string;
export declare type Float4 = number;
export declare type Float8 = number;
export declare type Numeric = string;
export declare type GetNotNull<Left, Right> = Right extends true ? Left extends true ? true : false : false;
export declare type GetMostSignificantDataType<Left, Right> = Left & Right extends Float8 ? Float8 : Left extends Float4 ? Right extends Float4 ? Float4 : Left & Right extends Float4 ? Float8 : Left & Right extends Numeric ? Numeric : Left & Right extends Int8 ? Int8 : Int4 : Left & Right extends Float4 ? Float8 : Left & Right extends Numeric ? Numeric : Left & Right extends Int8 ? Int8 : Int4;
export declare type Int4 = 'Int4';
export declare type Int8 = 'Int8';
export declare type Float4 = 'Float4';
export declare type Float8 = 'Float8';
export declare type Numeric = 'Numeric';
export declare type AnyNumber = Int4 | Int8 | Float4 | Float8 | Numeric;
export declare function dataType<T>(dataType: string): ColumnDefinition<T, false, false>;
export declare type Text = 'Text';
export declare type Date = 'Date';
export declare type DateTime = 'DateTime';
export declare type Any = AnyNumber | Text | Date | DateTime;
export declare type Uuid<T> = InternalUuid<T>;
export declare class InternalUuid<T> {
private _uuidBrand;
}
export declare type ToPostgresDataType<T extends string> = T extends DateTime ? 'timestamptz' : Lowercase<T>;
export declare function dataType<T>(dataType: string): ColumnDefinition<T, false, false, false>;
export declare function int8(): ColumnDefinition<Int8>;

@@ -18,2 +29,10 @@ export declare function int8<T>(): ColumnDefinition<T>;

export declare function serial8<T>(): ColumnDefinition<T, false, true>;
export declare function serial(): ColumnDefinition<Int4, false, true>;
export declare function serial<T>(): ColumnDefinition<T, false, true>;
export declare function serial4(): ColumnDefinition<Int4, false, true>;
export declare function serial4<T>(): ColumnDefinition<T, false, true>;
export declare function smallserial(): ColumnDefinition<Int4, false, true>;
export declare function smallserial<T>(): ColumnDefinition<T, false, true>;
export declare function serial2(): ColumnDefinition<Int4, false, true>;
export declare function serial2<T>(): ColumnDefinition<T, false, true>;
export declare function bit(n?: number): ColumnDefinition<string>;

@@ -33,9 +52,9 @@ export declare function bit<T>(n?: number): ColumnDefinition<T>;

export declare function bytea<T>(): ColumnDefinition<T>;
export declare function character(n?: number): ColumnDefinition<string>;
export declare function character(n?: number): ColumnDefinition<Text>;
export declare function character<T>(n?: number): ColumnDefinition<T>;
export declare function char(n?: number): ColumnDefinition<string>;
export declare function char(n?: number): ColumnDefinition<Text>;
export declare function char<T>(n?: number): ColumnDefinition<T>;
export declare function characterVarying(n?: number): ColumnDefinition<string>;
export declare function characterVarying(n?: number): ColumnDefinition<Text>;
export declare function characterVarying<T>(n?: number): ColumnDefinition<T>;
export declare function varchar(n?: number): ColumnDefinition<string>;
export declare function varchar(n?: number): ColumnDefinition<Text>;
export declare function varchar<T>(n?: number): ColumnDefinition<T>;

@@ -50,5 +69,5 @@ export declare function circle(): ColumnDefinition<{

export declare function cidr<T>(): ColumnDefinition<T>;
export declare function caseInsensitiveText(): ColumnDefinition<string>;
export declare function caseInsensitiveText(): ColumnDefinition<Text>;
export declare function caseInsensitiveText<T>(): ColumnDefinition<T>;
export declare function citext(): ColumnDefinition<string>;
export declare function citext(): ColumnDefinition<Text>;
export declare function citext<T>(): ColumnDefinition<T>;

@@ -116,11 +135,3 @@ export declare function date(): ColumnDefinition<Date>;

export declare function int2<T>(): ColumnDefinition<T>;
export declare function serial(): ColumnDefinition<Int4, false, true>;
export declare function serial<T>(): ColumnDefinition<T, false, true>;
export declare function serial4(): ColumnDefinition<Int4, false, true>;
export declare function serial4<T>(): ColumnDefinition<T, false, true>;
export declare function smallserial(): ColumnDefinition<Int4, false, true>;
export declare function smallserial<T>(): ColumnDefinition<T, false, true>;
export declare function serial2(): ColumnDefinition<Int4, false, true>;
export declare function serial2<T>(): ColumnDefinition<T, false, true>;
export declare function text(): ColumnDefinition<string>;
export declare function text(): ColumnDefinition<Text>;
export declare function text<T>(): ColumnDefinition<T>;

@@ -147,3 +158,3 @@ export declare function time(): ColumnDefinition<string>;

export declare function txidSnapshot<T>(): ColumnDefinition<T>;
export declare function uuid(): ColumnDefinition<string>;
export declare function uuid(): ColumnDefinition<Uuid<unknown>>;
export declare function uuid<T>(): ColumnDefinition<T>;

@@ -153,3 +164,3 @@ export declare function xml(): ColumnDefinition<string>;

export declare function enumType<EnumValue>(name: string, values: readonly EnumValue[]): ColumnDefinition<EnumValue>;
export declare function array<T>(dataType: ColumnDefinition<T>): ColumnDefinition<T[], false, false>;
export declare function array2d<T>(dataType: ColumnDefinition<T>): ColumnDefinition<T[][], false, false>;
export declare function array<T>(dataType: ColumnDefinition<T>): ColumnDefinition<T[], false, false, false>;
export declare function array2d<T>(dataType: ColumnDefinition<T>): ColumnDefinition<T[][], false, false, false>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.text = exports.serial2 = exports.smallserial = exports.serial4 = exports.serial = exports.int2 = exports.smallint = exports.float4 = exports.real = exports.polygon = exports.pgLsn = exports.path = exports.point = exports.numeric = exports.money = exports.macaddr8 = exports.macaddr = exports.lseg = exports.line = exports.jsonb = exports.json = exports.interval = exports.int4 = exports.int = exports.integer = exports.decimal = exports.inet = exports.float8 = exports.doublePrecision = exports.date = exports.citext = exports.caseInsensitiveText = exports.cidr = exports.circle = exports.varchar = exports.characterVarying = exports.char = exports.character = exports.bytea = exports.box = exports.bool = exports.boolean = exports.varbit = exports.bitVarying = exports.bit = exports.serial8 = exports.bigserial = exports.bigint = exports.int8 = exports.dataType = void 0;
exports.array2d = exports.array = exports.enumType = exports.xml = exports.uuid = exports.txidSnapshot = exports.tsvector = exports.tsquery = exports.timestampWithTimeZone = exports.timestampWithoutTimeZone = exports.timestamptz = exports.timestamp = exports.timeWithTimeZone = exports.timeWithoutTimeZone = exports.time = void 0;
exports.int2 = exports.smallint = exports.float4 = exports.real = exports.polygon = exports.pgLsn = exports.path = exports.point = exports.numeric = exports.money = exports.macaddr8 = exports.macaddr = exports.lseg = exports.line = exports.jsonb = exports.json = exports.interval = exports.int4 = exports.int = exports.integer = exports.decimal = exports.inet = exports.float8 = exports.doublePrecision = exports.date = exports.citext = exports.caseInsensitiveText = exports.cidr = exports.circle = exports.varchar = exports.characterVarying = exports.char = exports.character = exports.bytea = exports.box = exports.bool = exports.boolean = exports.varbit = exports.bitVarying = exports.bit = exports.serial2 = exports.smallserial = exports.serial4 = exports.serial = exports.serial8 = exports.bigserial = exports.bigint = exports.int8 = exports.dataType = exports.InternalUuid = void 0;
exports.array2d = exports.array = exports.enumType = exports.xml = exports.uuid = exports.txidSnapshot = exports.tsvector = exports.tsquery = exports.timestampWithTimeZone = exports.timestampWithoutTimeZone = exports.timestamptz = exports.timestamp = exports.timeWithTimeZone = exports.timeWithoutTimeZone = exports.time = exports.text = void 0;
const column_1 = require("./column");
const variableLength = (string, ...n) => n.length > 0 ? `${string}(${n.join(`, `)})` : string;
const makeDataType = column_1.makeColumnDefinition;
class InternalUuid {
}
exports.InternalUuid = InternalUuid;
function dataType(dataType) {

@@ -28,2 +31,18 @@ return makeDataType(dataType);

exports.serial8 = serial8;
function serial() {
return makeDataType(`serial`);
}
exports.serial = serial;
function serial4() {
return makeDataType(`serial4`);
}
exports.serial4 = serial4;
function smallserial() {
return makeDataType(`smallserial`);
}
exports.smallserial = smallserial;
function serial2() {
return makeDataType(`serial2`);
}
exports.serial2 = serial2;
function bit(n) {

@@ -189,18 +208,2 @@ return makeDataType(variableLength(`bit`, n));

exports.int2 = int2;
function serial() {
return makeDataType(`serial`);
}
exports.serial = serial;
function serial4() {
return makeDataType(`serial4`);
}
exports.serial4 = serial4;
function smallserial() {
return makeDataType(`smallserial`);
}
exports.smallserial = smallserial;
function serial2() {
return makeDataType(`serial2`);
}
exports.serial2 = serial2;
function text() {

@@ -207,0 +210,0 @@ return makeDataType(`text`);

import * as sqlFunctions from './sql-functions';
import { Column, ColumnDefinition, ColumnDefinitionFormat } from './column';
import { DbConfig, DefaultDbConfig } from './config';
import { InsertIntoResult } from './insert';

@@ -9,8 +10,67 @@ import { SelectFn } from './select';

import { Table } from './TableType';
import { Uuid } from './data-types';
export declare const makeDefineDb: <Config extends DbConfig>() => <TableDefinitions extends {
[key: string]: TableDefinition<any>;
}>(tableDefinitions: TableDefinitions, queryExecutor: QueryExecutorFn) => {
raw<DataType, IsNotNull extends boolean = false, Name extends string = "?column?", Config_1 extends DbConfig = DefaultDbConfig>(strings: TemplateStringsArray, ...parameters: any[]): import("./expression").Expression<Config_1, DataType, IsNotNull, Name>;
star(): sqlFunctions.Star;
star<T extends unknown>(table: T): T extends Table<any, any, infer Columns> ? import("./column").ColumnSet<Columns> : never;
toSql(query: import("./query").Query<any>): {
text: string;
parameters: any[];
};
Star: typeof sqlFunctions.Star;
now: <Config_2 extends DbConfig = DefaultDbConfig>() => import("./expression").RawExpression<Config_2, Date, true, "now">;
count: <Config_3 extends DbConfig = DefaultDbConfig>(expression?: import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | import("./expression").RawExpression<any, any, any, any> | undefined) => import("./expression").NumberExpression<Config_3, "Int8", true, "count">;
stringAgg: <Config_4 extends DbConfig>(expression: import("./expression").TextExpression<Config_4, "Text", boolean, any>, delimiter: string, ...orderBy: (import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | import("./expression").RawExpression<any, any, any, any>)[]) => import("./expression").TextExpression<Config_4, "Text", false, "stringAgg">;
bitAnd: <Config_5 extends DbConfig, T_1 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_5, T_1, boolean, any>) => import("./expression").Expression<Config_5, T_1, false, "bitAnd">;
bitOr: <Config_6 extends DbConfig, T_2 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_6, T_2, boolean, any>) => import("./expression").Expression<Config_6, T_2, false, "bitOr">;
boolAnd: <Config_7 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_7, false, boolean, any> | import("./expression").BooleanExpression<Config_7, true, boolean, any>) => import("./expression").NumberExpression<Config_7, number, false, "boolAnd">;
boolOr: <Config_8 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_8, false, boolean, any> | import("./expression").BooleanExpression<Config_8, true, boolean, any>) => import("./expression").NumberExpression<Config_8, number, false, "boolOr">;
every: <Config_9 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_9, false, boolean, any> | import("./expression").BooleanExpression<Config_9, true, boolean, any>) => import("./expression").NumberExpression<Config_9, number, false, "every">;
arrayAgg: <Config_10 extends DbConfig, DataType_1>(expression: import("./expression").Expression<Config_10, DataType_1, boolean, any>) => import("./expression").RawExpression<Config_10, import("./config").GetResultType<Config_10, DataType_1>[], false, "arrayAgg">;
min: <Config_11 extends DbConfig, DataType_2>(expression: import("./expression").Expression<Config_11, DataType_2, boolean, any>) => import("./expression").Expression<Config_11, DataType_2, false, "min">;
max: <Config_12 extends DbConfig, DataType_3>(expression: import("./expression").Expression<Config_12, DataType_3, boolean, any>) => import("./expression").Expression<Config_12, DataType_3, false, "max">;
avg: <Config_13 extends DbConfig, T_3 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_13, T_3, boolean, any>) => import("./expression").Expression<Config_13, T_3, false, "avg">;
sum: <Config_14 extends DbConfig, T_4 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_14, T_4, boolean, any>) => import("./expression").Expression<Config_14, T_4 extends "Int4" ? "Int8" : T_4, false, "sum">;
xmlagg: <Config_15 extends DbConfig, DataType_4>(expression: import("./expression").Expression<Config_15, DataType_4, boolean, any>) => import("./expression").NumberExpression<Config_15, number, false, "xmlagg">;
not: <Config_16 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_16, false, boolean, string> | import("./expression").BooleanExpression<Config_16, true, boolean, string>) => import("./expression").BooleanExpression<Config_16, false, true, "?column?"> | import("./expression").BooleanExpression<Config_16, true, true, "?column?">;
and: <Config_17 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_17, false, boolean, string> | import("./expression").BooleanExpression<Config_17, true, boolean, string>) => import("./expression").BooleanExpression<Config_17, false, true, "?column?"> | import("./expression").BooleanExpression<Config_17, true, true, "?column?">;
or: <Config_18 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_18, false, boolean, string> | import("./expression").BooleanExpression<Config_18, true, boolean, string>) => import("./expression").BooleanExpression<Config_18, false, true, "?column?"> | import("./expression").BooleanExpression<Config_18, true, true, "?column?">;
group: <Config_19 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_19, false, boolean, string> | import("./expression").BooleanExpression<Config_19, true, boolean, string>) => import("./expression").BooleanExpression<Config_19, false, true, "?column?"> | import("./expression").BooleanExpression<Config_19, true, true, "?column?">;
any: <Config_20 extends DbConfig, T_5>(array: T_5[]) => import("./expression").RawExpression<Config_20, T_5, true, "?column?">;
exists: <Config_21 extends DbConfig>(expression: import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | import("./expression").RawExpression<any, any, any, any> | import("./query").Query<any>) => import("./expression").BooleanExpression<Config_21, false, true, "?column?"> | import("./expression").BooleanExpression<Config_21, true, true, "?column?">;
andNotExists: <Config_22 extends DbConfig>(expression: import("./query").Query<any> | import("./expression").BooleanExpression<Config_22, any, any, any> | import("./expression").NumberExpression<Config_22, any, any, any> | import("./expression").TextExpression<Config_22, any, any, any> | import("./expression").UuidExpression<Config_22, unknown, any, any> | import("./expression").RawExpression<Config_22, any, any, any>) => import("./expression").BooleanExpression<Config_22, false, true, "?column?"> | import("./expression").BooleanExpression<Config_22, true, true, "?column?">;
andExists: <Config_23 extends DbConfig>(expression: import("./query").Query<any> | import("./expression").BooleanExpression<Config_23, any, any, any> | import("./expression").NumberExpression<Config_23, any, any, any> | import("./expression").TextExpression<Config_23, any, any, any> | import("./expression").UuidExpression<Config_23, unknown, any, any> | import("./expression").RawExpression<Config_23, any, any, any>) => import("./expression").BooleanExpression<Config_23, false, true, "?column?"> | import("./expression").BooleanExpression<Config_23, true, true, "?column?">;
notExists: <Config_24 extends DbConfig>(expression: import("./query").Query<any> | import("./expression").BooleanExpression<Config_24, any, any, any> | import("./expression").NumberExpression<Config_24, any, any, any> | import("./expression").TextExpression<Config_24, any, any, any> | import("./expression").UuidExpression<Config_24, unknown, any, any> | import("./expression").RawExpression<Config_24, any, any, any>) => import("./expression").BooleanExpression<Config_24, false, true, "?column?"> | import("./expression").BooleanExpression<Config_24, true, true, "?column?">;
coalesce: <Config_25 extends DbConfig, DataType_5>(...expressions: (import("./expression").Expression<Config_25, DataType_5, boolean, any> | import("./config").GetResultType<Config_25, DataType_5>)[]) => import("./expression").Expression<Config_25, DataType_5, false, "coalesce">;
cast: <Config_26 extends DbConfig, T_6 extends import("./data-types").Any, IsNotNull_1 extends boolean, Name_1 extends string>(expression: import("./expression").BooleanExpression<Config_26, any, IsNotNull_1, Name_1> | import("./expression").NumberExpression<Config_26, any, IsNotNull_1, Name_1> | import("./expression").TextExpression<Config_26, any, IsNotNull_1, Name_1> | import("./expression").UuidExpression<Config_26, unknown, IsNotNull_1, Name_1> | import("./expression").RawExpression<Config_26, any, IsNotNull_1, Name_1>, dataType: import("./data-types").ToPostgresDataType<T_6>) => import("./expression").Expression<Config_26, T_6, IsNotNull_1, Name_1>;
/** @internal */
getTableDefinitions(): {
name: string;
originalDefinition: any;
columns: (ColumnDefinitionFormat & {
name: string;
})[];
}[];
select: SelectFn<Config>;
insertInto: <T_7 extends unknown>(table: T_7, columnNames?: (T_7 extends Table<Config, any, infer Columns_1> ? (keyof Columns_1)[] : never) | undefined) => T_7 extends TableDefinition<any> ? never : InsertIntoResult<Config, T_7, T_7 extends Table<Config, any, infer Columns_2> ? { [K_1 in keyof import("./types").PickByValue<{ [K in keyof Columns_2]: Columns_2[K] extends Column<Config, any, any, any, infer IsNotNull_2, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull_2 : never; }, true>]: Columns_2[K_1] extends Column<Config, any, any, infer DataType_6, boolean, any, any> ? import("./config").GetResultType<Config, DataType_6> | import("./expression").Expression<Config, DataType_6, boolean, string> | import("./expression").Expression<Config, import("./config").GetResultType<Config, DataType_6>, boolean, string> | import("./query").Query<{
[key: string]: import("./config").GetResultType<Config, DataType_6> | import("./expression").Expression<Config, DataType_6, boolean, string> | import("./expression").Expression<Config, import("./config").GetResultType<Config, DataType_6>, boolean, string>;
}> : never; } & { [K_3 in keyof import("./types").PickByValue<{ [K_2 in keyof Columns_2]: Columns_2[K_2] extends Column<Config, any, any, any, infer IsNotNull_3, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_3 : never; }, false>]?: (Columns_2[K_3] extends Column<Config, any, any, infer DataType_7, boolean, any, any> ? import("./config").GetResultType<Config, DataType_7> | import("./expression").Expression<Config, DataType_7, boolean, string> | import("./expression").Expression<Config, import("./config").GetResultType<Config, DataType_7>, boolean, string> | import("./query").Query<{
[key: string]: import("./config").GetResultType<Config, DataType_7> | import("./expression").Expression<Config, DataType_7, boolean, string> | import("./expression").Expression<Config, import("./config").GetResultType<Config, DataType_7>, boolean, string>;
}> | ("Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null") : never) | undefined; } : never>;
deleteFrom: <T_8 extends unknown>(table: T_8) => T_8 extends TableDefinition<any> ? never : import("./delete").DeleteQuery<Config, T_8, number, T_8 extends Table<any, any, infer Columns_3> ? Columns_3 : never>;
update: <T_9 extends unknown>(table: T_9) => {
set(values: T_9 extends Table<Config, any, infer Columns_4> ? { [K_4 in keyof Columns_4]?: (Columns_4[K_4] extends Column<Config, any, any, infer DataType_8, infer IsNotNull_4, any, any> ? IsNotNull_4 extends true ? import("./config").GetResultType<Config, DataType_8> | import("./expression").Expression<Config, DataType_8, boolean, any> | import("./expression").Expression<Config, import("./config").GetResultType<Config, DataType_8>, boolean, any> : ("Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null") | import("./config").GetResultType<Config, DataType_8> | import("./expression").Expression<Config, DataType_8, boolean, any> | import("./expression").Expression<Config, import("./config").GetResultType<Config, DataType_8>, boolean, any> | import("./expression").Expression<Config, "Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null", boolean, any> : never) | undefined; } : never): import("./update").UpdateQuery<Config, T_9, number, T_9 extends Table<Config, any, infer Columns_5> ? Columns_5 : never>;
};
with: import("./with").WithFn<Config>;
truncate: <T_10 extends unknown>(table: T_10) => T_10 extends TableDefinition<any> ? never : import("./truncate").TruncateQuery<T_10, number>;
case: () => CaseStatement<Config, never, false>;
} & { [TableName in keyof TableDefinitions]: TableDefinitions[TableName] extends TableDefinition<infer ColumnDefinitions> ? Table<Config, TableName, { [K_5 in keyof ColumnDefinitions]: K_5 extends string ? Column<Config, K_5, TableName, ColumnDefinitions[K_5] extends ColumnDefinition<infer DataType_9, any, any, infer IsPrimaryKey> ? DataType_9 extends Uuid<any> ? IsPrimaryKey extends true ? Uuid<TableDefinitions[TableName]> : DataType_9 : DataType_9 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, infer IsNotNull_5, any, false> ? IsNotNull_5 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, any, infer HasDefault_2, false> ? HasDefault_2 : never, undefined> : never; }> : never; };
export declare const defineDb: <TableDefinitions extends {
[key: string]: TableDefinition<any>;
}>(tableDefinitions: TableDefinitions, queryExecutor: QueryExecutorFn) => {
raw<DataType, IsNotNull extends boolean = false, Name extends string = "?column?">(strings: TemplateStringsArray, ...parameters: any[]): import("./expression").Expression<DataType, IsNotNull, Name>;
raw<DataType, IsNotNull extends boolean = false, Name extends string = "?column?", Config extends DbConfig = DefaultDbConfig>(strings: TemplateStringsArray, ...parameters: any[]): import("./expression").Expression<Config, DataType, IsNotNull, Name>;
star(): sqlFunctions.Star;
star<T extends unknown>(table: T): T extends Table<any, infer Columns> ? import("./column").ColumnSet<Columns> : never;
star<T extends unknown>(table: T): T extends Table<any, any, infer Columns> ? import("./column").ColumnSet<Columns> : never;
toSql(query: import("./query").Query<any>): {

@@ -21,26 +81,27 @@ text: string;

Star: typeof sqlFunctions.Star;
stringAgg: (expression: import("./expression").Expression<string, boolean, any>, delimiter: string, ...orderBy: import("./expression").Expression<any, any, any>[]) => import("./expression").Expression<string, false, "stringAgg">;
bitAnd: <T_1 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<T_1, boolean, any>) => import("./expression").Expression<T_1, false, "bitAnd">;
bitOr: <T_2 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<T_2, boolean, any>) => import("./expression").Expression<T_2, false, "bitOr">;
boolAnd: (expression: import("./expression").Expression<boolean, boolean, any>) => import("./expression").Expression<number, false, "boolAnd">;
boolOr: (expression: import("./expression").Expression<boolean, boolean, any>) => import("./expression").Expression<number, false, "boolOr">;
every: (expression: import("./expression").Expression<boolean, boolean, any>) => import("./expression").Expression<number, false, "every">;
arrayAgg: <DataType_1>(expression: import("./expression").Expression<DataType_1, boolean, any>) => import("./expression").Expression<DataType_1[], false, "arrayAgg">;
count: (expression?: import("./expression").Expression<any, any, any> | undefined) => import("./expression").Expression<string, true, "count">;
min: <DataType_2>(expression: import("./expression").Expression<DataType_2, boolean, any>) => import("./expression").Expression<DataType_2, false, "min">;
max: <DataType_3>(expression: import("./expression").Expression<DataType_3, boolean, any>) => import("./expression").Expression<DataType_3, false, "max">;
avg: <T_3 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<T_3, boolean, any>) => import("./expression").Expression<T_3, false, "avg">;
sum: <T_4 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<T_4, boolean, any>) => import("./expression").Expression<T_4, false, "sum">;
xmlagg: <DataType_4>(expression: import("./expression").Expression<DataType_4, boolean, any>) => import("./expression").Expression<number, false, "xmlagg">;
not: (expression: import("./expression").Expression<boolean, boolean, string>) => import("./expression").DefaultExpression<boolean, true>;
and: (expression: import("./expression").Expression<boolean, boolean, string>) => import("./expression").DefaultExpression<boolean, true>;
or: (expression: import("./expression").Expression<boolean, boolean, string>) => import("./expression").DefaultExpression<boolean, true>;
group: (expression: import("./expression").Expression<boolean, boolean, string>) => import("./expression").DefaultExpression<boolean, true>;
any: <T_5>(array: T_5[]) => import("./expression").Expression<T_5, true, "?column?">;
now: () => import("./expression").Expression<Date, true, "now">;
exists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
andNotExists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
andExists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
notExists: (expression: import("./expression").Expression<any, any, any> | import("./query").Query<any>) => import("./expression").DefaultExpression<boolean, true>;
coalesce: <DataType_5>(...expressions: (DataType_5 | import("./expression").Expression<DataType_5, boolean, any>)[]) => import("./expression").Expression<DataType_5, true, "coalesce">;
now: <Config_1 extends DbConfig = DefaultDbConfig>() => import("./expression").RawExpression<Config_1, Date, true, "now">;
count: <Config_2 extends DbConfig = DefaultDbConfig>(expression?: import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | import("./expression").RawExpression<any, any, any, any> | undefined) => import("./expression").NumberExpression<Config_2, "Int8", true, "count">;
stringAgg: <Config_3 extends DbConfig>(expression: import("./expression").TextExpression<Config_3, "Text", boolean, any>, delimiter: string, ...orderBy: (import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | import("./expression").RawExpression<any, any, any, any>)[]) => import("./expression").TextExpression<Config_3, "Text", false, "stringAgg">;
bitAnd: <Config_4 extends DbConfig, T_1 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_4, T_1, boolean, any>) => import("./expression").Expression<Config_4, T_1, false, "bitAnd">;
bitOr: <Config_5 extends DbConfig, T_2 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_5, T_2, boolean, any>) => import("./expression").Expression<Config_5, T_2, false, "bitOr">;
boolAnd: <Config_6 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_6, false, boolean, any> | import("./expression").BooleanExpression<Config_6, true, boolean, any>) => import("./expression").NumberExpression<Config_6, number, false, "boolAnd">;
boolOr: <Config_7 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_7, false, boolean, any> | import("./expression").BooleanExpression<Config_7, true, boolean, any>) => import("./expression").NumberExpression<Config_7, number, false, "boolOr">;
every: <Config_8 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_8, false, boolean, any> | import("./expression").BooleanExpression<Config_8, true, boolean, any>) => import("./expression").NumberExpression<Config_8, number, false, "every">;
arrayAgg: <Config_9 extends DbConfig, DataType_1>(expression: import("./expression").Expression<Config_9, DataType_1, boolean, any>) => import("./expression").RawExpression<Config_9, import("./config").GetResultType<Config_9, DataType_1>[], false, "arrayAgg">;
min: <Config_10 extends DbConfig, DataType_2>(expression: import("./expression").Expression<Config_10, DataType_2, boolean, any>) => import("./expression").Expression<Config_10, DataType_2, false, "min">;
max: <Config_11 extends DbConfig, DataType_3>(expression: import("./expression").Expression<Config_11, DataType_3, boolean, any>) => import("./expression").Expression<Config_11, DataType_3, false, "max">;
avg: <Config_12 extends DbConfig, T_3 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_12, T_3, boolean, any>) => import("./expression").Expression<Config_12, T_3, false, "avg">;
sum: <Config_13 extends DbConfig, T_4 extends import("./data-types").AnyNumber>(expression: import("./expression").Expression<Config_13, T_4, boolean, any>) => import("./expression").Expression<Config_13, T_4 extends "Int4" ? "Int8" : T_4, false, "sum">;
xmlagg: <Config_14 extends DbConfig, DataType_4>(expression: import("./expression").Expression<Config_14, DataType_4, boolean, any>) => import("./expression").NumberExpression<Config_14, number, false, "xmlagg">;
not: <Config_15 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_15, false, boolean, string> | import("./expression").BooleanExpression<Config_15, true, boolean, string>) => import("./expression").BooleanExpression<Config_15, false, true, "?column?"> | import("./expression").BooleanExpression<Config_15, true, true, "?column?">;
and: <Config_16 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_16, false, boolean, string> | import("./expression").BooleanExpression<Config_16, true, boolean, string>) => import("./expression").BooleanExpression<Config_16, false, true, "?column?"> | import("./expression").BooleanExpression<Config_16, true, true, "?column?">;
or: <Config_17 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_17, false, boolean, string> | import("./expression").BooleanExpression<Config_17, true, boolean, string>) => import("./expression").BooleanExpression<Config_17, false, true, "?column?"> | import("./expression").BooleanExpression<Config_17, true, true, "?column?">;
group: <Config_18 extends DbConfig>(expression: import("./expression").BooleanExpression<Config_18, false, boolean, string> | import("./expression").BooleanExpression<Config_18, true, boolean, string>) => import("./expression").BooleanExpression<Config_18, false, true, "?column?"> | import("./expression").BooleanExpression<Config_18, true, true, "?column?">;
any: <Config_19 extends DbConfig, T_5>(array: T_5[]) => import("./expression").RawExpression<Config_19, T_5, true, "?column?">;
exists: <Config_20 extends DbConfig>(expression: import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | import("./expression").RawExpression<any, any, any, any> | import("./query").Query<any>) => import("./expression").BooleanExpression<Config_20, false, true, "?column?"> | import("./expression").BooleanExpression<Config_20, true, true, "?column?">;
andNotExists: <Config_21 extends DbConfig>(expression: import("./query").Query<any> | import("./expression").BooleanExpression<Config_21, any, any, any> | import("./expression").NumberExpression<Config_21, any, any, any> | import("./expression").TextExpression<Config_21, any, any, any> | import("./expression").UuidExpression<Config_21, unknown, any, any> | import("./expression").RawExpression<Config_21, any, any, any>) => import("./expression").BooleanExpression<Config_21, false, true, "?column?"> | import("./expression").BooleanExpression<Config_21, true, true, "?column?">;
andExists: <Config_22 extends DbConfig>(expression: import("./query").Query<any> | import("./expression").BooleanExpression<Config_22, any, any, any> | import("./expression").NumberExpression<Config_22, any, any, any> | import("./expression").TextExpression<Config_22, any, any, any> | import("./expression").UuidExpression<Config_22, unknown, any, any> | import("./expression").RawExpression<Config_22, any, any, any>) => import("./expression").BooleanExpression<Config_22, false, true, "?column?"> | import("./expression").BooleanExpression<Config_22, true, true, "?column?">;
notExists: <Config_23 extends DbConfig>(expression: import("./query").Query<any> | import("./expression").BooleanExpression<Config_23, any, any, any> | import("./expression").NumberExpression<Config_23, any, any, any> | import("./expression").TextExpression<Config_23, any, any, any> | import("./expression").UuidExpression<Config_23, unknown, any, any> | import("./expression").RawExpression<Config_23, any, any, any>) => import("./expression").BooleanExpression<Config_23, false, true, "?column?"> | import("./expression").BooleanExpression<Config_23, true, true, "?column?">;
coalesce: <Config_24 extends DbConfig, DataType_5>(...expressions: (import("./expression").Expression<Config_24, DataType_5, boolean, any> | import("./config").GetResultType<Config_24, DataType_5>)[]) => import("./expression").Expression<Config_24, DataType_5, false, "coalesce">;
cast: <Config_25 extends DbConfig, T_6 extends import("./data-types").Any, IsNotNull_1 extends boolean, Name_1 extends string>(expression: import("./expression").BooleanExpression<Config_25, any, IsNotNull_1, Name_1> | import("./expression").NumberExpression<Config_25, any, IsNotNull_1, Name_1> | import("./expression").TextExpression<Config_25, any, IsNotNull_1, Name_1> | import("./expression").UuidExpression<Config_25, unknown, IsNotNull_1, Name_1> | import("./expression").RawExpression<Config_25, any, IsNotNull_1, Name_1>, dataType: import("./data-types").ToPostgresDataType<T_6>) => import("./expression").Expression<Config_25, T_6, IsNotNull_1, Name_1>;
/** @internal */

@@ -54,15 +115,15 @@ getTableDefinitions(): {

}[];
select: SelectFn;
insertInto: <T_6 extends unknown>(table: T_6, columnNames?: (T_6 extends Table<any, infer Columns_1> ? (keyof Columns_1)[] : never) | undefined) => T_6 extends TableDefinition<any> ? never : InsertIntoResult<T_6, T_6 extends Table<any, infer Columns_2> ? { [K_1 in keyof import("./types").PickByValue<{ [K in keyof Columns_2]: Columns_2[K] extends Column<any, any, any, infer IsNotNull_1, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull_1 : never; }, true>]: Columns_2[K_1] extends Column<any, any, infer DataType_6, boolean, any, any> ? DataType_6 | import("./expression").Expression<DataType_6, boolean, string> | import("./query").Query<{
[key: string]: DataType_6 | import("./expression").Expression<DataType_6, boolean, string>;
}> : never; } & { [K_3 in keyof import("./types").PickByValue<{ [K_2 in keyof Columns_2]: Columns_2[K_2] extends Column<any, any, any, infer IsNotNull_2, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_2 : never; }, false>]?: (Columns_2[K_3] extends Column<any, any, infer DataType_7, boolean, any, any> ? DataType_7 | import("./expression").Expression<DataType_7, boolean, string> | import("./query").Query<{
[key: string]: DataType_7 | import("./expression").Expression<DataType_7, boolean, string>;
}> | undefined : never) | undefined; } : never>;
deleteFrom: <T_7 extends unknown>(table: T_7) => T_7 extends TableDefinition<any> ? never : import("./delete").DeleteQuery<T_7, number, T_7 extends Table<any, infer Columns_3> ? Columns_3 : never>;
update: <T_8 extends unknown>(table: T_8) => {
set(values: T_8 extends Table<any, infer Columns_4> ? { [K_4 in keyof Columns_4]?: (Columns_4[K_4] extends Column<any, any, infer DataType_8, infer IsNotNull_3, any, any> ? IsNotNull_3 extends true ? DataType_8 | import("./expression").Expression<DataType_8, boolean, any> : DataType_8 | import("./expression").Expression<DataType_8 | undefined, boolean, any> | undefined : never) | undefined; } : never): import("./update").UpdateQuery<T_8, number, T_8 extends Table<any, infer Columns_5> ? Columns_5 : never>;
select: SelectFn<DefaultDbConfig>;
insertInto: <T_7 extends unknown>(table: T_7, columnNames?: (T_7 extends Table<DefaultDbConfig, any, infer Columns_1> ? (keyof Columns_1)[] : never) | undefined) => T_7 extends TableDefinition<any> ? never : InsertIntoResult<DefaultDbConfig, T_7, T_7 extends Table<DefaultDbConfig, any, infer Columns_2> ? { [K_1 in keyof import("./types").PickByValue<{ [K in keyof Columns_2]: Columns_2[K] extends Column<DefaultDbConfig, any, any, any, infer IsNotNull_2, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull_2 : never; }, true>]: Columns_2[K_1] extends Column<DefaultDbConfig, any, any, infer DataType_6, boolean, any, any> ? import("./config").GetResultType<DefaultDbConfig, DataType_6> | import("./expression").Expression<DefaultDbConfig, DataType_6, boolean, string> | import("./expression").Expression<DefaultDbConfig, import("./config").GetResultType<DefaultDbConfig, DataType_6>, boolean, string> | import("./query").Query<{
[key: string]: import("./config").GetResultType<DefaultDbConfig, DataType_6> | import("./expression").Expression<DefaultDbConfig, DataType_6, boolean, string> | import("./expression").Expression<DefaultDbConfig, import("./config").GetResultType<DefaultDbConfig, DataType_6>, boolean, string>;
}> : never; } & { [K_3 in keyof import("./types").PickByValue<{ [K_2 in keyof Columns_2]: Columns_2[K_2] extends Column<DefaultDbConfig, any, any, any, infer IsNotNull_3, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_3 : never; }, false>]?: (Columns_2[K_3] extends Column<DefaultDbConfig, any, any, infer DataType_7, boolean, any, any> ? import("./config").GetResultType<DefaultDbConfig, DataType_7> | import("./expression").Expression<DefaultDbConfig, DataType_7, boolean, string> | import("./expression").Expression<DefaultDbConfig, import("./config").GetResultType<DefaultDbConfig, DataType_7>, boolean, string> | import("./query").Query<{
[key: string]: import("./config").GetResultType<DefaultDbConfig, DataType_7> | import("./expression").Expression<DefaultDbConfig, DataType_7, boolean, string> | import("./expression").Expression<DefaultDbConfig, import("./config").GetResultType<DefaultDbConfig, DataType_7>, boolean, string>;
}> | null : never) | undefined; } : never>;
deleteFrom: <T_8 extends unknown>(table: T_8) => T_8 extends TableDefinition<any> ? never : import("./delete").DeleteQuery<DefaultDbConfig, T_8, number, T_8 extends Table<any, any, infer Columns_3> ? Columns_3 : never>;
update: <T_9 extends unknown>(table: T_9) => {
set(values: T_9 extends Table<DefaultDbConfig, any, infer Columns_4> ? { [K_4 in keyof Columns_4]?: (Columns_4[K_4] extends Column<DefaultDbConfig, any, any, infer DataType_8, infer IsNotNull_4, any, any> ? IsNotNull_4 extends true ? import("./config").GetResultType<DefaultDbConfig, DataType_8> | import("./expression").Expression<DefaultDbConfig, DataType_8, boolean, any> | import("./expression").Expression<DefaultDbConfig, import("./config").GetResultType<DefaultDbConfig, DataType_8>, boolean, any> : import("./config").GetResultType<DefaultDbConfig, DataType_8> | import("./expression").Expression<DefaultDbConfig, DataType_8, boolean, any> | import("./expression").Expression<DefaultDbConfig, import("./config").GetResultType<DefaultDbConfig, DataType_8>, boolean, any> | import("./expression").RawExpression<DefaultDbConfig, null, boolean, any> | null : never) | undefined; } : never): import("./update").UpdateQuery<DefaultDbConfig, T_9, number, T_9 extends Table<DefaultDbConfig, any, infer Columns_5> ? Columns_5 : never>;
};
with: import("./with").WithFn;
truncate: <T_9 extends unknown>(table: T_9) => T_9 extends TableDefinition<any> ? never : import("./truncate").TruncateQuery<T_9, number, T_9 extends Table<any, infer Columns_6> ? Columns_6 : never>;
case: () => CaseStatement<never>;
} & { [TableName in keyof TableDefinitions]: TableDefinitions[TableName] extends TableDefinition<infer ColumnDefinitions> ? Table<TableName, { [K_5 in keyof ColumnDefinitions]: K_5 extends string ? Column<K_5, TableName, ColumnDefinitions[K_5] extends ColumnDefinition<infer DataType_9, any, any> ? DataType_9 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, infer IsNotNull_4, any> ? IsNotNull_4 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, any, infer HasDefault_2> ? HasDefault_2 : never, undefined> : never; }> : never; };
with: import("./with").WithFn<DefaultDbConfig>;
truncate: <T_10 extends unknown>(table: T_10) => T_10 extends TableDefinition<any> ? never : import("./truncate").TruncateQuery<T_10, number>;
case: () => CaseStatement<DefaultDbConfig, never, false>;
} & { [TableName in keyof TableDefinitions]: TableDefinitions[TableName] extends TableDefinition<infer ColumnDefinitions> ? Table<DefaultDbConfig, TableName, { [K_5 in keyof ColumnDefinitions]: K_5 extends string ? Column<DefaultDbConfig, K_5, TableName, ColumnDefinitions[K_5] extends ColumnDefinition<infer DataType_9, any, any, infer IsPrimaryKey> ? DataType_9 extends Uuid<any> ? IsPrimaryKey extends true ? Uuid<TableDefinitions[TableName]> : DataType_9 : DataType_9 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, infer IsNotNull_5, any, false> ? IsNotNull_5 : never, ColumnDefinitions[K_5] extends ColumnDefinition<any, any, infer HasDefault_2, false> ? HasDefault_2 : never, undefined> : never; }> : never; };

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.defineDb = void 0;
exports.defineDb = exports.makeDefineDb = void 0;
const sqlFunctions = __importStar(require("./sql-functions"));

@@ -41,3 +41,3 @@ const insert_1 = require("./insert");

};
const defineDb = (tableDefinitions, queryExecutor) => {
const makeDefineDb = () => (tableDefinitions, queryExecutor) => {
return {

@@ -67,2 +67,3 @@ /** @internal */

case: () => new case_1.CaseStatement([]),
// TODO: should we pass Config to these sql functions?
...sqlFunctions,

@@ -72,2 +73,3 @@ ...createTables(tableDefinitions),

};
exports.defineDb = defineDb;
exports.makeDefineDb = makeDefineDb;
exports.defineDb = exports.makeDefineDb();

@@ -0,10 +1,11 @@

import type { AnyTable, Table } from './TableType';
import { Token } from './tokens';
import type { GetReturning, QueryExecutorFn, ResultType } from './types';
import { DbConfig } from './config';
import { Expression } from './expression';
import { Query } from './query';
import type { ResultSet } from './result-set';
import type { Table } from './TableType';
import type { TableDefinition } from './table';
export declare const makeDeleteFrom: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : DeleteQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
export declare class DeleteQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {
export declare const makeDeleteFrom: <Config extends DbConfig>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : DeleteQuery<Config, T, number, T extends Table<any, any, infer Columns> ? Columns : never>;
export declare class DeleteQuery<Config extends DbConfig, T extends AnyTable, Returning = number, TableColumns = T extends Table<any, any, infer Columns> ? Columns : never> extends Query<Returning> {
private readonly queryExecutor;

@@ -17,16 +18,16 @@ private readonly returningKeys;

constructor(queryExecutor: QueryExecutorFn, returningKeys: string[], table: T, resultType: ResultType, tokens: Token[]);
then<Result1, Result2 = never>(onFulfilled?: ((value: Returning extends number ? number : ResultSet<DeleteQuery<T, Returning>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
using(...fromItems: Table<any, any>[]): DeleteQuery<T, Returning>;
where(condition: Expression<boolean, boolean, string>): DeleteQuery<T, Returning>;
whereCurrentOf(cursorName: string): DeleteQuery<T, Returning>;
returning<C1 extends keyof (T extends Table<string, infer Columns> ? Columns : never)>(column1: C1): DeleteQuery<T, GetReturning<T extends Table<string, infer Columns> ? Columns : never, C1>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns>(column1: C1, column2: C2): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns, C10 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9, column10: C10): DeleteQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9> & GetReturning<TableColumns, C10>>;
then<Result1, Result2 = never>(onFulfilled?: ((value: Returning extends number ? number : ResultSet<Config, DeleteQuery<Config, T, Returning>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
using(...fromItems: AnyTable[]): DeleteQuery<Config, T, Returning>;
where(condition: Expression<Config, boolean, boolean, string>): DeleteQuery<Config, T, Returning>;
whereCurrentOf(cursorName: string): DeleteQuery<Config, T, Returning>;
returning<C1 extends keyof (T extends Table<Config, string, infer Columns> ? Columns : never)>(column1: C1): DeleteQuery<Config, T, GetReturning<T extends Table<Config, string, infer Columns> ? Columns : never, C1>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns>(column1: C1, column2: C2): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns, C10 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9, column10: C10): DeleteQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9> & GetReturning<TableColumns, C10>>;
}

@@ -0,4 +1,66 @@

import { AnyNumber, GetMostSignificantDataType, GetNotNull, Text, Uuid } from './data-types';
import { BooleanQuery, Query, SpecificQuery } from './query';
import { Token } from './tokens';
export declare class Expression<DataType, IsNotNull extends boolean, Name extends string> {
import { DbConfig, GetResultType } from './config';
import { Err } from './types';
import { TableDefinition } from './table';
export interface SharedExpression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> {
as<AliasName extends string>(name: AliasName): Expression<Config, DataType, IsNotNull, AliasName>;
isNull(): DefaultExpression<Config, boolean>;
isNotNull(): DefaultExpression<Config, boolean>;
isDistinctFrom(a: DataType): DefaultExpression<Config, boolean>;
isNotDistinctFrom(a: DataType): DefaultExpression<Config, boolean>;
eq<RightNotNull extends boolean>(value: Expression<Config, DataType, RightNotNull, any>): DefaultExpression<Config, boolean, GetNotNull<IsNotNull, RightNotNull>>;
eq<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, GetResultType<Config, DataType>, boolean, any> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): DefaultExpression<Config, boolean>;
ne<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): DefaultExpression<Config, boolean>;
gt<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): DefaultExpression<Config, boolean>;
gte<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): DefaultExpression<Config, boolean>;
lt<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): DefaultExpression<Config, boolean>;
lte<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): DefaultExpression<Config, boolean>;
orderBy(...expressions: Expression<any, any, any, any>[]): DefaultExpression<Config, DataType, IsNotNull>;
asc(): DefaultExpression<Config, DataType, IsNotNull>;
desc(): DefaultExpression<Config, DataType, IsNotNull>;
nullsFirst(): DefaultExpression<Config, DataType, IsNotNull>;
nullsLast(): DefaultExpression<Config, DataType, IsNotNull>;
in<Q extends Query<any>>(array: SpecificQuery<Config, DataType, Q> | GetResultType<Config, DataType>[] | Expression<Config, DataType, IsNotNull, any>): DefaultExpression<Config, boolean>;
notIn(array: GetResultType<Config, DataType>[] | Expression<Config, DataType, IsNotNull, any> | Query<any>): DefaultExpression<Config, boolean>;
}
export interface TextExpression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> extends SharedExpression<Config, DataType, IsNotNull, Name> {
concat<RightIsNotNull extends boolean>(value: GetResultType<Config, DataType> | Expression<Config, DataType, RightIsNotNull, any>): DefaultExpression<Config, DataType, GetNotNull<IsNotNull, RightIsNotNull>>;
like(value: GetResultType<Config, DataType>): DefaultExpression<Config, boolean>;
ilike(value: GetResultType<Config, DataType>): DefaultExpression<Config, boolean>;
}
export interface NumberExpression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> extends SharedExpression<Config, DataType, IsNotNull, Name> {
plus<T extends AnyNumber, RightIsNotNull extends boolean>(expression: Expression<Config, T, RightIsNotNull, any>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, GetNotNull<IsNotNull, RightIsNotNull>>;
plus(value: GetResultType<Config, AnyNumber>): DefaultExpression<Config, DataType, IsNotNull>;
minus<T extends AnyNumber, RightIsNotNull extends boolean>(expression: Expression<Config, T, RightIsNotNull, any>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, GetNotNull<IsNotNull, RightIsNotNull>>;
minus<T extends AnyNumber>(value: GetResultType<Config, T>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, IsNotNull>;
multiply<T extends AnyNumber, RightIsNotNull extends boolean>(expression: Expression<Config, T, RightIsNotNull, any>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, GetNotNull<IsNotNull, RightIsNotNull>>;
multiply<T extends AnyNumber>(value: GetResultType<Config, T>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, IsNotNull>;
divide<T extends AnyNumber, RightIsNotNull extends boolean>(expression: Expression<Config, T, RightIsNotNull, any>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, GetNotNull<IsNotNull, RightIsNotNull>>;
divide<T extends AnyNumber>(value: GetResultType<Config, T>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, IsNotNull>;
modulo<T extends AnyNumber, RightIsNotNull extends boolean>(expression: Expression<Config, T, RightIsNotNull, any>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, GetNotNull<IsNotNull, RightIsNotNull>>;
modulo<T extends AnyNumber>(value: GetResultType<Config, T>): DefaultExpression<Config, GetMostSignificantDataType<DataType, T>, IsNotNull>;
between(a: GetResultType<Config, DataType>, b: GetResultType<Config, DataType>): DefaultExpression<Config, boolean>;
betweenSymmetric(a: GetResultType<Config, DataType>, b: GetResultType<Config, DataType>): DefaultExpression<Config, boolean>;
}
export interface BooleanExpression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> {
as<AliasName extends string>(name: AliasName): Expression<Config, DataType, IsNotNull, AliasName>;
or(query: BooleanQuery<Config, Query<any>>): DefaultExpression<Config, boolean, IsNotNull>;
or<RightIsNotNull extends boolean>(expression: Expression<Config, boolean, RightIsNotNull, any>): DefaultExpression<Config, boolean, GetNotNull<IsNotNull, RightIsNotNull>>;
and(query: BooleanQuery<Config, Query<any>>): DefaultExpression<Config, boolean, IsNotNull>;
and<RightIsNotNull extends boolean>(expression: Expression<Config, boolean, RightIsNotNull, any>): DefaultExpression<Config, boolean, GetNotNull<IsNotNull, RightIsNotNull>>;
andNotExists(query: Query<any>): DefaultExpression<Config, boolean, IsNotNull>;
andNotExists<RightIsNotNull extends boolean>(expression: Expression<Config, boolean, RightIsNotNull, any>): DefaultExpression<Config, boolean, GetNotNull<IsNotNull, RightIsNotNull>>;
andExists(query: Query<any>): DefaultExpression<Config, boolean, IsNotNull>;
andExists<RightIsNotNull extends boolean>(expression: Expression<Config, boolean, RightIsNotNull, any>): DefaultExpression<Config, boolean, GetNotNull<IsNotNull, RightIsNotNull>>;
}
export interface RawExpression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> extends TextExpression<Config, DataType, IsNotNull, Name>, NumberExpression<Config, DataType, IsNotNull, Name> {
}
export interface UuidExpression<Config extends DbConfig, TD, IsNotNull extends boolean, Name extends string> extends Omit<SharedExpression<Config, Uuid<TD>, IsNotNull, Name>, 'eq'> {
eq(value: GetResultType<Config, Uuid<TD>>): DefaultExpression<Config, boolean, IsNotNull>;
eq<RightExpression extends UuidExpression<Config, any, any, any>>(expression: RightExpression): RightExpression extends UuidExpression<Config, infer RightTableDefinition, infer RightIsNotNull, any> ? RightTableDefinition extends TableDefinition<infer RightColumns> ? TD extends TableDefinition<infer LeftColumns> ? [LeftColumns] extends [RightColumns] ? [RightColumns] extends [LeftColumns] ? DefaultExpression<Config, boolean, GetNotNull<IsNotNull, RightIsNotNull>> : Err<'not the right references'> : Err<'not the right references'> : Err<'no left table definition found in uuid'> : Err<'no right table definition found in uuid'> : Err<'no uuid expression'>;
}
export declare type Expression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> = DataType extends boolean ? BooleanExpression<Config, DataType, IsNotNull, Name> : DataType extends AnyNumber ? NumberExpression<Config, DataType, IsNotNull, Name> : DataType extends Text ? TextExpression<Config, DataType, IsNotNull, Name> : DataType extends number ? NumberExpression<Config, DataType, IsNotNull, Name> : DataType extends string ? TextExpression<Config, DataType, IsNotNull, Name> : DataType extends Uuid<infer TableDefinition> ? UuidExpression<Config, TableDefinition, IsNotNull, Name> : RawExpression<Config, DataType, IsNotNull, Name>;
export declare class InternalExpression<Config extends DbConfig, DataType, IsNotNull extends boolean, Name extends string> implements TextExpression<Config, DataType, IsNotNull, Name>, NumberExpression<Config, DataType, IsNotNull, Name>, BooleanExpression<Config, DataType, IsNotNull, Name> {
private readonly tokens;

@@ -12,37 +74,39 @@ private readonly name;

private toGroup;
or<Q extends Query<any>>(expression: Expression<boolean, any, any> | BooleanQuery<Q>): DefaultExpression<boolean>;
and<Q extends Query<any>>(expression: Expression<boolean, any, any> | BooleanQuery<Q>): DefaultExpression<boolean>;
andNotExists(expression: Expression<any, any, any> | Query<any>): DefaultExpression<boolean>;
andExists(expression: Expression<any, any, any> | Query<any>): DefaultExpression<boolean>;
as<AliasName extends string>(name: AliasName): Expression<DataType, IsNotNull, AliasName>;
isNull(): DefaultExpression<boolean>;
isNotNull(): DefaultExpression<boolean>;
asc(): DefaultExpression<DataType, IsNotNull>;
desc(): DefaultExpression<DataType, IsNotNull>;
nullsFirst(): DefaultExpression<DataType, IsNotNull>;
nullsLast(): DefaultExpression<DataType, IsNotNull>;
in<Q extends Query<any>>(array: DataType[] | Expression<DataType, IsNotNull, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
notIn(array: DataType[] | Expression<DataType, IsNotNull, any> | Query<any>): DefaultExpression<boolean>;
plus(value: DataType | Expression<DataType, IsNotNull, any>): DefaultExpression<DataType, IsNotNull>;
minus(value: DataType | Expression<DataType, IsNotNull, any>): DefaultExpression<DataType, IsNotNull>;
multiply(value: DataType | Expression<DataType, IsNotNull, any>): DefaultExpression<DataType, IsNotNull>;
divide(value: DataType | Expression<DataType, IsNotNull, any>): DefaultExpression<DataType, IsNotNull>;
modulo(value: DataType | Expression<DataType, IsNotNull, any>): DefaultExpression<DataType, IsNotNull>;
concat(value: DataType | Expression<DataType, IsNotNull, any>): DefaultExpression<DataType, IsNotNull>;
between(a: DataType, b: DataType): DefaultExpression<boolean>;
betweenSymmetric(a: DataType, b: DataType): DefaultExpression<boolean>;
isDistinctFrom(a: DataType): DefaultExpression<boolean>;
isNotDistinctFrom(a: DataType): DefaultExpression<boolean>;
like(value: DataType): DefaultExpression<boolean>;
ilike(value: DataType): DefaultExpression<boolean>;
eq<Q extends Query<any>>(value: DataType | Expression<DataType, boolean, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
ne<Q extends Query<any>>(value: DataType | Expression<DataType, boolean, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
gt<Q extends Query<any>>(value: DataType | Expression<DataType, boolean, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
gte<Q extends Query<any>>(value: DataType | Expression<DataType, boolean, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
lt<Q extends Query<any>>(value: DataType | Expression<DataType, boolean, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
lte<Q extends Query<any>>(value: DataType | Expression<DataType, boolean, any> | SpecificQuery<DataType, Q>): DefaultExpression<boolean>;
orderBy(...expressions: Expression<any, any, any>[]): DefaultExpression<DataType, IsNotNull>;
or(expression: Expression<any, boolean, any, any> | BooleanQuery<Config, Query<any>>): any;
and(expression: Expression<any, boolean, any, any> | BooleanQuery<Config, Query<any>>): any;
andNotExists(expression: Expression<any, any, any, any> | Query<any>): any;
andExists(expression: Expression<any, any, any, any> | Query<any>): any;
as(name: any): any;
isNull(): any;
isNotNull(): any;
asc(): any;
desc(): any;
nullsFirst(): any;
nullsLast(): any;
in(array: any): any;
notIn(array: any): any;
plus(value: any): any;
minus(value: any): InternalDefaultExpression<DbConfig, unknown, true>;
multiply(value: any): InternalDefaultExpression<DbConfig, unknown, true>;
divide(value: any): InternalDefaultExpression<DbConfig, unknown, true>;
modulo(value: any): InternalDefaultExpression<DbConfig, unknown, true>;
concat(value: any): any;
between(a: GetResultType<Config, DataType>, b: GetResultType<Config, DataType>): InternalDefaultExpression<DbConfig, unknown, true>;
betweenSymmetric(a: GetResultType<Config, DataType>, b: GetResultType<Config, DataType>): InternalDefaultExpression<DbConfig, unknown, true>;
isDistinctFrom(a: DataType): InternalDefaultExpression<DbConfig, unknown, true>;
isNotDistinctFrom(a: DataType): InternalDefaultExpression<DbConfig, unknown, true>;
like(value: GetResultType<Config, DataType>): InternalDefaultExpression<DbConfig, unknown, true>;
ilike(value: GetResultType<Config, DataType>): InternalDefaultExpression<DbConfig, unknown, true>;
eq<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): InternalDefaultExpression<DbConfig, unknown, true>;
ne<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): InternalDefaultExpression<DbConfig, unknown, true>;
gt<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): InternalDefaultExpression<DbConfig, unknown, true>;
gte<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): InternalDefaultExpression<DbConfig, unknown, true>;
lt<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): InternalDefaultExpression<DbConfig, unknown, true>;
lte<Q extends Query<any>>(value: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | SpecificQuery<Config, DataType, Q>): InternalDefaultExpression<DbConfig, unknown, true>;
orderBy(...expressions: any[]): any;
}
export declare class DefaultExpression<DataType, IsNotNull extends boolean = true> extends Expression<DataType, IsNotNull, '?column?'> {
export declare type DefaultExpression<Config extends DbConfig, DataType, IsNotNull extends boolean = true> = Expression<Config, DataType, IsNotNull, '?column?'>;
export declare class InternalDefaultExpression<Config extends DbConfig, DataType, IsNotNull extends boolean = true> extends InternalExpression<Config, DataType, IsNotNull, '?column?'> {
constructor(tokens: Token[]);
}
export declare type AnyExpression = Expression<any, any, any, any>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DefaultExpression = exports.Expression = void 0;
exports.InternalDefaultExpression = exports.InternalExpression = void 0;
const query_1 = require("./query");
const tokens_1 = require("./tokens");
const naming_1 = require("./naming");
class Expression {
class InternalExpression {
constructor(tokens, name, nameIsAlias = false) {

@@ -43,15 +43,11 @@ this.tokens = tokens;

}
// TODO: only include
// or: DataType extends boolean
// ? (expression: Expression<boolean, boolean, string>) => void
// : Explain<
// 'Expression#or() is only available on boolean expressions. Is this a boolean expression?'
// > = (() => {
// //
// }) as any;
or(expression) {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`OR`), this.toGroup(expression)]);
return new InternalDefaultExpression([
...this.tokens,
new tokens_1.StringToken(`OR`),
this.toGroup(expression),
]);
}
and(expression) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -63,3 +59,3 @@ new tokens_1.StringToken(`AND`),

andNotExists(expression) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -71,3 +67,3 @@ new tokens_1.StringToken(`AND NOT EXISTS`),

andExists(expression) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -80,27 +76,27 @@ new tokens_1.StringToken(`AND EXISTS`),

if (this.tokens.length > 2) {
return new Expression([new tokens_1.GroupToken(this.tokens)], name, true);
return new InternalExpression([new tokens_1.GroupToken(this.tokens)], name, true);
}
return new Expression([...this.tokens], name, true);
return new InternalExpression([...this.tokens], name, true);
}
isNull() {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`IS NULL`)]);
return new InternalDefaultExpression([...this.tokens, new tokens_1.StringToken(`IS NULL`)]);
}
isNotNull() {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`IS NOT NULL`)]);
return new InternalDefaultExpression([...this.tokens, new tokens_1.StringToken(`IS NOT NULL`)]);
}
asc() {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`ASC`)]);
return new InternalDefaultExpression([...this.tokens, new tokens_1.StringToken(`ASC`)]);
}
desc() {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`DESC`)]);
return new InternalDefaultExpression([...this.tokens, new tokens_1.StringToken(`DESC`)]);
}
nullsFirst() {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`NULLS FIRST`)]);
return new InternalDefaultExpression([...this.tokens, new tokens_1.StringToken(`NULLS FIRST`)]);
}
nullsLast() {
return new DefaultExpression([...this.tokens, new tokens_1.StringToken(`NULLS LAST`)]);
return new InternalDefaultExpression([...this.tokens, new tokens_1.StringToken(`NULLS LAST`)]);
}
in(array) {
if (array && ('toTokens' in array || array instanceof query_1.Query)) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -112,3 +108,3 @@ new tokens_1.StringToken(`IN`),

else {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -124,3 +120,3 @@ new tokens_1.StringToken(`IN`),

if (array && ('toTokens' in array || array instanceof query_1.Query)) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -132,3 +128,3 @@ new tokens_1.StringToken(`NOT IN`),

else {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -143,3 +139,3 @@ new tokens_1.StringToken(`NOT IN`),

plus(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -151,3 +147,3 @@ new tokens_1.StringToken(`+`),

minus(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -159,3 +155,3 @@ new tokens_1.StringToken(`-`),

multiply(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -167,3 +163,3 @@ new tokens_1.StringToken(`*`),

divide(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -175,3 +171,3 @@ new tokens_1.StringToken(`/`),

modulo(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -183,3 +179,3 @@ new tokens_1.StringToken(`%`),

concat(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -191,3 +187,3 @@ new tokens_1.StringToken(`||`),

between(a, b) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -201,3 +197,3 @@ new tokens_1.StringToken(`BETWEEN`),

betweenSymmetric(a, b) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -211,3 +207,3 @@ new tokens_1.StringToken(`BETWEEN SYMMETRIC`),

isDistinctFrom(a) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -219,3 +215,3 @@ new tokens_1.StringToken(`IS DISTINCT FROM`),

isNotDistinctFrom(a) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -227,3 +223,3 @@ new tokens_1.StringToken(`IS NOT DISTINCT FROM`),

like(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -235,3 +231,3 @@ new tokens_1.StringToken(`LIKE`),

ilike(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -243,3 +239,3 @@ new tokens_1.StringToken(`ILIKE`),

eq(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -251,3 +247,3 @@ new tokens_1.StringToken(`=`),

ne(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -259,3 +255,3 @@ new tokens_1.StringToken(`<>`),

gt(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -267,3 +263,3 @@ new tokens_1.StringToken(`>`),

gte(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -275,3 +271,3 @@ new tokens_1.StringToken(`>=`),

lt(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -283,3 +279,3 @@ new tokens_1.StringToken(`<`),

lte(value) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -291,3 +287,3 @@ new tokens_1.StringToken(`<=`),

orderBy(...expressions) {
return new DefaultExpression([
return new InternalDefaultExpression([
...this.tokens,

@@ -308,4 +304,4 @@ new tokens_1.StringToken(`ORDER BY`),

}
exports.Expression = Expression;
class DefaultExpression extends Expression {
exports.InternalExpression = InternalExpression;
class InternalDefaultExpression extends InternalExpression {
constructor(tokens) {

@@ -315,2 +311,2 @@ super(tokens, '?column?');

}
exports.DefaultExpression = DefaultExpression;
exports.InternalDefaultExpression = InternalDefaultExpression;

@@ -5,2 +5,3 @@ export * from './data-types';

export { defineTable, TableRow } from './table';
export { DefaultDbConfig } from './config';
export { DbConfig, DefaultDbConfig } from './config';
export * from './bootstrap';

@@ -19,1 +19,2 @@ "use strict";

Object.defineProperty(exports, "defineTable", { enumerable: true, get: function () { return table_1.defineTable; } });
__exportStar(require("./bootstrap"), exports);

@@ -0,5 +1,7 @@

import { Column } from './column';
import { AnyTable, Table } from './TableType';
import { Token } from './tokens';
import { DbConfig, GetResultType } from './config';
import { GetReturning, PickByValue, QueryExecutorFn, ResultType } from './types';
import { SelectFn } from './select';
import { Column } from './column';
import { DeleteQuery } from './delete';

@@ -9,6 +11,5 @@ import { Expression } from './expression';

import { ResultSet } from './result-set';
import { Table } from './TableType';
import { TableDefinition } from './table';
import { UpdateQuery } from './update';
export declare class InsertQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {
export declare class InsertQuery<Config extends DbConfig, T extends Table<any, any, any>, Returning = number, TableColumns = T extends Table<Config, any, infer Columns> ? Columns : never> extends Query<Returning> {
private readonly queryExecutor;

@@ -21,51 +22,51 @@ private readonly returningKeys;

constructor(queryExecutor: QueryExecutorFn, returningKeys: string[], table: T, resultType: ResultType, tokens: Token[]);
then<Result1, Result2 = never>(onFulfilled?: ((value: Returning extends number ? Returning : ResultSet<InsertQuery<T, Returning>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
returning<C1 extends keyof TableColumns>(column1: C1): InsertQuery<T, GetReturning<TableColumns, C1>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns>(column1: C1, column2: C2): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns, C10 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9, column10: C10): InsertQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9> & GetReturning<TableColumns, C10>>;
where(expression: Expression<boolean, boolean, string>): InsertQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
then<Result1, Result2 = never>(onFulfilled?: ((value: Returning extends number ? Returning : ResultSet<Config, InsertQuery<Config, T, Returning>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
returning<C1 extends keyof TableColumns>(column1: C1): InsertQuery<Config, T, GetReturning<TableColumns, C1>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns>(column1: C1, column2: C2): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns, C10 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9, column10: C10): InsertQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9> & GetReturning<TableColumns, C10>>;
where(expression: Expression<Config, boolean, boolean, string>): InsertQuery<DbConfig, T, number, T extends Table<DbConfig, any, infer Columns> ? Columns : never>;
onConflictOnConstraint(constraintName: string): {
doNothing(): InsertQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
doUpdateSet(values: T extends Table<any, infer Columns_1> ? { [K in keyof Columns_1]?: (Columns_1[K] extends Column<any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? Query<any> | DataType | Expression<DataType, IsNotNull, any> : Query<any> | DataType | Expression<DataType, IsNotNull, any> | undefined : never) | undefined; } : never): InsertQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
doNothing(): InsertQuery<DbConfig, T, number, T extends Table<DbConfig, any, infer Columns> ? Columns : never>;
doUpdateSet(values: T extends Table<Config, any, infer Columns_1> ? { [K in keyof Columns_1]?: (Columns_1[K] extends Column<Config, any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? Query<any> | GetResultType<Config, DataType> | Expression<Config, DataType, IsNotNull, any> | Expression<Config, GetResultType<Config, DataType>, IsNotNull, any> : Query<any> | Expression<Config, DataType, IsNotNull, any> | GetResultType<Config, DataType> | ("Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null") : never) | undefined; } : never): InsertQuery<DbConfig, T, number, T extends Table<DbConfig, any, infer Columns> ? Columns : never>;
};
private getConflictTargetToken;
onConflict<ColumnNames extends T extends Table<any, infer Columns> ? (keyof Columns)[] : never>(...columnNames: ColumnNames): {
doNothing(): InsertQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
doUpdateSet(values: T extends Table<any, infer Columns_1> ? { [K in keyof Columns_1]?: (Columns_1[K] extends Column<any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? Query<any> | DataType | Expression<DataType, IsNotNull, any> : Query<any> | DataType | Expression<DataType, IsNotNull, any> | undefined : never) | undefined; } : never): InsertQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
onConflict<ColumnNames extends T extends Table<Config, any, infer Columns> ? (keyof Columns)[] : never>(...columnNames: ColumnNames): {
doNothing(): InsertQuery<DbConfig, T, number, T extends Table<DbConfig, any, infer Columns> ? Columns : never>;
doUpdateSet(values: T extends Table<Config, any, infer Columns_1> ? { [K in keyof Columns_1]?: (Columns_1[K] extends Column<Config, any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? Query<any> | GetResultType<Config, DataType> | Expression<Config, DataType, IsNotNull, any> | Expression<Config, GetResultType<Config, DataType>, IsNotNull, any> : Query<any> | ("Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null") | Expression<Config, DataType, IsNotNull, any> | GetResultType<Config, DataType> | Expression<Config, GetResultType<Config, DataType>, IsNotNull, any> : never) | undefined; } : never): InsertQuery<DbConfig, T, number, T extends Table<DbConfig, any, infer Columns> ? Columns : never>;
};
}
export interface InsertIntoResult<T extends Table<any, any>, Row = T extends Table<any, infer Columns> ? {
export interface InsertIntoResult<Config extends DbConfig, T extends AnyTable, Row = T extends Table<Config, any, infer Columns> ? {
[K in keyof PickByValue<{
[K in keyof Columns]: Columns[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never;
}, true>]: Columns[K] extends Column<any, any, infer DataType, boolean, any, any> ? DataType | Query<{
[key: string]: DataType | Expression<DataType, boolean, string>;
}> | Expression<DataType, boolean, string> : never;
[K in keyof Columns]: Columns[K] extends Column<Config, any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never;
}, true>]: Columns[K] extends Column<Config, any, any, infer DataType, boolean, any, any> ? GetResultType<Config, DataType> | Query<{
[key: string]: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, string> | Expression<Config, GetResultType<Config, DataType>, boolean, string>;
}> | Expression<Config, DataType, boolean, string> | Expression<Config, GetResultType<Config, DataType>, boolean, string> : never;
} & {
[K in keyof PickByValue<{
[K in keyof Columns]: Columns[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never;
}, false>]?: Columns[K] extends Column<any, any, infer DataType, boolean, any, any> ? DataType | Query<{
[key: string]: DataType | Expression<DataType, boolean, string>;
}> | Expression<DataType, boolean, string> | undefined : never;
[K in keyof Columns]: Columns[K] extends Column<Config, any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never;
}, false>]?: Columns[K] extends Column<Config, any, any, infer DataType, boolean, any, any> ? GetResultType<Config, DataType> | Query<{
[key: string]: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, string> | Expression<Config, GetResultType<Config, DataType>, boolean, string>;
}> | Expression<Config, DataType, boolean, string> | Expression<Config, GetResultType<Config, DataType>, boolean, string> | GetResultType<Config, 'Null'> : never;
} : never> {
select: SelectFn;
deleteFrom<DeleteTable extends Table<any, any>>(deleteTable: DeleteTable): DeleteQuery<DeleteTable, number>;
update<UpdateTable extends Table<any, any>>(updateTable: UpdateTable): {
set(values: UpdateTable extends Table<any, infer Columns> ? {
[K in keyof Columns]?: Columns[K] extends Column<any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? DataType | Expression<DataType, boolean, any> : DataType | undefined | Expression<DataType | undefined, boolean, any> : never;
} : never): UpdateQuery<UpdateTable, number>;
select: SelectFn<Config>;
deleteFrom<DeleteTable extends AnyTable>(deleteTable: DeleteTable): DeleteQuery<Config, DeleteTable, number>;
update<UpdateTable extends AnyTable>(updateTable: UpdateTable): {
set(values: UpdateTable extends Table<Config, any, infer Columns> ? {
[K in keyof Columns]?: Columns[K] extends Column<Config, any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | Expression<Config, GetResultType<Config, DataType>, boolean, any> : GetResultType<Config, DataType> | GetResultType<Config, 'Null'> | Expression<Config, DataType | GetResultType<Config, 'Null'>, boolean, any> | Expression<Config, GetResultType<Config, DataType> | GetResultType<Config, 'Null'>, boolean, any> : never;
} : never): UpdateQuery<Config, UpdateTable, number>;
};
defaultValues(): InsertQuery<T, number>;
values(values: Row | Row[]): InsertQuery<T, number>;
defaultValues(): InsertQuery<Config, T, number>;
values(values: Row | Row[]): InsertQuery<Config, T, number>;
}
export declare const makeInsertInto: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T, columnNames?: (T extends Table<any, infer Columns> ? (keyof Columns)[] : never) | undefined) => T extends TableDefinition<any> ? never : InsertIntoResult<T, T extends Table<any, infer Columns_1> ? { [K_1 in keyof PickByValue<{ [K in keyof Columns_1]: Columns_1[K] extends Column<any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never; }, true>]: Columns_1[K_1] extends Column<any, any, infer DataType, boolean, any, any> ? DataType | Expression<DataType, boolean, string> | Query<{
[key: string]: DataType | Expression<DataType, boolean, string>;
}> : never; } & { [K_3 in keyof PickByValue<{ [K_2 in keyof Columns_1]: Columns_1[K_2] extends Column<any, any, any, infer IsNotNull_1, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_1 : never; }, false>]?: (Columns_1[K_3] extends Column<any, any, infer DataType_1, boolean, any, any> ? DataType_1 | Expression<DataType_1, boolean, string> | Query<{
[key: string]: DataType_1 | Expression<DataType_1, boolean, string>;
}> | undefined : never) | undefined; } : never>;
export declare const makeInsertInto: <Config extends DbConfig>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T, columnNames?: (T extends Table<Config, any, infer Columns> ? (keyof Columns)[] : never) | undefined) => T extends TableDefinition<any> ? never : InsertIntoResult<Config, T, T extends Table<Config, any, infer Columns_1> ? { [K_1 in keyof PickByValue<{ [K in keyof Columns_1]: Columns_1[K] extends Column<Config, any, any, any, infer IsNotNull, infer HasDefault, any> ? HasDefault extends true ? false : IsNotNull : never; }, true>]: Columns_1[K_1] extends Column<Config, any, any, infer DataType, boolean, any, any> ? GetResultType<Config, DataType> | Expression<Config, DataType, boolean, string> | Expression<Config, GetResultType<Config, DataType>, boolean, string> | Query<{
[key: string]: GetResultType<Config, DataType> | Expression<Config, DataType, boolean, string> | Expression<Config, GetResultType<Config, DataType>, boolean, string>;
}> : never; } & { [K_3 in keyof PickByValue<{ [K_2 in keyof Columns_1]: Columns_1[K_2] extends Column<Config, any, any, any, infer IsNotNull_1, infer HasDefault_1, any> ? HasDefault_1 extends true ? false : IsNotNull_1 : never; }, false>]?: (Columns_1[K_3] extends Column<Config, any, any, infer DataType_1, boolean, any, any> ? GetResultType<Config, DataType_1> | Expression<Config, DataType_1, boolean, string> | Expression<Config, GetResultType<Config, DataType_1>, boolean, string> | Query<{
[key: string]: GetResultType<Config, DataType_1> | Expression<Config, DataType_1, boolean, string> | Expression<Config, GetResultType<Config, DataType_1>, boolean, string>;
}> | ("Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null") : never) | undefined; } : never>;

@@ -61,3 +61,3 @@ "use strict";

new tokens_1.StringToken(`ON CONFLICT ON CONSTRAINT`),
new tokens_1.ParameterToken(constraintName),
new tokens_1.StringToken(constraintName),
new tokens_1.StringToken(`DO NOTHING`),

@@ -70,3 +70,3 @@ ]);

new tokens_1.StringToken(`ON CONFLICT ON CONSTRAINT`),
new tokens_1.ParameterToken(constraintName),
new tokens_1.StringToken(constraintName),
new tokens_1.StringToken(`DO UPDATE SET`),

@@ -83,3 +83,3 @@ new tokens_1.SeparatorToken(`,`, Object.keys(values).map((columnName) => {

new tokens_1.StringToken(`=`),
// TODO: should we add a group here-o?
// TODO: should we add a group here?
...value.toTokens(),

@@ -137,3 +137,3 @@ ]);

new tokens_1.StringToken(`=`),
// TODO: should we add a group here-o?
// TODO: should we add a group here?
...value.toTokens(),

@@ -140,0 +140,0 @@ ]);

@@ -0,8 +1,10 @@

import { DbConfig, GetResultType } from './config';
import { ResultSet } from './result-set';
export declare type SpecificQuery<DataType, Q extends Query<any>, Result = ResultSet<Q, false>> = Result extends {
[K in keyof Result]: DataType | undefined;
export declare type SpecificQuery<Config extends DbConfig, DataType, Q extends Query<any>, Result = ResultSet<Config, Q, false>> = Result extends {
[K in keyof Result]: GetResultType<Config, DataType> | GetResultType<Config, 'Null'>;
} ? Q : never;
export declare type BooleanQuery<Q extends Query<any>> = SpecificQuery<boolean, Q>;
export declare type BooleanQuery<Config extends DbConfig, Q extends Query<any>> = SpecificQuery<Config, boolean, Q>;
export declare type AnyQuery = Query<any>;
export declare abstract class Query<Returning> {
private _queryBrand;
}

@@ -1,6 +0,6 @@

import { NullType } from './config';
import { DbConfig, GetResultType } from './config';
import type { Column } from './column';
import { DeleteQuery } from './delete';
import type { Expression } from './expression';
import { GetDataType } from './types';
import { Err, GetDataType } from './types';
import { InsertQuery } from './insert';

@@ -10,11 +10,16 @@ import { Query } from './query';

import { UpdateQuery } from './update';
export declare type ResultSetDataType<Type, IsNotNull> = IsNotNull extends true ? Type : Type | NullType;
export declare type ResultSet<T extends Query<any>, Test extends boolean> = T extends SelectQuery<infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : T extends DeleteQuery<any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : T extends UpdateQuery<any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : T extends InsertQuery<any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<D, false> : Returning[K] extends Expression<infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Returning[K], Test>[keyof ResultSet<Returning[K], Test>] : never;
} : never;
import { TruncateQuery } from './truncate';
export declare type ResultSetDataType<Config extends DbConfig, Type, IsNotNull> = IsNotNull extends true ? GetResultType<Config, Type> : GetResultType<Config, Type> | GetResultType<Config, 'Null'>;
declare type ReturningResultSet<Config extends DbConfig, Returning, Test extends boolean> = {
[K in keyof Returning]: Returning[K] extends Column<any, any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<Config, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Returning[K] extends Expression<Config, infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<Config, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Config, Returning[K], Test>[keyof ResultSet<Config, Returning[K], Test>] : never;
};
export declare type ResultSet<Config extends DbConfig, T extends Query<any>, Test extends boolean> = T extends SelectQuery<Config, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<Config, any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<Config, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Returning[K] extends Expression<Config, infer D, infer IsNotNull, string> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<Config, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Config, Returning[K], Test>[keyof ResultSet<Config, Returning[K], Test>] : never;
} : T extends DeleteQuery<Config, any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<Config, any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<Config, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Returning[K] extends Expression<Config, infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<Config, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Config, Returning[K], Test>[keyof ResultSet<Config, Returning[K], Test>] : never;
} : T extends UpdateQuery<Config, any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<Config, any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<Config, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Returning[K] extends Expression<Config, infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<Config, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Config, Returning[K], Test>[keyof ResultSet<Config, Returning[K], Test>] : never;
} : T extends InsertQuery<Config, any, infer Returning> ? {
[K in keyof Returning]: Returning[K] extends Column<any, any, any, infer D, infer N, any, infer JoinType> ? Extract<JoinType, 'left-join'> extends never ? Extract<JoinType, 'left-side-of-right-join'> extends never ? Extract<JoinType, 'full-join'> extends never ? N extends true ? Test extends true ? GetDataType<D, true> : ResultSetDataType<Config, D, true> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Test extends true ? GetDataType<D, false> : ResultSetDataType<Config, D, false> : Returning[K] extends Expression<Config, infer D, infer IsNotNull, any> ? Test extends true ? GetDataType<D, IsNotNull> : ResultSetDataType<Config, D, IsNotNull> : Returning[K] extends Query<{}> ? ResultSet<Config, Returning[K], Test>[keyof ResultSet<Config, Returning[K], Test>] : never;
} : T extends TruncateQuery<any, infer Returning> ? ReturningResultSet<Config, Returning, Test> : Err<'not a query'>;
export {};
import { Token } from './tokens';
import { SelectFn } from './SelectFn';
import { Column } from './column';
import { Expression } from './expression';
import { AnyColumn, Column } from './column';
import { DbConfig } from './config';
import { AnyExpression, Expression } from './expression';
import { FromItem } from './with';

@@ -9,3 +10,3 @@ import { Query } from './query';

import { ResultSet } from './result-set';
import { Table } from './TableType';
import { AnyTable, Table } from './TableType';
import { TableDefinition } from './table';

@@ -15,18 +16,18 @@ export { SelectFn };

declare type ToJoinType<OldType, NewType extends JoinType> = Extract<OldType, 'left-side-of-right-join'> extends never ? NewType : OldType;
declare type GetTableName<T extends Table<any, any>> = T extends Table<infer A, object> ? A : never;
declare type GetTableName<T extends AnyTable> = T extends Table<any, infer A, object> ? A : never;
declare type AddLeftJoin<Columns, JoinTable> = {
[K in keyof Columns]: Columns[K] extends Column<infer Name, infer TableName, infer DataType, infer IsNotNull, infer HasDefault, infer JoinType> ? Extract<GetTableName<JoinTable>, TableName> extends never ? Column<Name, TableName, DataType, IsNotNull, HasDefault, JoinType> : Column<Name, TableName, DataType, IsNotNull, HasDefault, ToJoinType<JoinType, 'left-join'>> : never;
[K in keyof Columns]: Columns[K] extends Column<infer Config, infer Name, infer TableName, infer DataType, infer IsNotNull, infer HasDefault, infer JoinType> ? Extract<GetTableName<JoinTable>, TableName> extends never ? Column<Config, Name, TableName, DataType, IsNotNull, HasDefault, JoinType> : Column<Config, Name, TableName, DataType, IsNotNull, HasDefault, ToJoinType<JoinType, 'left-join'>> : never;
};
declare type AddRightJoin<Columns, JoinTable> = {
[K in keyof Columns]: Columns[K] extends Column<infer Name, infer TableName, infer DataType, infer IsNotNull, infer HasDefault, infer JoinType> ? Extract<GetTableName<JoinTable>, TableName> extends never ? Column<Name, TableName, DataType, IsNotNull, HasDefault, ToJoinType<JoinType, 'left-side-of-right-join'>> : Columns[K] : never;
[K in keyof Columns]: Columns[K] extends Column<infer Config, infer Name, infer TableName, infer DataType, infer IsNotNull, infer HasDefault, infer JoinType> ? Extract<GetTableName<JoinTable>, TableName> extends never ? Column<Config, Name, TableName, DataType, IsNotNull, HasDefault, ToJoinType<JoinType, 'left-side-of-right-join'>> : Columns[K] : never;
};
declare type AddJoinType<Columns, NewJoinType extends JoinType> = {
[K in keyof Columns]: Columns[K] extends Column<infer Name, infer TableName, infer DataType, infer IsNotNull, infer HasDefault, infer OldJoinType> ? Column<Name, TableName, DataType, IsNotNull, HasDefault, ToJoinType<OldJoinType, NewJoinType>> : never;
[K in keyof Columns]: Columns[K] extends Column<infer Config, infer Name, infer TableName, infer DataType, infer IsNotNull, infer HasDefault, infer OldJoinType> ? Column<Config, Name, TableName, DataType, IsNotNull, HasDefault, ToJoinType<OldJoinType, NewJoinType>> : never;
};
declare type Join<Query extends SelectQuery<any, boolean>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<ExistingColumns & Omit<GetColumns<JoinTable>, keyof ExistingColumns>, true> : SelectQuery<ExistingColumns, false> : never;
declare type GetColumns<From extends Table<any, any> | FromItem<any>> = From extends Table<any, infer Columns> ? Columns : From extends FromItem<infer Q> ? Q extends Query<infer Returning> ? Returning : never : never;
declare type LeftJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<ExistingColumns & AddJoinType<GetColumns<JoinTable>, 'left-join'>> : SelectQuery<AddLeftJoin<ExistingColumns, JoinTable>> : never;
declare type RightJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<AddJoinType<ExistingColumns, 'left-side-of-right-join'> & GetColumns<JoinTable>> : SelectQuery<AddRightJoin<ExistingColumns, JoinTable>> : never;
declare type FullJoin<Query extends SelectQuery<any>, JoinTable extends Table<any, any> | FromItem<any>> = Query extends SelectQuery<infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<AddJoinType<ExistingColumns & GetColumns<JoinTable>, 'full-join'>> : SelectQuery<AddJoinType<ExistingColumns, 'full-join'>> : never;
export declare class SelectQuery<Columns extends {
declare type Join<Query extends SelectQuery<any, any, boolean>, JoinTable extends AnyTable | FromItem<any, any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, ExistingColumns & Omit<GetColumns<JoinTable>, keyof ExistingColumns>, true> : SelectQuery<Config, ExistingColumns, false> : never;
declare type GetColumns<From extends AnyTable | FromItem<any, any>> = From extends Table<any, any, infer Columns> ? Columns : From extends FromItem<any, infer Q> ? Q extends Query<infer Returning> ? Returning : never : never;
declare type LeftJoin<Query extends SelectQuery<any, any>, JoinTable extends AnyTable | FromItem<any, any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, ExistingColumns & AddJoinType<GetColumns<JoinTable>, 'left-join'>> : SelectQuery<Config, AddLeftJoin<ExistingColumns, JoinTable>> : never;
declare type RightJoin<Query extends SelectQuery<any, any>, JoinTable extends AnyTable | FromItem<any, any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, AddJoinType<ExistingColumns, 'left-side-of-right-join'> & GetColumns<JoinTable>> : SelectQuery<Config, AddRightJoin<ExistingColumns, JoinTable>> : never;
declare type FullJoin<Query extends SelectQuery<any, any>, JoinTable extends AnyTable | FromItem<any, any>> = Query extends SelectQuery<infer Config, infer ExistingColumns, infer IncludesStar> ? IncludesStar extends true ? SelectQuery<Config, AddJoinType<ExistingColumns & GetColumns<JoinTable>, 'full-join'>> : SelectQuery<Config, AddJoinType<ExistingColumns, 'full-join'>> : never;
export declare class SelectQuery<Config extends DbConfig, Columns extends {
[column: string]: any;

@@ -40,32 +41,38 @@ }, IncludesStar = false> extends Query<Columns> {

constructor(queryExecutor: QueryExecutorFn, returningKeys: string[], includesStar: boolean, tokens: Token[]);
then<Result1, Result2 = never>(onFulfilled?: ((value: ResultSet<SelectQuery<Columns>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
exec(): Promise<{
rows: any[];
affectedCount: number;
}>;
then<Result1, Result2 = never>(onFulfilled?: ((value: ResultSet<Config, SelectQuery<Config, Columns>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
private newSelectQuery;
from<T extends Table<any, any>>(fromItem: T): T extends TableDefinition<any> ? never : Join<SelectQuery<Columns, IncludesStar>, T>;
join<T extends Table<any, any>>(table: T): Join<SelectQuery<Columns, IncludesStar>, T>;
innerJoin<JoinTable extends Table<string, any>>(table: JoinTable): Join<SelectQuery<Columns, IncludesStar>, JoinTable>;
leftOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): LeftJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
leftJoin<JoinTable extends Table<any, any>>(table: JoinTable): LeftJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
rightOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): RightJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
rightJoin<JoinTable extends Table<any, any>>(table: JoinTable): RightJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
fullOuterJoin<JoinTable extends Table<any, any>>(table: JoinTable): FullJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
fullJoin<JoinTable extends Table<any, any>>(table: JoinTable): FullJoin<SelectQuery<Columns, IncludesStar>, JoinTable>;
crossJoin<JoinTable extends Table<any, any>>(table: Table<any, any>): Join<SelectQuery<Columns, IncludesStar>, JoinTable>;
forUpdate(): SelectQuery<Columns>;
forNoKeyUpdate(): SelectQuery<Columns>;
forShare(): SelectQuery<Columns>;
forKeyShare(): SelectQuery<Columns>;
on(joinCondition: Expression<boolean, boolean, string>): SelectQuery<Columns, IncludesStar>;
using(...columns: Column<any, any, any, any, any, any>[]): SelectQuery<Columns>;
where(condition: Expression<boolean, boolean, string>): SelectQuery<Columns>;
groupBy(...expressions: Expression<any, any, any>[]): SelectQuery<Columns>;
having(...conditions: Expression<boolean, boolean, string>[]): SelectQuery<Columns>;
window(): SelectQuery<Columns>;
orderBy(...expressions: Expression<any, any, any>[]): SelectQuery<Columns>;
limit(limit: number | 'ALL'): SelectQuery<Columns>;
offset(start: number): SelectQuery<Columns>;
fetch(count: number): SelectQuery<Columns>;
of(table: Table<any, any>): SelectQuery<Columns>;
nowait(): SelectQuery<Columns>;
skipLocked(): SelectQuery<Columns>;
from<T extends AnyTable>(fromItem: T): T extends TableDefinition<any> ? never : Join<SelectQuery<Config, Columns, IncludesStar>, T>;
join<T extends AnyTable>(table: T): Join<SelectQuery<Config, Columns, IncludesStar>, T>;
innerJoin<JoinTable extends AnyTable>(table: JoinTable): Join<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
leftOuterJoin<JoinTable extends AnyTable>(table: JoinTable): LeftJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
leftJoin<JoinTable extends AnyTable>(table: JoinTable): LeftJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
rightOuterJoin<JoinTable extends AnyTable>(table: JoinTable): RightJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
rightJoin<JoinTable extends AnyTable>(table: JoinTable): RightJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
fullOuterJoin<JoinTable extends AnyTable>(table: JoinTable): FullJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
fullJoin<JoinTable extends AnyTable>(table: JoinTable): FullJoin<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
crossJoin<JoinTable extends AnyTable>(table: AnyTable): Join<SelectQuery<Config, Columns, IncludesStar>, JoinTable>;
forUpdate(): SelectQuery<Config, Columns>;
forNoKeyUpdate(): SelectQuery<Config, Columns>;
forShare(): SelectQuery<Config, Columns>;
forKeyShare(): SelectQuery<Config, Columns>;
on(joinCondition: Expression<Config, boolean, boolean, string>): SelectQuery<Config, Columns, IncludesStar>;
using(...columns: AnyColumn[]): SelectQuery<Config, Columns>;
where(condition: Expression<Config, boolean, boolean, string>): SelectQuery<Config, Columns>;
groupBy(...expressions: AnyExpression[]): SelectQuery<Config, Columns>;
having(...conditions: Expression<Config, boolean, boolean, string>[]): SelectQuery<Config, Columns>;
window(): SelectQuery<Config, Columns>;
orderBy(...expressions: AnyExpression[]): SelectQuery<Config, Columns>;
limit(limit: number | 'ALL'): SelectQuery<Config, Columns>;
offset(start: number): SelectQuery<Config, Columns>;
fetch(count: number): SelectQuery<Config, Columns>;
of(table: AnyTable): SelectQuery<Config, Columns>;
nowait(): SelectQuery<Config, Columns>;
skipLocked(): SelectQuery<Config, Columns>;
union(query: Query<any>): SelectQuery<Config, Columns, IncludesStar>;
unionAll(query: Query<any>): SelectQuery<Config, Columns, IncludesStar>;
}
export declare const makeSelect: (queryExecutor: QueryExecutorFn, initialTokens?: Token[] | undefined) => SelectFn;
export declare const makeSelect: <Config extends DbConfig>(queryExecutor: QueryExecutorFn, initialTokens?: Token[] | undefined) => SelectFn<Config>;

@@ -20,2 +20,6 @@ "use strict";

}
async exec() {
const queryState = tokens_1.createQueryState(this.tokens);
return this.queryExecutor(queryState.text.join(` `), queryState.parameters);
}
then(onFulfilled, onRejected) {

@@ -182,2 +186,8 @@ const queryState = tokens_1.createQueryState(this.tokens);

}
union(query) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`UNION`), ...query.toTokens()]);
}
unionAll(query) {
return this.newSelectQuery([...this.tokens, new tokens_1.StringToken(`UNION ALL`), ...query.toTokens()]);
}
}

@@ -184,0 +194,0 @@ exports.SelectQuery = SelectQuery;

@@ -1,10 +0,11 @@

import { Column, ColumnSet } from './column';
import { Expression } from './expression';
import { AnyExpression, BooleanExpression, Expression, NumberExpression, RawExpression, TextExpression } from './expression';
import { AnyColumn, Column, ColumnSet } from './column';
import { SelectQuery } from './select';
import { Star } from './sql-functions';
export declare type GetSelectableName<S> = S extends Column<infer A2, string, any, boolean, boolean, any> ? A2 : S extends Expression<any, boolean, infer A1> ? A1 : S extends SelectQuery<infer Columns> ? keyof Columns : never;
export declare type GetSelectable<C extends Selectable> = C extends ColumnSet<infer Columns> ? Columns : {
import { DbConfig } from './config';
export declare type GetSelectableName<S> = S extends Column<any, infer Name, string, any, boolean, boolean, any> ? Name : S extends NumberExpression<any, any, boolean, infer Name> ? Name : S extends TextExpression<any, any, boolean, infer Name> ? Name : S extends BooleanExpression<any, any, boolean, infer Name> ? Name : S extends RawExpression<any, any, boolean, infer Name> ? Name : S extends Expression<any, any, boolean, infer Name> ? Name : S extends SelectQuery<any, infer Columns> ? keyof Columns : never;
export declare type GetSelectable<C extends Selectable> = C extends ColumnSet<infer Columns> ? Columns : GetSelectableName<C> extends string ? {
[K in GetSelectableName<C>]: C;
};
export declare type Selectable = Expression<any, any, any> | SelectQuery<any> | Column<any, any, any, boolean, boolean, any> | ColumnSet<any> | Star;
} : never;
export declare type Selectable = AnyExpression | SelectQuery<any, any, boolean> | AnyColumn | ColumnSet<any> | Star;
declare type ContainsStar<Selectables> = Extract<Star, Selectables> extends never ? false : true;

@@ -25,5 +26,5 @@ declare type GetSelectables<Columns extends Array<any>> = {

} ? T : never;
export interface SelectFn {
<Columns extends Array<Selectable>>(...columns: [...Columns]): SelectQuery<ToColumns<TupleToIntersection<GetSelectables<Columns>>>, ContainsStar<Columns[number]>>;
export interface SelectFn<Config extends DbConfig> {
<Columns extends Selectable[]>(...columns: [...Columns]): SelectQuery<Config, ToColumns<TupleToIntersection<GetSelectables<Columns>>>, ContainsStar<Columns[number]>>;
}
export {};
import { AllStarToken } from './tokens';
import { AnyNumber, Int8 } from './data-types';
import { Any, AnyNumber, Int4, Int8, Text, ToPostgresDataType } from './data-types';
import { AnyTable, Table } from './TableType';
import { AnyExpression, DefaultExpression, Expression, RawExpression } from './expression';
import type { ColumnSet } from './column';
import { DefaultExpression, Expression } from './expression';
import { DbConfig, DefaultDbConfig, GetResultType } from './config';
import { Query } from './query';
import { Table } from './TableType';
export declare class Star {

@@ -14,29 +15,30 @@ private readonly table?;

}
export declare function raw<DataType, IsNotNull extends boolean = false, Name extends string = '?column?'>(strings: TemplateStringsArray, ...parameters: any[]): Expression<DataType, IsNotNull, Name>;
export declare const now: <Config extends DbConfig = DefaultDbConfig>() => RawExpression<Config, Date, true, "now">;
export declare function raw<DataType, IsNotNull extends boolean = false, Name extends string = '?column?', Config extends DbConfig = DefaultDbConfig>(strings: TemplateStringsArray, ...parameters: any[]): Expression<Config, DataType, IsNotNull, Name>;
export declare const count: <Config extends DbConfig = DefaultDbConfig>(expression?: import("./expression").BooleanExpression<any, any, any, any> | import("./expression").NumberExpression<any, any, any, any> | import("./expression").TextExpression<any, any, any, any> | import("./expression").UuidExpression<any, unknown, any, any> | RawExpression<any, any, any, any> | undefined) => import("./expression").NumberExpression<Config, "Int8", true, "count">;
export declare function star(): Star;
export declare function star<T extends Table<any, any>>(table: T): T extends Table<any, infer Columns> ? ColumnSet<Columns> : never;
export declare const stringAgg: (expression: Expression<string, boolean, any>, delimiter: string, ...orderBy: Expression<any, any, any>[]) => Expression<string, false, 'stringAgg'>;
export declare const bitAnd: <T extends AnyNumber>(expression: Expression<T, boolean, any>) => Expression<T, false, "bitAnd">;
export declare const bitOr: <T extends AnyNumber>(expression: Expression<T, boolean, any>) => Expression<T, false, "bitOr">;
export declare const boolAnd: (expression: Expression<boolean, boolean, any>) => Expression<number, false, "boolAnd">;
export declare const boolOr: (expression: Expression<boolean, boolean, any>) => Expression<number, false, "boolOr">;
export declare const every: (expression: Expression<boolean, boolean, any>) => Expression<number, false, "every">;
export declare const arrayAgg: <DataType>(expression: Expression<DataType, boolean, any>) => Expression<DataType[], false, "arrayAgg">;
export declare const count: (expression?: Expression<any, any, any> | undefined) => Expression<Int8, true, 'count'>;
export declare const min: <DataType>(expression: Expression<DataType, boolean, any>) => Expression<DataType, false, "min">;
export declare const max: <DataType>(expression: Expression<DataType, boolean, any>) => Expression<DataType, false, "max">;
export declare const avg: <T extends AnyNumber>(expression: Expression<T, boolean, any>) => Expression<T, false, "avg">;
export declare const sum: <T extends AnyNumber>(expression: Expression<T, boolean, any>) => Expression<T, false, "sum">;
export declare const xmlagg: <DataType>(expression: Expression<DataType, boolean, any>) => Expression<number, false, "xmlagg">;
export declare const not: (expression: Expression<boolean, boolean, string>) => DefaultExpression<boolean, true>;
export declare const and: (expression: Expression<boolean, boolean, string>) => DefaultExpression<boolean, true>;
export declare const or: (expression: Expression<boolean, boolean, string>) => DefaultExpression<boolean, true>;
export declare const group: (expression: Expression<boolean, boolean, string>) => DefaultExpression<boolean, true>;
export declare const any: <T>(array: T[]) => Expression<T, true, "?column?">;
export declare const now: () => Expression<Date, true, "now">;
export declare const exists: (expression: Expression<any, any, any> | Query<any>) => DefaultExpression<boolean>;
export declare const andNotExists: (expression: Expression<any, any, any> | Query<any>) => DefaultExpression<boolean>;
export declare const andExists: (expression: Expression<any, any, any> | Query<any>) => DefaultExpression<boolean>;
export declare const notExists: (expression: Expression<any, any, any> | Query<any>) => DefaultExpression<boolean>;
export declare const coalesce: <DataType>(...expressions: (DataType | Expression<DataType, boolean, any>)[]) => Expression<DataType, true, "coalesce">;
export declare function star<T extends AnyTable>(table: T): T extends Table<any, any, infer Columns> ? ColumnSet<Columns> : never;
export declare const stringAgg: <Config extends DbConfig>(expression: import("./expression").TextExpression<Config, "Text", boolean, any>, delimiter: string, ...orderBy: AnyExpression[]) => import("./expression").TextExpression<Config, "Text", false, "stringAgg">;
export declare const bitAnd: <Config extends DbConfig, T extends AnyNumber>(expression: Expression<Config, T, boolean, any>) => Expression<Config, T, false, "bitAnd">;
export declare const bitOr: <Config extends DbConfig, T extends AnyNumber>(expression: Expression<Config, T, boolean, any>) => Expression<Config, T, false, "bitOr">;
export declare const boolAnd: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, any> | import("./expression").BooleanExpression<Config, true, boolean, any>) => import("./expression").NumberExpression<Config, number, false, "boolAnd">;
export declare const boolOr: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, any> | import("./expression").BooleanExpression<Config, true, boolean, any>) => import("./expression").NumberExpression<Config, number, false, "boolOr">;
export declare const every: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, any> | import("./expression").BooleanExpression<Config, true, boolean, any>) => import("./expression").NumberExpression<Config, number, false, "every">;
export declare const arrayAgg: <Config extends DbConfig, DataType>(expression: Expression<Config, DataType, boolean, any>) => RawExpression<Config, GetResultType<Config, DataType>[], false, "arrayAgg">;
export declare const min: <Config extends DbConfig, DataType>(expression: Expression<Config, DataType, boolean, any>) => Expression<Config, DataType, false, "min">;
export declare const max: <Config extends DbConfig, DataType>(expression: Expression<Config, DataType, boolean, any>) => Expression<Config, DataType, false, "max">;
export declare const avg: <Config extends DbConfig, T extends AnyNumber>(expression: Expression<Config, T, boolean, any>) => Expression<Config, T, false, "avg">;
export declare const sum: <Config extends DbConfig, T extends AnyNumber>(expression: Expression<Config, T, boolean, any>) => Expression<Config, T extends "Int4" ? "Int8" : T, false, "sum">;
export declare const xmlagg: <Config extends DbConfig, DataType>(expression: Expression<Config, DataType, boolean, any>) => import("./expression").NumberExpression<Config, number, false, "xmlagg">;
export declare const not: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, string> | import("./expression").BooleanExpression<Config, true, boolean, string>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const and: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, string> | import("./expression").BooleanExpression<Config, true, boolean, string>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const or: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, string> | import("./expression").BooleanExpression<Config, true, boolean, string>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const group: <Config extends DbConfig>(expression: import("./expression").BooleanExpression<Config, false, boolean, string> | import("./expression").BooleanExpression<Config, true, boolean, string>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const any: <Config extends DbConfig, T>(array: T[]) => RawExpression<Config, T, true, "?column?">;
export declare const exists: <Config extends DbConfig>(expression: AnyExpression | Query<any>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const andNotExists: <Config extends DbConfig>(expression: Query<any> | import("./expression").BooleanExpression<Config, any, any, any> | import("./expression").NumberExpression<Config, any, any, any> | import("./expression").TextExpression<Config, any, any, any> | import("./expression").UuidExpression<Config, unknown, any, any> | RawExpression<Config, any, any, any>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const andExists: <Config extends DbConfig>(expression: Query<any> | import("./expression").BooleanExpression<Config, any, any, any> | import("./expression").NumberExpression<Config, any, any, any> | import("./expression").TextExpression<Config, any, any, any> | import("./expression").UuidExpression<Config, unknown, any, any> | RawExpression<Config, any, any, any>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const notExists: <Config extends DbConfig>(expression: Query<any> | import("./expression").BooleanExpression<Config, any, any, any> | import("./expression").NumberExpression<Config, any, any, any> | import("./expression").TextExpression<Config, any, any, any> | import("./expression").UuidExpression<Config, unknown, any, any> | RawExpression<Config, any, any, any>) => import("./expression").BooleanExpression<Config, false, true, "?column?"> | import("./expression").BooleanExpression<Config, true, true, "?column?">;
export declare const coalesce: <Config extends DbConfig, DataType>(...expressions: (Expression<Config, DataType, boolean, any> | GetResultType<Config, DataType>)[]) => Expression<Config, DataType, false, "coalesce">;
export declare const cast: <Config extends DbConfig, T extends Any, IsNotNull extends boolean, Name extends string>(expression: import("./expression").BooleanExpression<Config, any, IsNotNull, Name> | import("./expression").NumberExpression<Config, any, IsNotNull, Name> | import("./expression").TextExpression<Config, any, IsNotNull, Name> | import("./expression").UuidExpression<Config, unknown, IsNotNull, Name> | RawExpression<Config, any, IsNotNull, Name>, dataType: ToPostgresDataType<T>) => Expression<Config, T, IsNotNull, Name>;
export declare function toSql(query: Query<any>): {

@@ -43,0 +45,0 @@ text: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toSql = exports.coalesce = exports.notExists = exports.andExists = exports.andNotExists = exports.exists = exports.now = exports.any = exports.group = exports.or = exports.and = exports.not = exports.xmlagg = exports.sum = exports.avg = exports.max = exports.min = exports.count = exports.arrayAgg = exports.every = exports.boolOr = exports.boolAnd = exports.bitOr = exports.bitAnd = exports.stringAgg = exports.star = exports.raw = exports.Star = void 0;
exports.toSql = exports.cast = exports.coalesce = exports.notExists = exports.andExists = exports.andNotExists = exports.exists = exports.any = exports.group = exports.or = exports.and = exports.not = exports.xmlagg = exports.sum = exports.avg = exports.max = exports.min = exports.arrayAgg = exports.every = exports.boolOr = exports.boolAnd = exports.bitOr = exports.bitAnd = exports.stringAgg = exports.star = exports.count = exports.raw = exports.now = exports.Star = void 0;
const tokens_1 = require("./tokens");

@@ -21,2 +21,4 @@ const expression_1 = require("./expression");

exports.Star = Star;
const now = () => new expression_1.InternalExpression([new tokens_1.StringToken(`NOW()`)], 'now');
exports.now = now;
function raw(strings, ...parameters) {

@@ -30,5 +32,13 @@ const tokens = strings.flatMap((string, index) => {

});
return new expression_1.Expression(tokens, '');
return new expression_1.InternalExpression(tokens, '');
}
exports.raw = raw;
const count = (expression) => {
if (!expression) {
return new expression_1.InternalExpression([new tokens_1.StringToken(`COUNT(*)`)], 'count');
}
const tokens = expression.toTokens();
return new expression_1.InternalExpression([new tokens_1.StringToken(`COUNT`), new tokens_1.GroupToken(tokens)], 'count');
};
exports.count = count;
function star(table) {

@@ -42,3 +52,3 @@ if (table) {

const stringAgg = (expression, delimiter, ...orderBy) => {
return new expression_1.Expression([
return new expression_1.InternalExpression([
new tokens_1.StringToken(`string_agg`),

@@ -62,57 +72,71 @@ new tokens_1.GroupToken([

exports.stringAgg = stringAgg;
const bitAnd = (expression) => new expression_1.Expression([new tokens_1.StringToken(`bit_and`), new tokens_1.GroupToken(expression.toTokens(false))], 'bitAnd');
const bitAnd = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`bit_and`), new tokens_1.GroupToken(expression.toTokens(false))], 'bitAnd');
exports.bitAnd = bitAnd;
const bitOr = (expression) => new expression_1.Expression([new tokens_1.StringToken(`bit_or`), new tokens_1.GroupToken(expression.toTokens(false))], 'bitOr');
const bitOr = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`bit_or`), new tokens_1.GroupToken(expression.toTokens(false))], 'bitOr');
exports.bitOr = bitOr;
const boolAnd = (expression) => new expression_1.Expression([new tokens_1.StringToken(`bool_and`), new tokens_1.GroupToken(expression.toTokens(false))], 'boolAnd');
const boolAnd = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`bool_and`), new tokens_1.GroupToken(expression.toTokens(false))], 'boolAnd');
exports.boolAnd = boolAnd;
const boolOr = (expression) => new expression_1.Expression([new tokens_1.StringToken(`bool_or`), new tokens_1.GroupToken(expression.toTokens(false))], 'boolOr');
const boolOr = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`bool_or`), new tokens_1.GroupToken(expression.toTokens(false))], 'boolOr');
exports.boolOr = boolOr;
const every = (expression) => new expression_1.Expression([new tokens_1.StringToken(`every`), new tokens_1.GroupToken(expression.toTokens(false))], 'every');
const every = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`every`), new tokens_1.GroupToken(expression.toTokens(false))], 'every');
exports.every = every;
const arrayAgg = (expression) => new expression_1.Expression([new tokens_1.StringToken(`array_agg`), new tokens_1.GroupToken(expression.toTokens(false))], 'arrayAgg');
const arrayAgg = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`array_agg`), new tokens_1.GroupToken(expression.toTokens(false))], 'arrayAgg');
exports.arrayAgg = arrayAgg;
const count = (expression) => {
if (!expression) {
return new expression_1.Expression([new tokens_1.StringToken(`COUNT(*)`)], 'count');
}
const tokens = expression.toTokens();
return new expression_1.Expression([new tokens_1.StringToken(`COUNT`), new tokens_1.GroupToken(tokens)], 'count');
};
exports.count = count;
const min = (expression) => new expression_1.Expression([new tokens_1.StringToken(`MIN`), new tokens_1.GroupToken(expression.toTokens())], 'min');
const min = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`MIN`), new tokens_1.GroupToken(expression.toTokens())], 'min');
exports.min = min;
const max = (expression) => new expression_1.Expression([new tokens_1.StringToken(`MAX`), new tokens_1.GroupToken(expression.toTokens())], 'max');
const max = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`MAX`), new tokens_1.GroupToken(expression.toTokens())], 'max');
exports.max = max;
const avg = (expression) => new expression_1.Expression([new tokens_1.StringToken(`AVG`), new tokens_1.GroupToken(expression.toTokens())], 'avg');
const avg = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`AVG`), new tokens_1.GroupToken(expression.toTokens())], 'avg');
exports.avg = avg;
const sum = (expression) => new expression_1.Expression([new tokens_1.StringToken(`SUM`), new tokens_1.GroupToken(expression.toTokens())], 'sum');
// Selecting the sum of an int4 results in a int8, but selecting the sum of any other data type
// doesn't seem to change the return type at all.
const sum = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`SUM`), new tokens_1.GroupToken(expression.toTokens())], 'sum');
exports.sum = sum;
const xmlagg = (expression) => new expression_1.Expression([new tokens_1.StringToken(`xmlagg`), new tokens_1.GroupToken(expression.toTokens())], 'xmlagg');
const xmlagg = (expression) => new expression_1.InternalExpression([new tokens_1.StringToken(`xmlagg`), new tokens_1.GroupToken(expression.toTokens())], 'xmlagg');
exports.xmlagg = xmlagg;
const not = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`NOT`), new tokens_1.GroupToken(expression.toTokens())]);
const not = (expression) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`NOT`),
new tokens_1.GroupToken(expression.toTokens()),
]);
exports.not = not;
const and = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`AND`), new tokens_1.GroupToken(expression.toTokens())]);
const and = (expression) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`AND`),
new tokens_1.GroupToken(expression.toTokens()),
]);
exports.and = and;
const or = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`OR`), new tokens_1.GroupToken(expression.toTokens())]);
const or = (expression) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`OR`),
new tokens_1.GroupToken(expression.toTokens()),
]);
exports.or = or;
const group = (expression) => new expression_1.DefaultExpression([new tokens_1.GroupToken(expression.toTokens())]);
const group = (expression) => new expression_1.InternalDefaultExpression([new tokens_1.GroupToken(expression.toTokens())]);
exports.group = group;
const any = (array) => new expression_1.Expression([new tokens_1.StringToken(`ANY`), new tokens_1.GroupToken([new tokens_1.ParameterToken(array)])], '?column?');
const any = (array) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`ANY`),
new tokens_1.GroupToken([new tokens_1.ParameterToken(array)]),
]);
exports.any = any;
const now = () => new expression_1.Expression([new tokens_1.StringToken(`NOW()`)], 'now');
exports.now = now;
const exists = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`EXISTS`), new tokens_1.GroupToken(expression.toTokens())]);
const exists = (expression) => new expression_1.InternalDefaultExpression([new tokens_1.StringToken(`EXISTS`), new tokens_1.GroupToken(expression.toTokens())]);
exports.exists = exists;
const andNotExists = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`AND NOT EXISTS`), new tokens_1.GroupToken(expression.toTokens())]);
const andNotExists = (expression) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`AND NOT EXISTS`),
new tokens_1.GroupToken(expression.toTokens()),
]);
exports.andNotExists = andNotExists;
const andExists = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`AND EXISTS`), new tokens_1.GroupToken(expression.toTokens())]);
const andExists = (expression) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`AND EXISTS`),
new tokens_1.GroupToken(expression.toTokens()),
]);
exports.andExists = andExists;
const notExists = (expression) => new expression_1.DefaultExpression([new tokens_1.StringToken(`NOT EXISTS`), new tokens_1.GroupToken(expression.toTokens())]);
const notExists = (expression) => new expression_1.InternalDefaultExpression([
new tokens_1.StringToken(`NOT EXISTS`),
new tokens_1.GroupToken(expression.toTokens()),
]);
exports.notExists = notExists;
// TODO: it's still possible for coalesce to return nullable. It depends on the input.
const coalesce = (...expressions) => {
return new expression_1.Expression([
return new expression_1.InternalExpression([
new tokens_1.StringToken(`coalesce`),
new tokens_1.GroupToken([
new tokens_1.SeparatorToken(',', expressions.map((expression) => expression instanceof expression_1.Expression
new tokens_1.SeparatorToken(',', expressions.map((expression) => expression instanceof expression_1.InternalExpression
? new tokens_1.CollectionToken(expression.toTokens())

@@ -124,2 +148,11 @@ : new tokens_1.ParameterToken(expression))),

exports.coalesce = coalesce;
const cast = (expression, dataType) => new expression_1.InternalExpression([
new tokens_1.StringToken(`CAST`),
new tokens_1.GroupToken([
...expression.toTokens(),
new tokens_1.StringToken(`AS`),
new tokens_1.ParameterToken(dataType),
]),
], expression.getName());
exports.cast = cast;
function toSql(query) {

@@ -126,0 +159,0 @@ const queryState = tokens_1.createQueryState(query.toTokens());

@@ -1,4 +0,5 @@

import { Column, ColumnDefinition } from './column';
export declare type TableRow<T> = T extends TableDefinition<infer Columns> ? {
[K in keyof Columns]: Columns[K] extends ColumnDefinition<infer DataType, infer IsNotNull, boolean> ? IsNotNull extends true ? DataType : DataType | undefined : never;
import { ColumnDefinition } from './column';
import { DbConfig, GetResultType } from './config';
export declare type TableRow<Config extends DbConfig, T> = T extends TableDefinition<infer Columns> ? {
[K in keyof Columns]: Columns[K] extends ColumnDefinition<infer DataType, infer IsNotNull, boolean> ? IsNotNull extends true ? GetResultType<Config, DataType> : GetResultType<Config, DataType> | GetResultType<Config, 'Null'> : never;
} : never;

@@ -9,11 +10,6 @@ export declare class TableDefinition<Columns> {

export declare const makeTable: <TableName extends string, TableDefinition_1 extends {
[column: string]: ColumnDefinition<any, any, any>;
}>(tableName: TableName, originalTableName: string | undefined, tableDefinition: TableDefinition_1) => { [K in keyof TableDefinition_1]: K extends string ? Column<K, TableName, TableDefinition_1[K] extends ColumnDefinition<infer DataType, any, any> ? DataType : never, TableDefinition_1[K] extends ColumnDefinition<any, infer IsNotNull, any> ? IsNotNull : never, TableDefinition_1[K] extends ColumnDefinition<any, any, infer HasDefault> ? HasDefault : never, undefined> : never; } & {
as<T extends string>(alias: T): any;
getName(): TableName;
getOriginalName(): string | undefined;
_tableBrand: any;
};
[column: string]: ColumnDefinition<any, any, any, false>;
}>(tableName: TableName, originalTableName: string | undefined, tableDefinition: TableDefinition_1) => any;
export declare const defineTable: <Columns extends {
[column: string]: ColumnDefinition<any, any, any>;
[column: string]: ColumnDefinition<any, any, any, false>;
}>(tableDefinition: Columns) => TableDefinition<Columns>;

@@ -11,3 +11,3 @@ "use strict";

const columns = columnNames.reduce((map, columnName) => {
const column = new column_1.Column(columnName, tableName, undefined);
const column = new column_1.InternalColumn(columnName, tableName, undefined);
map[columnName] = column;

@@ -14,0 +14,0 @@ return map;

import { Column } from './column';
export declare type Table<TableName, Columns> = Columns & InternalTable<TableName, Columns>;
export interface InternalTable<TableName, Columns> {
as<T>(alias: T): Table<T, {
[K in keyof Columns]: Columns[K] extends Column<infer Name, string, infer DataType, infer IsNotNull, infer HasDefault, infer JoinType> ? Column<Name, T, DataType, IsNotNull, HasDefault, JoinType> : never;
import { DbConfig } from './config';
export declare type AnyTable = Table<any, any, any>;
export declare type Table<Config extends DbConfig, TableName, Columns> = Columns & InternalTable<Config, TableName, Columns>;
export interface InternalTable<Config extends DbConfig, TableName, Columns> {
as<T>(alias: T): Table<Config, T, {
[K in keyof Columns]: Columns[K] extends Column<Config, infer Name, string, infer DataType, infer IsNotNull, infer HasDefault, infer JoinType> ? Column<Config, Name, T, DataType, IsNotNull, HasDefault, JoinType> : never;
}>;
}
import { State, Token } from './token';
import type { Table } from '../TableType';
import type { AnyTable } from '../TableType';
export declare class AllStarToken extends Token {
constructor();
reduce(state: State, numberOfParameters: number, tables: Table<any, any>[]): State;
reduce(state: State, numberOfParameters: number, tables: AnyTable[]): State;
}
import { State, Token } from './token';
import type { Table } from '../TableType';
import type { AnyTable } from '../TableType';
export declare class CollectionToken extends Token {
tokens: Token[];
constructor(tokens: Token[]);
reduce(state: State, numberOfParameters: number, tables: Table<any, any>[]): State;
reduce(state: State, numberOfParameters: number, tables: AnyTable[]): State;
}
import { State, Token } from './token';
import type { Table } from '../TableType';
import type { AnyTable } from '../TableType';
export declare type Separator = ',';

@@ -8,3 +8,3 @@ export declare class SeparatorToken extends Token {

constructor(separator: Separator, tokens: Token[]);
reduce(state: State, numberOfParameters: number, tables: Table<any, any>[]): State;
reduce(state: State, numberOfParameters: number, tables: AnyTable[]): State;
}
import { State, Token } from './token';
import type { Table } from '../TableType';
import type { AnyTable } from '../TableType';
export declare class TableStarToken extends Token {
private readonly table;
constructor(table: Table<any, any>);
constructor(table: AnyTable);
reduce(state: State, numberOfParameters: number): State;
}
import { State, Token } from './token';
import { Table } from '../TableType';
import { AnyTable } from '../TableType';
export declare class TableToken extends Token {
private readonly table;
constructor(table: Table<any, any>);
constructor(table: AnyTable);
reduce(state: State): State;
getTable(): any;
}

@@ -1,4 +0,4 @@

import type { Table } from '../TableType';
import type { AnyTable } from '../TableType';
export declare abstract class Token {
abstract reduce(state: any, numberOfParameters: number, tables: Table<any, any>[]): any;
abstract reduce(state: any, numberOfParameters: number, tables: AnyTable[]): any;
}

@@ -5,0 +5,0 @@ export interface State {

import { QueryExecutorFn, ResultType } from './types';
import { Token } from './tokens';
import { DbConfig } from './config';
import { Query } from './query';
import { Table } from './TableType';
import { AnyTable } from './TableType';
import { TableDefinition } from './table';
export declare const makeTruncate: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : TruncateQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
export declare class TruncateQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {
export declare const makeTruncate: <Config extends DbConfig>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => T extends TableDefinition<any> ? never : TruncateQuery<T, number>;
export declare class TruncateQuery<T extends AnyTable, Returning = number> extends Query<Returning> {
private readonly queryExecutor;

@@ -14,6 +15,6 @@ private readonly table;

then<Result1, Result2 = never>(onFulfilled?: ((value: number) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
restartIdentity<T extends Table<any, any>>(): any;
continueIdentity<T extends Table<any, any>>(): any;
cascade<T extends Table<any, any>>(): TruncateQuery<any, number, any>;
restrict<T extends Table<any, any>>(): TruncateQuery<any, number, any>;
restartIdentity(): any;
continueIdentity(): any;
cascade(): TruncateQuery<any, number>;
restrict(): TruncateQuery<any, number>;
private newTruncateQuery;

@@ -20,0 +21,0 @@ getReturningKeys(): string[];

@@ -15,1 +15,2 @@ export declare type ResultType = 'ROWS' | 'AFFECTED_COUNT';

}>;
export declare type Err<Message extends string> = {} & Message;

@@ -0,9 +1,10 @@

import { Column } from './column';
import { AnyTable, Table } from './TableType';
import { Token } from './tokens';
import { DbConfig, GetResultType } from './config';
import { GetReturning, QueryExecutorFn, ResultType } from './types';
import { Column } from './column';
import { Expression } from './expression';
import { Query } from './query';
import { ResultSet } from './result-set';
import { Table } from './TableType';
export declare class UpdateQuery<T extends Table<any, any>, Returning = number, TableColumns = T extends Table<any, infer Columns> ? Columns : never> extends Query<Returning> {
export declare class UpdateQuery<Config extends DbConfig, T extends AnyTable, Returning = number, TableColumns = T extends Table<Config, any, infer Columns> ? Columns : never> extends Query<Returning> {
private readonly queryExecutor;

@@ -16,19 +17,19 @@ private readonly returningKeys;

constructor(queryExecutor: QueryExecutorFn, returningKeys: string[], table: T, resultType: ResultType, tokens: Token[]);
then<Result1, Result2 = never>(onFulfilled?: ((value: Returning extends number ? Returning : ResultSet<UpdateQuery<T, Returning>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
where(condition: Expression<boolean, boolean, string>): UpdateQuery<T, Returning>;
whereCurrentOf(cursorName: string): UpdateQuery<T, number, T extends Table<any, infer Columns> ? Columns : never>;
from(fromItem: Table<any, any>): UpdateQuery<T, Returning>;
returning<C1 extends keyof TableColumns>(column1: C1): UpdateQuery<T, GetReturning<TableColumns, C1>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns>(column1: C1, column2: C2): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns, C10 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9, column10: C10): UpdateQuery<T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9> & GetReturning<TableColumns, C10>>;
then<Result1, Result2 = never>(onFulfilled?: ((value: Returning extends number ? Returning : ResultSet<Config, UpdateQuery<Config, T, Returning>, false>[]) => Result1 | PromiseLike<Result1>) | undefined | null, onRejected?: ((reason: any) => Result2 | PromiseLike<Result2>) | undefined | null): Promise<Result1 | Result2>;
where(condition: Expression<Config, boolean, boolean, string>): UpdateQuery<Config, T, Returning>;
whereCurrentOf(cursorName: string): UpdateQuery<DbConfig, T, number, T extends Table<DbConfig, any, infer Columns> ? Columns : never>;
from(fromItem: AnyTable): UpdateQuery<Config, T, Returning>;
returning<C1 extends keyof TableColumns>(column1: C1): UpdateQuery<Config, T, GetReturning<TableColumns, C1>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns>(column1: C1, column2: C2): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9>>;
returning<C1 extends keyof TableColumns, C2 extends keyof TableColumns, C3 extends keyof TableColumns, C4 extends keyof TableColumns, C5 extends keyof TableColumns, C6 extends keyof TableColumns, C7 extends keyof TableColumns, C8 extends keyof TableColumns, C9 extends keyof TableColumns, C10 extends keyof TableColumns>(column1: C1, column2: C2, column3: C3, column4: C4, column5: C5, column6: C6, column7: C7, column8: C8, column9: C9, column10: C10): UpdateQuery<Config, T, GetReturning<TableColumns, C1> & GetReturning<TableColumns, C2> & GetReturning<TableColumns, C3> & GetReturning<TableColumns, C4> & GetReturning<TableColumns, C5> & GetReturning<TableColumns, C6> & GetReturning<TableColumns, C7> & GetReturning<TableColumns, C8> & GetReturning<TableColumns, C9> & GetReturning<TableColumns, C10>>;
}
export declare const makeUpdate: (queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => {
set(values: T extends Table<any, infer Columns> ? { [K in keyof Columns]?: (Columns[K] extends Column<any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? DataType | Expression<DataType, boolean, any> : DataType | Expression<DataType | undefined, boolean, any> | undefined : never) | undefined; } : never): UpdateQuery<T, number, T extends Table<any, infer Columns_1> ? Columns_1 : never>;
export declare const makeUpdate: <Config extends DbConfig>(queryExecutor: QueryExecutorFn) => <T extends unknown>(table: T) => {
set(values: T extends Table<Config, any, infer Columns> ? { [K in keyof Columns]?: (Columns[K] extends Column<Config, any, any, infer DataType, infer IsNotNull, any, any> ? IsNotNull extends true ? GetResultType<Config, DataType> | Expression<Config, DataType, boolean, any> | Expression<Config, GetResultType<Config, DataType>, boolean, any> : GetResultType<Config, DataType> | ("Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null") | Expression<Config, DataType, boolean, any> | Expression<Config, "Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null", boolean, any> | Expression<Config, GetResultType<Config, DataType>, boolean, any> | Expression<Config, "Null" extends keyof Config ? Config[keyof Config & "Null"] : "Null", boolean, any> : never) | undefined; } : never): UpdateQuery<Config, T, number, T extends Table<Config, any, infer Columns_1> ? Columns_1 : never>;
};

@@ -0,463 +1,465 @@

import { Expression } from './expression';
import { GetDataType, QueryExecutorFn } from './types';
import { Expression } from './expression';
import { DbConfig } from './config';
import { Query } from './query';
import { ResultSet } from './result-set';
export declare type FromItem<Q> = Q extends Query<any> ? FromItemQuery<Q> : Q extends (args: any) => infer R ? R extends Query<any> ? FromItemQuery<R> : never : never;
declare type FromItemQuery<Q, Result = Q extends Query<any> ? ResultSet<Q, true> : never> = {
[K in keyof Result]: Result[K] extends GetDataType<infer DataType, infer IsNotNull> ? Expression<DataType, IsNotNull, K extends string ? K : never> : never;
export declare type FromItem<Config extends DbConfig, Q> = Q extends Query<any> ? FromItemQuery<Config, Q> : Q extends (args: any) => infer R ? R extends Query<any> ? FromItemQuery<Config, R> : never : never;
declare type FromItemQuery<Config extends DbConfig, Q, Result = Q extends Query<any> ? ResultSet<Config, Q, true> : never> = {
[K in keyof Result]: Result[K] extends GetDataType<infer DataType, infer IsNotNull> ? Expression<Config, DataType, IsNotNull, K extends string ? K : never> : never;
};
declare type QueryFn<T> = Query<any> | ((args: T) => Query<any>);
export interface WithFn {
export interface WithFn<Config extends DbConfig> {
<N1 extends string, W1 extends QueryFn<never>, Q extends Query<any>>(name1: N1, with1: W1, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, N5 extends string, W5 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, name5: N5, with5: W5, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, N5 extends string, W5 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}>, N6 extends string, W6 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, name5: N5, with5: W5, name6: N6, with6: W6, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, N5 extends string, W5 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}>, N6 extends string, W6 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
}>, N7 extends string, W7 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, name5: N5, with5: W5, name6: N6, with6: W6, name7: N7, with7: W7, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, N5 extends string, W5 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}>, N6 extends string, W6 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
}>, N7 extends string, W7 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
}>, N8 extends string, W8 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, name5: N5, with5: W5, name6: N6, with6: W6, name7: N7, with7: W7, name8: N8, with8: W8, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
} & {
[K in N8]: FromItem<W8>;
[K in N8]: FromItem<Config, W8>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, N5 extends string, W5 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}>, N6 extends string, W6 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
}>, N7 extends string, W7 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
}>, N8 extends string, W8 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
}>, N9 extends string, W9 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
} & {
[K in N8]: FromItem<W8>;
[K in N8]: FromItem<Config, W8>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, name5: N5, with5: W5, name6: N6, with6: W6, name7: N7, with7: W7, name8: N8, with8: W8, name9: N9, with9: W9, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
} & {
[K in N8]: FromItem<W8>;
[K in N8]: FromItem<Config, W8>;
} & {
[K in N9]: FromItem<W9>;
[K in N9]: FromItem<Config, W9>;
}) => Q): Q;
<N1 extends string, W1 extends QueryFn<never>, N2 extends string, W2 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
}>, N3 extends string, W3 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
}>, N4 extends string, W4 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
}>, N5 extends string, W5 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
}>, N6 extends string, W6 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
}>, N7 extends string, W7 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
}>, N8 extends string, W8 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
}>, N9 extends string, W9 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
} & {
[K in N8]: FromItem<W8>;
[K in N8]: FromItem<Config, W8>;
}>, N10 extends string, W10 extends QueryFn<{
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
} & {
[K in N8]: FromItem<W8>;
[K in N8]: FromItem<Config, W8>;
} & {
[K in N9]: FromItem<W9>;
[K in N9]: FromItem<Config, W9>;
}>, Q extends Query<any>>(name1: N1, with1: W1, name2: N2, with2: W2, name3: N3, with3: W3, name4: N4, with4: W4, name5: N5, with5: W5, name6: N6, with6: W6, name7: N7, with7: W7, name8: N8, with8: W8, name9: N9, with9: W9, name10: N10, with10: W10, callback: (args: {
[K in N1]: FromItem<W1>;
[K in N1]: FromItem<Config, W1>;
} & {
[K in N2]: FromItem<W2>;
[K in N2]: FromItem<Config, W2>;
} & {
[K in N3]: FromItem<W3>;
[K in N3]: FromItem<Config, W3>;
} & {
[K in N4]: FromItem<W4>;
[K in N4]: FromItem<Config, W4>;
} & {
[K in N5]: FromItem<W5>;
[K in N5]: FromItem<Config, W5>;
} & {
[K in N6]: FromItem<W6>;
[K in N6]: FromItem<Config, W6>;
} & {
[K in N7]: FromItem<W7>;
[K in N7]: FromItem<Config, W7>;
} & {
[K in N8]: FromItem<W8>;
[K in N8]: FromItem<Config, W8>;
} & {
[K in N9]: FromItem<W9>;
[K in N9]: FromItem<Config, W9>;
} & {
[K in N10]: FromItem<W10>;
[K in N10]: FromItem<Config, W10>;
}) => Q): Q;
}
export declare const makeWith: (queryExecutor: QueryExecutorFn) => WithFn;
export declare const makeWith: <Config extends DbConfig>(queryExecutor: QueryExecutorFn) => WithFn<Config>;
export declare const makeWithRecursive: <Config extends DbConfig>(queryExecutor: QueryExecutorFn) => WithFn<Config>;
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.makeWith = void 0;
exports.makeWithRecursive = exports.makeWith = void 0;
const tokens_1 = require("./tokens");

@@ -9,3 +9,3 @@ const expression_1 = require("./expression");

const naming_1 = require("./naming");
const makeWith = (queryExecutor) => (...args) => {
const makeMakeWith = (initialTokens) => (queryExecutor) => (...args) => {
const queries = {};

@@ -21,3 +21,3 @@ const createWith = (withFn) => {

...query.getReturningKeys().reduce((fromItem, key) => {
fromItem[key] = new expression_1.Expression([new tokens_1.StringToken(`${naming_1.wrapQuotes(name)}.${naming_1.wrapQuotes(key)}`)], key);
fromItem[key] = new expression_1.InternalExpression([new tokens_1.StringToken(`${naming_1.wrapQuotes(name)}.${naming_1.wrapQuotes(key)}`)], key);
return fromItem;

@@ -48,3 +48,3 @@ }, {}),

return new select_1.SelectQuery(queryExecutor, [], false, [
new tokens_1.StringToken(`WITH`),
...initialTokens,
new tokens_1.SeparatorToken(`,`, tokens),

@@ -54,2 +54,3 @@ ...query.toTokens(),

};
exports.makeWith = makeWith;
exports.makeWith = makeMakeWith([new tokens_1.StringToken(`WITH`)]);
exports.makeWithRecursive = makeMakeWith([new tokens_1.StringToken(`WITH RECURSIVE`)]);
{
"name": "@ff00ff/mammoth",
"license": "MIT",
"version": "2.0.0-beta.7",
"version": "2.0.0-beta.8",
"main": "./.build/index.js",

@@ -20,11 +20,2 @@ "types": "./.build/index.d.ts",

],
"devDependencies": {
"@types/jest": "^26.0.24",
"@types/node": "^16.4.4",
"dts-jest": "^23.3.0",
"jest": "^26.6.3",
"prettier": "^2.3.2",
"ts-jest": "^26.5.6",
"typescript": "^4.3.5"
},
"scripts": {

@@ -31,0 +22,0 @@ "test": "jest",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc