prisma-ts-select 0.0.33 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1455 -263
  3. package/dist/bin.cjs +1 -1
  4. package/dist/bin.js +1 -1
  5. package/dist/chunk-47KZVQLD.js +283 -0
  6. package/dist/chunk-54D2J5AR.cjs +291 -0
  7. package/dist/extend/dialects/index.d.ts +13 -0
  8. package/dist/extend/dialects/index.js +186 -0
  9. package/dist/extend/dialects/mysql-v6.d.ts +100 -0
  10. package/dist/extend/dialects/mysql-v6.js +152 -0
  11. package/dist/extend/dialects/mysql-v7.d.ts +6 -0
  12. package/dist/extend/dialects/mysql-v7.js +138 -0
  13. package/dist/extend/dialects/mysql.d.ts +90 -0
  14. package/dist/extend/dialects/mysql.js +156 -0
  15. package/dist/extend/dialects/postgresql-v6.d.ts +97 -0
  16. package/dist/extend/dialects/postgresql-v6.js +136 -0
  17. package/dist/extend/dialects/postgresql-v7.d.ts +97 -0
  18. package/dist/extend/dialects/postgresql-v7.js +136 -0
  19. package/dist/extend/dialects/postgresql.d.ts +89 -0
  20. package/dist/extend/dialects/postgresql.js +147 -0
  21. package/dist/extend/dialects/shared.d.ts +6 -0
  22. package/dist/extend/dialects/shared.js +5 -0
  23. package/dist/extend/dialects/sqlite.d.ts +63 -0
  24. package/dist/extend/dialects/sqlite.js +138 -0
  25. package/dist/extend/dialects/types.d.ts +12 -0
  26. package/dist/extend/dialects/types.js +4 -0
  27. package/dist/extend/extend.d.ts +342 -57
  28. package/dist/extend/extend.js +813 -161
  29. package/dist/extend/sql-expr-BaKWzJ-r.d.ts +10 -0
  30. package/dist/extend/types-D84lxYVc.d.ts +5 -0
  31. package/dist/generator.cjs +1 -1
  32. package/dist/generator.js +1 -1
  33. package/package.json +52 -41
  34. package/built/extend.cjs +0 -565
  35. package/built/extend.d.cts +0 -451
  36. package/built/extend.d.ts +0 -451
  37. package/built/extend.js +0 -563
  38. package/dist/chunk-G66FOFCO.cjs +0 -195
  39. package/dist/chunk-GBXPF5FT.js +0 -187
  40. package/dist/extend/extend.cjs +0 -277
  41. package/dist/extend/extend.d.cts +0 -222
@@ -0,0 +1,90 @@
1
+ import { Dialect } from './types.js';
2
+ import { S as SQLExpr } from '../sql-expr-BaKWzJ-r.js';
3
+ import { J as JSONValue } from '../types-D84lxYVc.js';
4
+ import { Decimal } from '@prisma/client/runtime/client';
5
+ import { FilterCols, ColName } from './shared.js';
6
+
7
+ type MySQLCastTypeMap = {
8
+ SIGNED: bigint;
9
+ UNSIGNED: bigint;
10
+ DECIMAL: Decimal;
11
+ CHAR: string;
12
+ BINARY: Buffer;
13
+ DATE: Date;
14
+ DATETIME: Date;
15
+ TIME: string;
16
+ JSON: JSONValue;
17
+ FLOAT: number;
18
+ DOUBLE: number;
19
+ };
20
+ type IntervalUnit = 'MICROSECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
21
+ declare const mysqlContextFns: <TColEntries extends [string, unknown] = never, TCriteria extends object = object>(quoteFn: (ref: string) => string, condFn: (criteria: TCriteria) => string) => {
22
+ avg: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<Decimal>;
23
+ sum: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<Decimal>;
24
+ countAll: () => SQLExpr<bigint>;
25
+ count: (col: ColName<TColEntries> | "*") => SQLExpr<bigint>;
26
+ countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
27
+ length: (col: FilterCols<TColEntries, string> | SQLExpr<string>) => SQLExpr<bigint>;
28
+ groupConcat: (col: ColName<TColEntries>, sep?: string) => SQLExpr<string>;
29
+ bitAnd: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
30
+ bitOr: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
31
+ bitXor: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
32
+ stddev: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
33
+ stddevSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
34
+ variance: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
35
+ varSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
36
+ jsonArrayAgg: (col: ColName<TColEntries>) => SQLExpr<JSONValue>;
37
+ jsonObjectAgg: (key: ColName<TColEntries>, val: ColName<TColEntries>) => SQLExpr<JSONValue>;
38
+ concat: (args_0: SQLExpr<string> | FilterCols<TColEntries, string>, ...args: (SQLExpr<string> | FilterCols<TColEntries, string>)[]) => SQLExpr<string>;
39
+ substring: (col: FilterCols<TColEntries, string> | SQLExpr<string>, start: number, len?: number) => SQLExpr<string>;
40
+ left: (col: FilterCols<TColEntries, string> | SQLExpr<string>, n: number) => SQLExpr<string>;
41
+ right: (col: FilterCols<TColEntries, string> | SQLExpr<string>, n: number) => SQLExpr<string>;
42
+ repeat: (col: FilterCols<TColEntries, string> | SQLExpr<string>, n: number) => SQLExpr<string>;
43
+ reverse: (col: FilterCols<TColEntries, string> | SQLExpr<string>) => SQLExpr<string>;
44
+ lpad: (col: FilterCols<TColEntries, string> | SQLExpr<string>, len: number, pad: string) => SQLExpr<string>;
45
+ rpad: (col: FilterCols<TColEntries, string> | SQLExpr<string>, len: number, pad: string) => SQLExpr<string>;
46
+ locate: (substr: string, col: FilterCols<TColEntries, string> | SQLExpr<string>) => SQLExpr<bigint>;
47
+ space: (n: number) => SQLExpr<string>;
48
+ now: () => SQLExpr<Date>;
49
+ curDate: () => SQLExpr<Date>;
50
+ year: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<bigint>;
51
+ month: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<bigint>;
52
+ day: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<bigint>;
53
+ hour: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<bigint>;
54
+ minute: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<number>;
55
+ second: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<number>;
56
+ $if: <T>(cond: TCriteria | SQLExpr<unknown>, trueVal: SQLExpr<T>, falseVal: SQLExpr<T>) => SQLExpr<T>;
57
+ ifNull: <T>(col: FilterCols<TColEntries, T> | SQLExpr<T>, fallback: SQLExpr<NonNullable<T>>) => SQLExpr<NonNullable<T>>;
58
+ greatest: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T | null>;
59
+ least: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T | null>;
60
+ dateAdd: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>, n: number, unit: IntervalUnit) => SQLExpr<Date>;
61
+ dateSub: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>, n: number, unit: IntervalUnit) => SQLExpr<Date>;
62
+ dateFormat: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>, fmt: string) => SQLExpr<string>;
63
+ dateDiff: (d1: FilterCols<TColEntries, Date> | SQLExpr<Date>, d2: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<number>;
64
+ quarter: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<bigint>;
65
+ weekOfYear: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<number>;
66
+ dayName: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<string>;
67
+ lastDay: (col: FilterCols<TColEntries, Date> | SQLExpr<Date>) => SQLExpr<Date>;
68
+ abs: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
69
+ ceil: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
70
+ floor: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
71
+ round: (col: FilterCols<TColEntries, number> | SQLExpr<number>, decimals?: number) => SQLExpr<number>;
72
+ power: (base: FilterCols<TColEntries, number> | SQLExpr<number>, exp: number | SQLExpr<number>) => SQLExpr<number>;
73
+ sqrt: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
74
+ mod: (col: FilterCols<TColEntries, number> | SQLExpr<number>, divisor: number) => SQLExpr<bigint | number>;
75
+ sign: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
76
+ exp: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
77
+ pi: () => SQLExpr<number>;
78
+ ln: (x: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
79
+ log: (x: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
80
+ log2: (x: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
81
+ log10: (x: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
82
+ truncate: (x: FilterCols<TColEntries, number> | SQLExpr<number>, n: number) => SQLExpr<number>;
83
+ rand: (seed?: number) => SQLExpr<number>;
84
+ cast: <T extends keyof MySQLCastTypeMap>(expr: ColName<TColEntries> | SQLExpr<unknown>, type: T) => SQLExpr<MySQLCastTypeMap[T]>;
85
+ };
86
+ type DialectFns<TColEntries extends [string, unknown] = never, TCriteria extends object = object> = ReturnType<typeof mysqlContextFns<TColEntries, TCriteria>>;
87
+ declare const supportedJoinMethods: readonly ["join", "joinUnsafeTypeEnforced", "joinUnsafeIgnoreType", "innerJoin", "innerJoinUnsafeTypeEnforced", "innerJoinUnsafeIgnoreType", "leftJoin", "leftJoinUnsafeTypeEnforced", "leftJoinUnsafeIgnoreType", "rightJoin", "rightJoinUnsafeTypeEnforced", "rightJoinUnsafeIgnoreType", "crossJoin", "crossJoinUnsafeTypeEnforced", "crossJoinUnsafeIgnoreType", "manyToManyJoin"];
88
+ declare const mysqlDialect: Dialect;
89
+
90
+ export { type DialectFns, type IntervalUnit, mysqlContextFns, mysqlDialect, supportedJoinMethods };
@@ -0,0 +1,156 @@
1
+ // src/sql-expr.ts
2
+ function sqlExpr(sql) {
3
+ return { sql, toString() {
4
+ return sql;
5
+ } };
6
+ }
7
+ function resolveArg(arg, quoteFn) {
8
+ if (typeof arg !== "string") return arg.sql;
9
+ return quoteFn(arg);
10
+ }
11
+
12
+ // src/dialects/shared.ts
13
+ var esc = (s) => s.replace(/'/g, "''");
14
+
15
+ // src/dialects/mysql.ts
16
+ var MYSQL_CAST_TYPES = /* @__PURE__ */ new Set(["SIGNED", "UNSIGNED", "DECIMAL", "CHAR", "BINARY", "DATE", "DATETIME", "TIME", "JSON", "FLOAT", "DOUBLE"]);
17
+ var mysqlContextFns = (quoteFn, condFn) => ({
18
+ avg: (col) => sqlExpr(`AVG(${resolveArg(col, quoteFn)})`),
19
+ sum: (col) => sqlExpr(`SUM(${resolveArg(col, quoteFn)})`),
20
+ countAll: () => sqlExpr("COUNT(*)"),
21
+ count: (col) => sqlExpr(col === "*" ? "COUNT(*)" : `COUNT(${quoteFn(col)})`),
22
+ countDistinct: (col) => sqlExpr(`COUNT(DISTINCT ${quoteFn(col)})`),
23
+ length: (col) => sqlExpr(`LENGTH(${resolveArg(col, quoteFn)})`),
24
+ groupConcat: (col, sep) => sqlExpr(`GROUP_CONCAT(${quoteFn(col)}${sep !== void 0 ? ` SEPARATOR '${esc(sep)}'` : ""})`),
25
+ bitAnd: (col) => sqlExpr(`BIT_AND(${quoteFn(col)})`),
26
+ bitOr: (col) => sqlExpr(`BIT_OR(${quoteFn(col)})`),
27
+ bitXor: (col) => sqlExpr(`BIT_XOR(${quoteFn(col)})`),
28
+ stddev: (col) => sqlExpr(`STDDEV(${quoteFn(col)})`),
29
+ stddevSamp: (col) => sqlExpr(`STDDEV_SAMP(${quoteFn(col)})`),
30
+ variance: (col) => sqlExpr(`VARIANCE(${quoteFn(col)})`),
31
+ varSamp: (col) => sqlExpr(`VAR_SAMP(${quoteFn(col)})`),
32
+ jsonArrayAgg: (col) => sqlExpr(`JSON_ARRAYAGG(${quoteFn(col)})`),
33
+ jsonObjectAgg: (key, val) => sqlExpr(`JSON_OBJECTAGG(${quoteFn(key)}, ${quoteFn(val)})`),
34
+ concat: (...args) => {
35
+ if (args.length === 0) throw new Error("concat: requires at least one argument");
36
+ return sqlExpr(`CONCAT(${args.map((a) => resolveArg(a, quoteFn)).join(", ")})`);
37
+ },
38
+ substring: (col, start, len) => sqlExpr(`SUBSTRING(${resolveArg(col, quoteFn)}, ${start}${len !== void 0 ? `, ${len}` : ""})`),
39
+ left: (col, n) => sqlExpr(`LEFT(${resolveArg(col, quoteFn)}, ${n})`),
40
+ right: (col, n) => sqlExpr(`RIGHT(${resolveArg(col, quoteFn)}, ${n})`),
41
+ repeat: (col, n) => sqlExpr(`REPEAT(${resolveArg(col, quoteFn)}, ${n})`),
42
+ reverse: (col) => sqlExpr(`REVERSE(${resolveArg(col, quoteFn)})`),
43
+ lpad: (col, len, pad) => sqlExpr(`LPAD(${resolveArg(col, quoteFn)}, ${len}, '${esc(pad)}')`),
44
+ rpad: (col, len, pad) => sqlExpr(`RPAD(${resolveArg(col, quoteFn)}, ${len}, '${esc(pad)}')`),
45
+ locate: (substr, col) => sqlExpr(`LOCATE('${esc(substr)}', ${resolveArg(col, quoteFn)})`),
46
+ space: (n) => sqlExpr(`SPACE(${n})`),
47
+ // DateTime base fns (MySQL defaults)
48
+ now: () => sqlExpr("NOW()"),
49
+ curDate: () => sqlExpr("CURDATE()"),
50
+ year: (col) => sqlExpr(`YEAR(${resolveArg(col, quoteFn)})`),
51
+ month: (col) => sqlExpr(`MONTH(${resolveArg(col, quoteFn)})`),
52
+ day: (col) => sqlExpr(`DAY(${resolveArg(col, quoteFn)})`),
53
+ hour: (col) => sqlExpr(`HOUR(${resolveArg(col, quoteFn)})`),
54
+ minute: (col) => sqlExpr(`MINUTE(${resolveArg(col, quoteFn)})`),
55
+ second: (col) => sqlExpr(`SECOND(${resolveArg(col, quoteFn)})`),
56
+ // Control flow
57
+ $if: (cond, trueVal, falseVal) => {
58
+ const condSql = typeof cond === "object" && cond !== null && "sql" in cond ? cond.sql : condFn(cond);
59
+ return sqlExpr(`IF(${condSql}, ${trueVal.sql}, ${falseVal.sql})`);
60
+ },
61
+ ifNull: (col, fallback) => sqlExpr(`IFNULL(${resolveArg(col, quoteFn)}, ${fallback.sql})`),
62
+ // NULL-poisoned: returns NULL if any arg is NULL
63
+ greatest: (...args) => {
64
+ if (args.length === 0) throw new Error("greatest: requires at least one argument");
65
+ return sqlExpr(`GREATEST(${args.map((a) => resolveArg(a, quoteFn)).join(", ")})`);
66
+ },
67
+ // NULL-poisoned: returns NULL if any arg is NULL
68
+ least: (...args) => {
69
+ if (args.length === 0) throw new Error("least: requires at least one argument");
70
+ return sqlExpr(`LEAST(${args.map((a) => resolveArg(a, quoteFn)).join(", ")})`);
71
+ },
72
+ // DateTime fns (MySQL-only)
73
+ dateAdd: (col, n, unit) => {
74
+ if (!Number.isFinite(n)) throw new Error(`dateAdd: n must be a finite number, got ${n}`);
75
+ return sqlExpr(`DATE_ADD(${resolveArg(col, quoteFn)}, INTERVAL ${n} ${unit})`);
76
+ },
77
+ dateSub: (col, n, unit) => {
78
+ if (!Number.isFinite(n)) throw new Error(`dateSub: n must be a finite number, got ${n}`);
79
+ return sqlExpr(`DATE_SUB(${resolveArg(col, quoteFn)}, INTERVAL ${n} ${unit})`);
80
+ },
81
+ /**
82
+ * MySQL `DATE_FORMAT` returns `NULL` if the date column value is `NULL`.
83
+ * Unknown format specifiers are passed through literally, not as errors.
84
+ */
85
+ dateFormat: (col, fmt) => sqlExpr(`DATE_FORMAT(${resolveArg(col, quoteFn)}, '${esc(fmt)}')`),
86
+ dateDiff: (d1, d2) => sqlExpr(`DATEDIFF(${resolveArg(d1, quoteFn)}, ${resolveArg(d2, quoteFn)})`),
87
+ quarter: (col) => sqlExpr(`QUARTER(${resolveArg(col, quoteFn)})`),
88
+ weekOfYear: (col) => sqlExpr(`WEEKOFYEAR(${resolveArg(col, quoteFn)})`),
89
+ dayName: (col) => sqlExpr(`DAYNAME(${resolveArg(col, quoteFn)})`),
90
+ lastDay: (col) => sqlExpr(`LAST_DAY(${resolveArg(col, quoteFn)})`),
91
+ // ── Math ─────────────────────────────────────────────────────────────────
92
+ abs: (col) => sqlExpr(`ABS(${resolveArg(col, quoteFn)})`),
93
+ ceil: (col) => sqlExpr(`CEIL(${resolveArg(col, quoteFn)})`),
94
+ floor: (col) => sqlExpr(`FLOOR(${resolveArg(col, quoteFn)})`),
95
+ round: (col, decimals) => sqlExpr(decimals !== void 0 ? `ROUND(${resolveArg(col, quoteFn)}, ${decimals})` : `ROUND(${resolveArg(col, quoteFn)})`),
96
+ power: (base, exp) => sqlExpr(`POWER(${resolveArg(base, quoteFn)}, ${typeof exp === "number" ? exp : exp.sql})`),
97
+ sqrt: (col) => sqlExpr(`SQRT(${resolveArg(col, quoteFn)})`),
98
+ mod: (col, divisor) => sqlExpr(`MOD(${resolveArg(col, quoteFn)}, ${divisor})`),
99
+ sign: (col) => sqlExpr(`SIGN(${resolveArg(col, quoteFn)})`),
100
+ exp: (col) => sqlExpr(`EXP(${resolveArg(col, quoteFn)})`),
101
+ // ── Math (MySQL-specific) ─────────────────────────────────────────────────
102
+ pi: () => sqlExpr("PI()"),
103
+ ln: (x) => sqlExpr(`LN(${resolveArg(x, quoteFn)})`),
104
+ /** Natural log (ln(x)). Use `log10(x)` for base-10. Note: PG `log(x)` is base-10 — opposite semantics. */
105
+ log: (x) => sqlExpr(`LOG(${resolveArg(x, quoteFn)})`),
106
+ log2: (x) => sqlExpr(`LOG2(${resolveArg(x, quoteFn)})`),
107
+ log10: (x) => sqlExpr(`LOG10(${resolveArg(x, quoteFn)})`),
108
+ truncate: (x, n) => sqlExpr(`TRUNCATE(${resolveArg(x, quoteFn)}, ${n})`),
109
+ rand: (seed) => sqlExpr(seed !== void 0 ? `RAND(${seed})` : "RAND()"),
110
+ // ── Type coercion ────────────────────────────────────────────────────────
111
+ cast: (expr, type) => {
112
+ if (!MYSQL_CAST_TYPES.has(type)) throw new Error(`cast: invalid cast type '${String(type)}'`);
113
+ return sqlExpr(`CAST(${resolveArg(expr, quoteFn)} AS ${type})`);
114
+ }
115
+ });
116
+ var supportedJoinMethods = [
117
+ "join",
118
+ "joinUnsafeTypeEnforced",
119
+ "joinUnsafeIgnoreType",
120
+ "innerJoin",
121
+ "innerJoinUnsafeTypeEnforced",
122
+ "innerJoinUnsafeIgnoreType",
123
+ "leftJoin",
124
+ "leftJoinUnsafeTypeEnforced",
125
+ "leftJoinUnsafeIgnoreType",
126
+ "rightJoin",
127
+ "rightJoinUnsafeTypeEnforced",
128
+ "rightJoinUnsafeIgnoreType",
129
+ "crossJoin",
130
+ "crossJoinUnsafeTypeEnforced",
131
+ "crossJoinUnsafeIgnoreType",
132
+ "manyToManyJoin"
133
+ ];
134
+ var mysqlDialect = {
135
+ name: "mysql",
136
+ needsBooleanCoercion: () => true,
137
+ quote: (id, _isAlias) => `\`${id}\``,
138
+ quoteTableIdentifier: (name, _isAlias) => `\`${name}\``,
139
+ quoteQualifiedColumn: (ref) => {
140
+ if (!ref.includes(".")) return `\`${ref}\``;
141
+ const [table, col] = ref.split(".", 2);
142
+ return `\`${table}\`.\`${col}\``;
143
+ },
144
+ quoteOrderByClause: (clause) => {
145
+ const parts = clause.trim().split(/\s+/);
146
+ const colRef = parts[0] ?? "";
147
+ const suffix = parts.slice(1).join(" ");
148
+ const quoted = colRef.includes(".") ? (() => {
149
+ const [table, col] = colRef.split(".", 2);
150
+ return `\`${table}\`.\`${col}\``;
151
+ })() : `\`${colRef}\``;
152
+ return suffix ? `${quoted} ${suffix}` : quoted;
153
+ }
154
+ };
155
+
156
+ export { mysqlContextFns, mysqlDialect, supportedJoinMethods };
@@ -0,0 +1,97 @@
1
+ import { PgExtractField, PgDateTruncUnit } from './postgresql.js';
2
+ export { postgresqlDialect } from './postgresql.js';
3
+ import { J as JSONValue } from '../types-D84lxYVc.js';
4
+ import { Decimal } from '@prisma/client/runtime/client';
5
+ import { S as SQLExpr } from '../sql-expr-BaKWzJ-r.js';
6
+ import { ColName, FilterCols } from './shared.js';
7
+ import './types.js';
8
+
9
+ declare const postgresqlV6ContextFns: <TColEntries extends [string, unknown] = never>(quoteFn: (ref: string) => string) => {
10
+ countAll: () => SQLExpr<bigint>;
11
+ count: (col: ColName<TColEntries> | "*") => SQLExpr<bigint>;
12
+ countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
13
+ ceil: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
14
+ floor: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
15
+ avg: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
16
+ sum: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
17
+ length: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<number>;
18
+ stringAgg: (col: ColName<TColEntries>, sep: string) => SQLExpr<string>;
19
+ arrayAgg: (col: ColName<TColEntries>) => SQLExpr<unknown[]>;
20
+ stddevPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
21
+ stddevSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
22
+ varPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
23
+ varSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
24
+ boolAnd: (col: FilterCols<TColEntries, boolean>) => SQLExpr<boolean>;
25
+ boolOr: (col: FilterCols<TColEntries, boolean>) => SQLExpr<boolean>;
26
+ jsonAgg: (col: ColName<TColEntries>) => SQLExpr<JSONValue[]>;
27
+ bitAnd: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
28
+ bitOr: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
29
+ jsonObjectAgg: (key: ColName<TColEntries>, val: ColName<TColEntries>) => SQLExpr<JSONValue>;
30
+ concat: (args_0: SQLExpr<string> | FilterCols<TColEntries, string>, ...args: (SQLExpr<string> | FilterCols<TColEntries, string>)[]) => SQLExpr<string>;
31
+ substring: (col: SQLExpr<string> | FilterCols<TColEntries, string>, start: number, len?: number) => SQLExpr<string>;
32
+ left: (col: SQLExpr<string> | FilterCols<TColEntries, string>, n: number) => SQLExpr<string>;
33
+ right: (col: SQLExpr<string> | FilterCols<TColEntries, string>, n: number) => SQLExpr<string>;
34
+ repeat: (col: SQLExpr<string> | FilterCols<TColEntries, string>, n: number) => SQLExpr<string>;
35
+ reverse: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<string>;
36
+ lpad: (col: SQLExpr<string> | FilterCols<TColEntries, string>, len: number, pad: string) => SQLExpr<string>;
37
+ rpad: (col: SQLExpr<string> | FilterCols<TColEntries, string>, len: number, pad: string) => SQLExpr<string>;
38
+ initcap: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<string>;
39
+ strpos: (col: SQLExpr<string> | FilterCols<TColEntries, string>, substr: string) => SQLExpr<number>;
40
+ splitPart: (col: SQLExpr<string> | FilterCols<TColEntries, string>, delimiter: string, field: number) => SQLExpr<string>;
41
+ btrim: (col: SQLExpr<string> | FilterCols<TColEntries, string>, chars?: string) => SQLExpr<string>;
42
+ md5: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<string>;
43
+ greatest: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T>;
44
+ least: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T>;
45
+ now: () => SQLExpr<Date>;
46
+ curDate: () => SQLExpr<Date>;
47
+ year: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
48
+ month: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
49
+ day: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
50
+ hour: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
51
+ minute: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
52
+ second: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
53
+ extract: (field: PgExtractField, col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
54
+ dateTrunc: (unit: PgDateTruncUnit, col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<Date>;
55
+ age: (ts1: SQLExpr<Date> | FilterCols<TColEntries, Date>, ts2?: SQLExpr<Date> | FilterCols<TColEntries, Date> | undefined) => SQLExpr<string>;
56
+ toDate: (text: SQLExpr<string> | FilterCols<TColEntries, string>, fmt: string) => SQLExpr<Date>;
57
+ abs: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
58
+ round: (col: SQLExpr<number> | FilterCols<TColEntries, number>, decimals?: number) => SQLExpr<number>;
59
+ power: (base: SQLExpr<number> | FilterCols<TColEntries, number>, exp: number | SQLExpr<number>) => SQLExpr<number>;
60
+ sqrt: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
61
+ mod: (col: SQLExpr<number> | FilterCols<TColEntries, number>, divisor: number) => SQLExpr<number>;
62
+ sign: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
63
+ exp: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
64
+ pi: () => SQLExpr<number>;
65
+ ln: (x: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
66
+ log: (x: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
67
+ logBase: (base: number, x: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
68
+ trunc: (x: SQLExpr<number> | FilterCols<TColEntries, number>, n?: number) => SQLExpr<number>;
69
+ div: (x: SQLExpr<number> | FilterCols<TColEntries, number>, y: number) => SQLExpr<number>;
70
+ random: () => SQLExpr<number>;
71
+ cast: <T extends keyof {
72
+ INTEGER: number;
73
+ TEXT: string;
74
+ BIGINT: bigint;
75
+ BOOLEAN: boolean;
76
+ REAL: number;
77
+ NUMERIC: number;
78
+ DATE: Date;
79
+ TIMESTAMP: Date;
80
+ JSON: JSONValue;
81
+ JSONB: JSONValue;
82
+ }>(expr: SQLExpr<unknown> | ColName<TColEntries>, type: T) => SQLExpr<{
83
+ INTEGER: number;
84
+ TEXT: string;
85
+ BIGINT: bigint;
86
+ BOOLEAN: boolean;
87
+ REAL: number;
88
+ NUMERIC: number;
89
+ DATE: Date;
90
+ TIMESTAMP: Date;
91
+ JSON: JSONValue;
92
+ JSONB: JSONValue;
93
+ }[T]>;
94
+ };
95
+ type DialectFns<TColEntries extends [string, unknown] = never, _TCriteria extends object = object> = ReturnType<typeof postgresqlV6ContextFns<TColEntries>>;
96
+
97
+ export { type DialectFns, PgDateTruncUnit, PgExtractField, postgresqlV6ContextFns };
@@ -0,0 +1,136 @@
1
+ // src/sql-expr.ts
2
+ function sqlExpr(sql) {
3
+ return { sql, toString() {
4
+ return sql;
5
+ } };
6
+ }
7
+ function resolveArg(arg, quoteFn) {
8
+ if (typeof arg !== "string") return arg.sql;
9
+ return quoteFn(arg);
10
+ }
11
+
12
+ // src/dialects/shared.ts
13
+ var esc = (s) => s.replace(/'/g, "''");
14
+
15
+ // src/dialects/postgresql.ts
16
+ var PG_CAST_TYPES = /* @__PURE__ */ new Set(["INTEGER", "TEXT", "BIGINT", "BOOLEAN", "REAL", "NUMERIC", "DATE", "TIMESTAMP", "JSON", "JSONB"]);
17
+ var postgresqlContextFns = (quoteFn) => ({
18
+ avg: (col) => sqlExpr(`AVG(${resolveArg(col, quoteFn)})`),
19
+ sum: (col) => sqlExpr(`SUM(${resolveArg(col, quoteFn)})`),
20
+ countAll: () => sqlExpr("COUNT(*)"),
21
+ count: (col) => sqlExpr(col === "*" ? "COUNT(*)" : `COUNT(${quoteFn(col)})`),
22
+ countDistinct: (col) => sqlExpr(`COUNT(DISTINCT ${quoteFn(col)})`),
23
+ length: (col) => sqlExpr(`LENGTH(${resolveArg(col, quoteFn)})`),
24
+ stringAgg: (col, sep) => sqlExpr(`STRING_AGG(${quoteFn(col)}, '${esc(sep)}')`),
25
+ arrayAgg: (col) => sqlExpr(`ARRAY_AGG(${quoteFn(col)})`),
26
+ stddevPop: (col) => sqlExpr(`STDDEV_POP(${quoteFn(col)})`),
27
+ stddevSamp: (col) => sqlExpr(`STDDEV_SAMP(${quoteFn(col)})`),
28
+ varPop: (col) => sqlExpr(`VAR_POP(${quoteFn(col)})`),
29
+ varSamp: (col) => sqlExpr(`VAR_SAMP(${quoteFn(col)})`),
30
+ boolAnd: (col) => sqlExpr(`BOOL_AND(${quoteFn(col)})`),
31
+ boolOr: (col) => sqlExpr(`BOOL_OR(${quoteFn(col)})`),
32
+ jsonAgg: (col) => sqlExpr(`JSON_AGG(${quoteFn(col)})`),
33
+ bitAnd: (col) => sqlExpr(`BIT_AND(${quoteFn(col)})`),
34
+ bitOr: (col) => sqlExpr(`BIT_OR(${quoteFn(col)})`),
35
+ jsonObjectAgg: (key, val) => sqlExpr(`JSON_OBJECT_AGG(${quoteFn(key)}, ${quoteFn(val)})`),
36
+ concat: (...args) => {
37
+ if (args.length === 0) throw new Error("concat: requires at least one argument");
38
+ return sqlExpr(`CONCAT(${args.map((a) => resolveArg(a, quoteFn)).join(", ")})`);
39
+ },
40
+ substring: (col, start, len) => sqlExpr(`SUBSTRING(${resolveArg(col, quoteFn)}, ${start}${len !== void 0 ? `, ${len}` : ""})`),
41
+ left: (col, n) => sqlExpr(`LEFT(${resolveArg(col, quoteFn)}, ${n})`),
42
+ right: (col, n) => sqlExpr(`RIGHT(${resolveArg(col, quoteFn)}, ${n})`),
43
+ repeat: (col, n) => sqlExpr(`REPEAT(${resolveArg(col, quoteFn)}, ${n})`),
44
+ reverse: (col) => sqlExpr(`REVERSE(${resolveArg(col, quoteFn)})`),
45
+ lpad: (col, len, pad) => sqlExpr(`LPAD(${resolveArg(col, quoteFn)}, ${len}, '${esc(pad)}')`),
46
+ rpad: (col, len, pad) => sqlExpr(`RPAD(${resolveArg(col, quoteFn)}, ${len}, '${esc(pad)}')`),
47
+ initcap: (col) => sqlExpr(`INITCAP(${resolveArg(col, quoteFn)})`),
48
+ strpos: (col, substr) => sqlExpr(`STRPOS(${resolveArg(col, quoteFn)}, '${esc(substr)}')`),
49
+ splitPart: (col, delimiter, field) => sqlExpr(`SPLIT_PART(${resolveArg(col, quoteFn)}, '${esc(delimiter)}', ${field})`),
50
+ btrim: (col, chars) => sqlExpr(`BTRIM(${resolveArg(col, quoteFn)}${chars !== void 0 ? `, '${esc(chars)}'` : ""})`),
51
+ md5: (col) => sqlExpr(`MD5(${resolveArg(col, quoteFn)})`),
52
+ // Control flow
53
+ greatest: (...args) => {
54
+ if (args.length === 0) throw new Error("greatest: requires at least one argument");
55
+ return sqlExpr(`GREATEST(${args.map((a) => resolveArg(a, quoteFn)).join(", ")})`);
56
+ },
57
+ least: (...args) => {
58
+ if (args.length === 0) throw new Error("least: requires at least one argument");
59
+ return sqlExpr(`LEAST(${args.map((a) => resolveArg(a, quoteFn)).join(", ")})`);
60
+ },
61
+ // DateTime overrides
62
+ now: () => sqlExpr("NOW()"),
63
+ curDate: () => sqlExpr("CURRENT_DATE"),
64
+ year: (col) => sqlExpr(`EXTRACT(YEAR FROM ${resolveArg(col, quoteFn)})::integer`),
65
+ month: (col) => sqlExpr(`EXTRACT(MONTH FROM ${resolveArg(col, quoteFn)})::integer`),
66
+ day: (col) => sqlExpr(`EXTRACT(DAY FROM ${resolveArg(col, quoteFn)})::integer`),
67
+ hour: (col) => sqlExpr(`EXTRACT(HOUR FROM ${resolveArg(col, quoteFn)})::integer`),
68
+ minute: (col) => sqlExpr(`EXTRACT(MINUTE FROM ${resolveArg(col, quoteFn)})::integer`),
69
+ second: (col) => sqlExpr(`EXTRACT(SECOND FROM ${resolveArg(col, quoteFn)})::integer`),
70
+ // PG-only DateTime fns
71
+ extract: (field, col) => sqlExpr(`EXTRACT(${field} FROM ${resolveArg(col, quoteFn)})`),
72
+ dateTrunc: (unit, col) => sqlExpr(`DATE_TRUNC('${unit}', ${resolveArg(col, quoteFn)})`),
73
+ /**
74
+ * PG `AGE()` returns an `interval`. Typed as `string` since node-postgres serializes
75
+ * intervals as strings (e.g. `"1 year 2 mons 3 days"`). Arithmetic on the result
76
+ * must be done in SQL, not JS — use `sqlExpr` to compose further expressions.
77
+ */
78
+ age: (ts1, ts2) => sqlExpr(ts2 !== void 0 ? `AGE(${resolveArg(ts1, quoteFn)}, ${resolveArg(ts2, quoteFn)})` : `AGE(${resolveArg(ts1, quoteFn)})`),
79
+ toDate: (text, fmt) => sqlExpr(`TO_DATE(${resolveArg(text, quoteFn)}, '${esc(fmt)}')`),
80
+ // ── Math ─────────────────────────────────────────────────────────────────
81
+ abs: (col) => sqlExpr(`ABS(${resolveArg(col, quoteFn)})`),
82
+ ceil: (col) => sqlExpr(`CEIL(${resolveArg(col, quoteFn)})`),
83
+ floor: (col) => sqlExpr(`FLOOR(${resolveArg(col, quoteFn)})`),
84
+ round: (col, decimals) => sqlExpr(decimals !== void 0 ? `ROUND(${resolveArg(col, quoteFn)}, ${decimals})` : `ROUND(${resolveArg(col, quoteFn)})`),
85
+ power: (base, exp) => sqlExpr(`POWER(${resolveArg(base, quoteFn)}, ${typeof exp === "number" ? exp : exp.sql})`),
86
+ sqrt: (col) => sqlExpr(`SQRT(${resolveArg(col, quoteFn)})`),
87
+ mod: (col, divisor) => sqlExpr(`MOD(${resolveArg(col, quoteFn)}, ${divisor})`),
88
+ sign: (col) => sqlExpr(`SIGN(${resolveArg(col, quoteFn)})`),
89
+ exp: (col) => sqlExpr(`EXP(${resolveArg(col, quoteFn)})`),
90
+ // ── Math (PostgreSQL-specific) ────────────────────────────────────────────
91
+ pi: () => sqlExpr("PI()"),
92
+ ln: (x) => sqlExpr(`LN(${resolveArg(x, quoteFn)})`),
93
+ log: (x) => sqlExpr(`LOG(${resolveArg(x, quoteFn)})`),
94
+ logBase: (base, x) => sqlExpr(`LOG(${base}, ${resolveArg(x, quoteFn)})`),
95
+ trunc: (x, n) => sqlExpr(n !== void 0 ? `TRUNC(${resolveArg(x, quoteFn)}, ${n})` : `TRUNC(${resolveArg(x, quoteFn)})`),
96
+ div: (x, y) => sqlExpr(`DIV(${resolveArg(x, quoteFn)}, ${y})`),
97
+ random: () => sqlExpr("RANDOM()"),
98
+ // ── Type coercion ────────────────────────────────────────────────────────
99
+ cast: (expr, type) => {
100
+ if (!PG_CAST_TYPES.has(type)) throw new Error(`cast: invalid cast type '${String(type)}'`);
101
+ return sqlExpr(`CAST(${resolveArg(expr, quoteFn)} AS ${type})`);
102
+ }
103
+ });
104
+ var postgresqlDialect = {
105
+ name: "postgresql",
106
+ needsBooleanCoercion: () => false,
107
+ quote: (id, _isAlias) => `"${id}"`,
108
+ quoteTableIdentifier: (name, _isAlias) => `"${name}"`,
109
+ quoteQualifiedColumn: (ref) => {
110
+ if (!ref.includes(".")) return `"${ref}"`;
111
+ const [table, col] = ref.split(".", 2);
112
+ return `"${table}"."${col}"`;
113
+ },
114
+ quoteOrderByClause: (clause) => {
115
+ const parts = clause.trim().split(/\s+/);
116
+ const colRef = parts[0] ?? "";
117
+ const suffix = parts.slice(1).join(" ");
118
+ const quoted = colRef.includes(".") ? (() => {
119
+ const [table, col] = colRef.split(".", 2);
120
+ return `"${table}"."${col}"`;
121
+ })() : `"${colRef}"`;
122
+ return suffix ? `${quoted} ${suffix}` : quoted;
123
+ }
124
+ };
125
+
126
+ // src/dialects/postgresql-v6.ts
127
+ var postgresqlV6ContextFns = (quoteFn) => ({
128
+ ...postgresqlContextFns(quoteFn),
129
+ countAll: () => sqlExpr("COUNT(*)"),
130
+ count: (col) => sqlExpr(col === "*" ? "COUNT(*)" : `COUNT(${quoteFn(col)})`),
131
+ countDistinct: (col) => sqlExpr(`COUNT(DISTINCT ${quoteFn(col)})`),
132
+ ceil: (col) => sqlExpr(`CEIL(${resolveArg(col, quoteFn)})`),
133
+ floor: (col) => sqlExpr(`FLOOR(${resolveArg(col, quoteFn)})`)
134
+ });
135
+
136
+ export { postgresqlDialect, postgresqlV6ContextFns };
@@ -0,0 +1,97 @@
1
+ import { PgExtractField, PgDateTruncUnit } from './postgresql.js';
2
+ export { postgresqlDialect } from './postgresql.js';
3
+ import { J as JSONValue } from '../types-D84lxYVc.js';
4
+ import { Decimal } from '@prisma/client/runtime/client';
5
+ import { S as SQLExpr } from '../sql-expr-BaKWzJ-r.js';
6
+ import { ColName, FilterCols } from './shared.js';
7
+ import './types.js';
8
+
9
+ declare const postgresqlV7ContextFns: <TColEntries extends [string, unknown] = never>(quoteFn: (ref: string) => string) => {
10
+ countAll: () => SQLExpr<bigint>;
11
+ count: (col: ColName<TColEntries> | "*") => SQLExpr<bigint>;
12
+ countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
13
+ ceil: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
14
+ floor: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
15
+ avg: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
16
+ sum: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
17
+ length: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<number>;
18
+ stringAgg: (col: ColName<TColEntries>, sep: string) => SQLExpr<string>;
19
+ arrayAgg: (col: ColName<TColEntries>) => SQLExpr<unknown[]>;
20
+ stddevPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
21
+ stddevSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
22
+ varPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
23
+ varSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
24
+ boolAnd: (col: FilterCols<TColEntries, boolean>) => SQLExpr<boolean>;
25
+ boolOr: (col: FilterCols<TColEntries, boolean>) => SQLExpr<boolean>;
26
+ jsonAgg: (col: ColName<TColEntries>) => SQLExpr<JSONValue[]>;
27
+ bitAnd: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
28
+ bitOr: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
29
+ jsonObjectAgg: (key: ColName<TColEntries>, val: ColName<TColEntries>) => SQLExpr<JSONValue>;
30
+ concat: (args_0: SQLExpr<string> | FilterCols<TColEntries, string>, ...args: (SQLExpr<string> | FilterCols<TColEntries, string>)[]) => SQLExpr<string>;
31
+ substring: (col: SQLExpr<string> | FilterCols<TColEntries, string>, start: number, len?: number) => SQLExpr<string>;
32
+ left: (col: SQLExpr<string> | FilterCols<TColEntries, string>, n: number) => SQLExpr<string>;
33
+ right: (col: SQLExpr<string> | FilterCols<TColEntries, string>, n: number) => SQLExpr<string>;
34
+ repeat: (col: SQLExpr<string> | FilterCols<TColEntries, string>, n: number) => SQLExpr<string>;
35
+ reverse: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<string>;
36
+ lpad: (col: SQLExpr<string> | FilterCols<TColEntries, string>, len: number, pad: string) => SQLExpr<string>;
37
+ rpad: (col: SQLExpr<string> | FilterCols<TColEntries, string>, len: number, pad: string) => SQLExpr<string>;
38
+ initcap: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<string>;
39
+ strpos: (col: SQLExpr<string> | FilterCols<TColEntries, string>, substr: string) => SQLExpr<number>;
40
+ splitPart: (col: SQLExpr<string> | FilterCols<TColEntries, string>, delimiter: string, field: number) => SQLExpr<string>;
41
+ btrim: (col: SQLExpr<string> | FilterCols<TColEntries, string>, chars?: string) => SQLExpr<string>;
42
+ md5: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<string>;
43
+ greatest: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T>;
44
+ least: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T>;
45
+ now: () => SQLExpr<Date>;
46
+ curDate: () => SQLExpr<Date>;
47
+ year: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
48
+ month: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
49
+ day: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
50
+ hour: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
51
+ minute: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
52
+ second: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
53
+ extract: (field: PgExtractField, col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
54
+ dateTrunc: (unit: PgDateTruncUnit, col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<Date>;
55
+ age: (ts1: SQLExpr<Date> | FilterCols<TColEntries, Date>, ts2?: SQLExpr<Date> | FilterCols<TColEntries, Date> | undefined) => SQLExpr<string>;
56
+ toDate: (text: SQLExpr<string> | FilterCols<TColEntries, string>, fmt: string) => SQLExpr<Date>;
57
+ abs: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
58
+ round: (col: SQLExpr<number> | FilterCols<TColEntries, number>, decimals?: number) => SQLExpr<number>;
59
+ power: (base: SQLExpr<number> | FilterCols<TColEntries, number>, exp: number | SQLExpr<number>) => SQLExpr<number>;
60
+ sqrt: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
61
+ mod: (col: SQLExpr<number> | FilterCols<TColEntries, number>, divisor: number) => SQLExpr<number>;
62
+ sign: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
63
+ exp: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
64
+ pi: () => SQLExpr<number>;
65
+ ln: (x: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
66
+ log: (x: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
67
+ logBase: (base: number, x: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
68
+ trunc: (x: SQLExpr<number> | FilterCols<TColEntries, number>, n?: number) => SQLExpr<number>;
69
+ div: (x: SQLExpr<number> | FilterCols<TColEntries, number>, y: number) => SQLExpr<number>;
70
+ random: () => SQLExpr<number>;
71
+ cast: <T extends keyof {
72
+ INTEGER: number;
73
+ TEXT: string;
74
+ BIGINT: bigint;
75
+ BOOLEAN: boolean;
76
+ REAL: number;
77
+ NUMERIC: number;
78
+ DATE: Date;
79
+ TIMESTAMP: Date;
80
+ JSON: JSONValue;
81
+ JSONB: JSONValue;
82
+ }>(expr: SQLExpr<unknown> | ColName<TColEntries>, type: T) => SQLExpr<{
83
+ INTEGER: number;
84
+ TEXT: string;
85
+ BIGINT: bigint;
86
+ BOOLEAN: boolean;
87
+ REAL: number;
88
+ NUMERIC: number;
89
+ DATE: Date;
90
+ TIMESTAMP: Date;
91
+ JSON: JSONValue;
92
+ JSONB: JSONValue;
93
+ }[T]>;
94
+ };
95
+ type DialectFns<TColEntries extends [string, unknown] = never, _TCriteria extends object = object> = ReturnType<typeof postgresqlV7ContextFns<TColEntries>>;
96
+
97
+ export { type DialectFns, PgDateTruncUnit, PgExtractField, postgresqlV7ContextFns };