prisma-ts-select 0.1.7 → 0.1.8
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.
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/assets/groupBy.gif +0 -0
- package/assets/joinUnsafeIgnoreType.gif +0 -0
- package/assets/joinUnsafeTypeEnforced.gif +0 -0
- package/assets/typesafe-join.gif +0 -0
- package/assets/typesafe-join.png +0 -0
- package/assets/whereIsNull.gif +0 -0
- package/assets/whereNotNull.gif +0 -0
- package/dist/bin.js +0 -0
- package/dist/extend/dialects/index.js +11 -11
- package/dist/extend/dialects/mysql-v6.d.ts +9 -7
- package/dist/extend/dialects/mysql-v6.js +5 -5
- package/dist/extend/dialects/mysql-v7.js +4 -4
- package/dist/extend/dialects/mysql.d.ts +7 -5
- package/dist/extend/dialects/mysql.js +4 -4
- package/dist/extend/dialects/postgresql-v6.d.ts +8 -6
- package/dist/extend/dialects/postgresql-v6.js +5 -5
- package/dist/extend/dialects/postgresql-v7.d.ts +8 -6
- package/dist/extend/dialects/postgresql-v7.js +5 -5
- package/dist/extend/dialects/postgresql.d.ts +7 -5
- package/dist/extend/dialects/postgresql.js +4 -4
- package/dist/extend/dialects/sqlite.d.ts +7 -7
- package/dist/extend/dialects/sqlite.js +3 -3
- package/dist/extend/extend.d.ts +96 -20
- package/dist/extend/extend.js +38 -30
- package/package.json +26 -26
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Adrian Elton-Browning
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
File without changes
|
package/assets/groupBy.gif
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/assets/typesafe-join.gif
CHANGED
|
File without changes
|
package/assets/typesafe-join.png
CHANGED
|
File without changes
|
package/assets/whereIsNull.gif
CHANGED
|
File without changes
|
package/assets/whereNotNull.gif
CHANGED
|
File without changes
|
package/dist/bin.js
CHANGED
|
File without changes
|
|
@@ -48,7 +48,7 @@ var sqliteContextFns = (quoteFn, condFn) => ({
|
|
|
48
48
|
if (isDistinct(col) && sep !== void 0) {
|
|
49
49
|
throw new Error("SQLite does not support GROUP_CONCAT(DISTINCT col, sep) \u2014 omit the separator.");
|
|
50
50
|
}
|
|
51
|
-
return sqlExpr(`GROUP_CONCAT(${inner}${sep !== void 0 ? `, '${sep
|
|
51
|
+
return sqlExpr(`GROUP_CONCAT(${inner}${sep !== void 0 ? `, '${esc(sep)}'` : ""})`);
|
|
52
52
|
},
|
|
53
53
|
total: (col) => sqlExpr(`TOTAL(${quoteFn(col)})`),
|
|
54
54
|
// SQLite MIN/MAX return bigint for integer columns — override base (number) return types
|
|
@@ -123,11 +123,11 @@ var sqliteDialect = {
|
|
|
123
123
|
name: "sqlite",
|
|
124
124
|
needsBooleanCoercion: () => true,
|
|
125
125
|
quote: (name, _isAlias) => {
|
|
126
|
-
if (_isAlias) return "`" + name + "`";
|
|
126
|
+
if (_isAlias) return "`" + name.replace(/`/g, "``") + "`";
|
|
127
127
|
return name;
|
|
128
128
|
},
|
|
129
129
|
quoteTableIdentifier: (name, _isAlias) => {
|
|
130
|
-
if (_isAlias) return "`" + name + "`";
|
|
130
|
+
if (_isAlias) return "`" + name.replace(/`/g, "``") + "`";
|
|
131
131
|
return name;
|
|
132
132
|
},
|
|
133
133
|
quoteQualifiedColumn: (ref) => {
|
|
@@ -151,12 +151,12 @@ var sqliteDialect = {
|
|
|
151
151
|
var mysqlDialect = {
|
|
152
152
|
name: "mysql",
|
|
153
153
|
needsBooleanCoercion: () => true,
|
|
154
|
-
quote: (id, _isAlias) => `\`${id}\``,
|
|
155
|
-
quoteTableIdentifier: (name, _isAlias) => `\`${name}\``,
|
|
154
|
+
quote: (id, _isAlias) => `\`${id.replace(/`/g, "``")}\``,
|
|
155
|
+
quoteTableIdentifier: (name, _isAlias) => `\`${name.replace(/`/g, "``")}\``,
|
|
156
156
|
quoteQualifiedColumn: (ref) => {
|
|
157
|
-
if (!ref.includes(".")) return `\`${ref}\``;
|
|
157
|
+
if (!ref.includes(".")) return `\`${ref.replace(/`/g, "``")}\``;
|
|
158
158
|
const [table, col] = ref.split(".", 2);
|
|
159
|
-
return `\`${table}\`.\`${col}\``;
|
|
159
|
+
return `\`${table.replace(/`/g, "``")}\`.\`${col.replace(/`/g, "``")}\``;
|
|
160
160
|
},
|
|
161
161
|
quoteOrderByClause: (clause) => {
|
|
162
162
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -174,12 +174,12 @@ var mysqlDialect = {
|
|
|
174
174
|
var postgresqlDialect = {
|
|
175
175
|
name: "postgresql",
|
|
176
176
|
needsBooleanCoercion: () => false,
|
|
177
|
-
quote: (id, _isAlias) => `"${id}"`,
|
|
178
|
-
quoteTableIdentifier: (name, _isAlias) => `"${name}"`,
|
|
177
|
+
quote: (id, _isAlias) => `"${id.replace(/"/g, '""')}"`,
|
|
178
|
+
quoteTableIdentifier: (name, _isAlias) => `"${name.replace(/"/g, '""')}"`,
|
|
179
179
|
quoteQualifiedColumn: (ref) => {
|
|
180
|
-
if (!ref.includes(".")) return `"${ref}"`;
|
|
180
|
+
if (!ref.includes(".")) return `"${ref.replace(/"/g, '""')}"`;
|
|
181
181
|
const [table, col] = ref.split(".", 2);
|
|
182
|
-
return `"${table}"."${col}"`;
|
|
182
|
+
return `"${table.replace(/"/g, '""')}"."${col.replace(/"/g, '""')}"`;
|
|
183
183
|
},
|
|
184
184
|
quoteOrderByClause: (clause) => {
|
|
185
185
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IntervalUnit } from './mysql.js';
|
|
2
2
|
export { mysqlDialect } from './mysql.js';
|
|
3
3
|
import { J as JSONValue, a as JSONObject } from '../types-B0F8m0ok.js';
|
|
4
|
-
import { S as SQLExpr, a as SQLDistinct } from '../sql-expr-BGSEwzCi.js';
|
|
4
|
+
import { S as SQLExpr, a as SQLDistinct, D as DISTINCT_BRAND } from '../sql-expr-BGSEwzCi.js';
|
|
5
5
|
import { ColName, FilterCols, ColTypeOf, FilterJsonCols } from './shared.js';
|
|
6
6
|
import * as _prisma_client_runtime_client from '@prisma/client/runtime/client';
|
|
7
7
|
import './types.js';
|
|
@@ -16,10 +16,12 @@ declare const mysqlV6ContextFns: <TColEntries extends [string, unknown] = never,
|
|
|
16
16
|
floor: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
|
|
17
17
|
mod: (col: FilterCols<TColEntries, number> | SQLExpr<number>, divisor: number) => SQLExpr<bigint | number>;
|
|
18
18
|
sign: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
|
|
19
|
-
avg: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<_prisma_client_runtime_client.Decimal>;
|
|
20
|
-
sum: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<_prisma_client_runtime_client.Decimal>;
|
|
21
|
-
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<
|
|
22
|
-
groupConcat: (col: SQLExpr<
|
|
19
|
+
avg: (col: SQLExpr<number | null> | FilterCols<TColEntries, number>) => SQLExpr<_prisma_client_runtime_client.Decimal>;
|
|
20
|
+
sum: (col: SQLExpr<number | null> | FilterCols<TColEntries, number>) => SQLExpr<_prisma_client_runtime_client.Decimal>;
|
|
21
|
+
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<ColTypeOf<TColEntries, Col>>;
|
|
22
|
+
groupConcat: (<T extends string | null>(col: SQLDistinct<T>, sep?: string) => SQLExpr<T>) & (<Col extends ColName<TColEntries>>(col: Col, sep?: string) => SQLExpr<null extends ColTypeOf<TColEntries, Col> ? string | (ColTypeOf<TColEntries, Col> & null) : string>) & (<T extends string | null>(col: SQLExpr<T> & {
|
|
23
|
+
readonly [DISTINCT_BRAND]?: never;
|
|
24
|
+
}, sep?: string) => SQLExpr<T>);
|
|
23
25
|
bitAnd: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
24
26
|
bitOr: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
25
27
|
bitXor: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
@@ -47,7 +49,7 @@ declare const mysqlV6ContextFns: <TColEntries extends [string, unknown] = never,
|
|
|
47
49
|
hour: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<bigint>;
|
|
48
50
|
minute: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
|
|
49
51
|
second: (col: SQLExpr<Date> | FilterCols<TColEntries, Date>) => SQLExpr<number>;
|
|
50
|
-
$if: <T>(cond: SQLExpr<unknown
|
|
52
|
+
$if: <T>(cond: TCriteria | SQLExpr<unknown>, trueVal: SQLExpr<T>, falseVal: SQLExpr<T>) => SQLExpr<T>;
|
|
51
53
|
ifNull: <T>(col: FilterCols<TColEntries, T> | SQLExpr<T>, fallback: SQLExpr<NonNullable<T>>) => SQLExpr<NonNullable<T>>;
|
|
52
54
|
greatest: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T | null>;
|
|
53
55
|
least: <T>(args_0: FilterCols<TColEntries, T> | SQLExpr<T>, ...args: (FilterCols<TColEntries, T> | SQLExpr<T>)[]) => SQLExpr<T | null>;
|
|
@@ -101,4 +103,4 @@ declare const mysqlV6ContextFns: <TColEntries extends [string, unknown] = never,
|
|
|
101
103
|
};
|
|
102
104
|
type DialectFns<TColEntries extends [string, unknown] = never, TCriteria extends object = object> = ReturnType<typeof mysqlV6ContextFns<TColEntries, TCriteria>>;
|
|
103
105
|
|
|
104
|
-
export { type DialectFns, IntervalUnit, mysqlV6ContextFns };
|
|
106
|
+
export { DISTINCT_BRAND, type DialectFns, IntervalUnit, mysqlV6ContextFns };
|
|
@@ -128,12 +128,12 @@ var mysqlContextFns = (quoteFn, condFn) => ({
|
|
|
128
128
|
var mysqlDialect = {
|
|
129
129
|
name: "mysql",
|
|
130
130
|
needsBooleanCoercion: () => true,
|
|
131
|
-
quote: (id, _isAlias) => `\`${id}\``,
|
|
132
|
-
quoteTableIdentifier: (name, _isAlias) => `\`${name}\``,
|
|
131
|
+
quote: (id, _isAlias) => `\`${id.replace(/`/g, "``")}\``,
|
|
132
|
+
quoteTableIdentifier: (name, _isAlias) => `\`${name.replace(/`/g, "``")}\``,
|
|
133
133
|
quoteQualifiedColumn: (ref) => {
|
|
134
|
-
if (!ref.includes(".")) return `\`${ref}\``;
|
|
134
|
+
if (!ref.includes(".")) return `\`${ref.replace(/`/g, "``")}\``;
|
|
135
135
|
const [table, col] = ref.split(".", 2);
|
|
136
|
-
return `\`${table}\`.\`${col}\``;
|
|
136
|
+
return `\`${table.replace(/`/g, "``")}\`.\`${col.replace(/`/g, "``")}\``;
|
|
137
137
|
},
|
|
138
138
|
quoteOrderByClause: (clause) => {
|
|
139
139
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -161,4 +161,4 @@ var mysqlV6ContextFns = (quoteFn, condFn) => ({
|
|
|
161
161
|
sign: (col) => sqlExpr(`SIGN(${resolveArg(col, quoteFn)})`)
|
|
162
162
|
});
|
|
163
163
|
|
|
164
|
-
export { mysqlDialect, mysqlV6ContextFns };
|
|
164
|
+
export { DISTINCT_BRAND, mysqlDialect, mysqlV6ContextFns };
|
|
@@ -128,12 +128,12 @@ var mysqlContextFns = (quoteFn, condFn) => ({
|
|
|
128
128
|
var mysqlDialect = {
|
|
129
129
|
name: "mysql",
|
|
130
130
|
needsBooleanCoercion: () => true,
|
|
131
|
-
quote: (id, _isAlias) => `\`${id}\``,
|
|
132
|
-
quoteTableIdentifier: (name, _isAlias) => `\`${name}\``,
|
|
131
|
+
quote: (id, _isAlias) => `\`${id.replace(/`/g, "``")}\``,
|
|
132
|
+
quoteTableIdentifier: (name, _isAlias) => `\`${name.replace(/`/g, "``")}\``,
|
|
133
133
|
quoteQualifiedColumn: (ref) => {
|
|
134
|
-
if (!ref.includes(".")) return `\`${ref}\``;
|
|
134
|
+
if (!ref.includes(".")) return `\`${ref.replace(/`/g, "``")}\``;
|
|
135
135
|
const [table, col] = ref.split(".", 2);
|
|
136
|
-
return `\`${table}\`.\`${col}\``;
|
|
136
|
+
return `\`${table.replace(/`/g, "``")}\`.\`${col.replace(/`/g, "``")}\``;
|
|
137
137
|
},
|
|
138
138
|
quoteOrderByClause: (clause) => {
|
|
139
139
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialect } from './types.js';
|
|
2
|
-
import { S as SQLExpr, a as SQLDistinct } from '../sql-expr-BGSEwzCi.js';
|
|
2
|
+
import { S as SQLExpr, a as SQLDistinct, D as DISTINCT_BRAND } from '../sql-expr-BGSEwzCi.js';
|
|
3
3
|
import { J as JSONValue, a as JSONObject } from '../types-B0F8m0ok.js';
|
|
4
4
|
import { Decimal } from '@prisma/client/runtime/client';
|
|
5
5
|
import { FilterCols, ColName, ColTypeOf, FilterJsonCols } from './shared.js';
|
|
@@ -19,14 +19,16 @@ type MySQLCastTypeMap = {
|
|
|
19
19
|
};
|
|
20
20
|
type IntervalUnit = 'MICROSECOND' | 'SECOND' | 'MINUTE' | 'HOUR' | 'DAY' | 'WEEK' | 'MONTH' | 'QUARTER' | 'YEAR';
|
|
21
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>;
|
|
22
|
+
avg: (col: FilterCols<TColEntries, number> | SQLExpr<number | null>) => SQLExpr<Decimal>;
|
|
23
|
+
sum: (col: FilterCols<TColEntries, number> | SQLExpr<number | null>) => SQLExpr<Decimal>;
|
|
24
24
|
countAll: () => SQLExpr<bigint>;
|
|
25
25
|
count: (col: ColName<TColEntries> | "*" | SQLExpr<unknown>) => SQLExpr<bigint>;
|
|
26
26
|
countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
|
|
27
|
-
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<
|
|
27
|
+
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<ColTypeOf<TColEntries, Col>>;
|
|
28
28
|
length: (col: FilterCols<TColEntries, string> | SQLExpr<string>) => SQLExpr<bigint>;
|
|
29
|
-
groupConcat: (col:
|
|
29
|
+
groupConcat: ((<T extends string | null>(col: SQLDistinct<T>, sep?: string) => SQLExpr<T>) & (<Col extends ColName<TColEntries>>(col: Col, sep?: string) => SQLExpr<null extends ColTypeOf<TColEntries, Col> ? string | null : string>) & (<T extends string | null>(col: SQLExpr<T> & {
|
|
30
|
+
readonly [DISTINCT_BRAND]?: never;
|
|
31
|
+
}, sep?: string) => SQLExpr<T>));
|
|
30
32
|
bitAnd: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
31
33
|
bitOr: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
32
34
|
bitXor: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
@@ -146,12 +146,12 @@ var supportedJoinMethods = [
|
|
|
146
146
|
var mysqlDialect = {
|
|
147
147
|
name: "mysql",
|
|
148
148
|
needsBooleanCoercion: () => true,
|
|
149
|
-
quote: (id, _isAlias) => `\`${id}\``,
|
|
150
|
-
quoteTableIdentifier: (name, _isAlias) => `\`${name}\``,
|
|
149
|
+
quote: (id, _isAlias) => `\`${id.replace(/`/g, "``")}\``,
|
|
150
|
+
quoteTableIdentifier: (name, _isAlias) => `\`${name.replace(/`/g, "``")}\``,
|
|
151
151
|
quoteQualifiedColumn: (ref) => {
|
|
152
|
-
if (!ref.includes(".")) return `\`${ref}\``;
|
|
152
|
+
if (!ref.includes(".")) return `\`${ref.replace(/`/g, "``")}\``;
|
|
153
153
|
const [table, col] = ref.split(".", 2);
|
|
154
|
-
return `\`${table}\`.\`${col}\``;
|
|
154
|
+
return `\`${table.replace(/`/g, "``")}\`.\`${col.replace(/`/g, "``")}\``;
|
|
155
155
|
},
|
|
156
156
|
quoteOrderByClause: (clause) => {
|
|
157
157
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -3,7 +3,7 @@ import { Decimal } from '@prisma/client/runtime/client';
|
|
|
3
3
|
import { PgExtractField, PgDateTruncUnit } from './postgresql.js';
|
|
4
4
|
export { postgresqlDialect } from './postgresql.js';
|
|
5
5
|
import { J as JSONValue, a as JSONObject } from '../types-B0F8m0ok.js';
|
|
6
|
-
import { S as SQLExpr, a as SQLDistinct } from '../sql-expr-BGSEwzCi.js';
|
|
6
|
+
import { S as SQLExpr, a as SQLDistinct, D as DISTINCT_BRAND } from '../sql-expr-BGSEwzCi.js';
|
|
7
7
|
import { ColName, FilterCols, ColTypeOf, FilterJsonCols } from './shared.js';
|
|
8
8
|
import './types.js';
|
|
9
9
|
|
|
@@ -13,11 +13,13 @@ declare const postgresqlV6ContextFns: <TColEntries extends [string, unknown] = n
|
|
|
13
13
|
countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
|
|
14
14
|
ceil: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
|
|
15
15
|
floor: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
|
|
16
|
-
avg: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
17
|
-
sum: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
18
|
-
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<
|
|
16
|
+
avg: (col: SQLExpr<number | null> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
17
|
+
sum: (col: SQLExpr<number | null> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
18
|
+
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<ColTypeOf<TColEntries, Col>>;
|
|
19
19
|
length: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<number>;
|
|
20
|
-
stringAgg: (col: SQLExpr<
|
|
20
|
+
stringAgg: (<T extends string | null>(col: SQLDistinct<T>, sep: string) => SQLExpr<T>) & (<Col extends ColName<TColEntries>>(col: Col, sep: string) => SQLExpr<null extends ColTypeOf<TColEntries, Col> ? string | (ColTypeOf<TColEntries, Col> & null) : string>) & (<T extends string | null>(col: SQLExpr<T> & {
|
|
21
|
+
readonly [DISTINCT_BRAND]?: never;
|
|
22
|
+
}, sep: string) => SQLExpr<T>);
|
|
21
23
|
arrayAgg: (col: SQLExpr<unknown> | ColName<TColEntries>) => SQLExpr<unknown[]>;
|
|
22
24
|
stddevPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
23
25
|
stddevSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
@@ -99,4 +101,4 @@ declare const postgresqlV6ContextFns: <TColEntries extends [string, unknown] = n
|
|
|
99
101
|
};
|
|
100
102
|
type DialectFns<TColEntries extends [string, unknown] = never, _TCriteria extends object = object> = ReturnType<typeof postgresqlV6ContextFns<TColEntries>>;
|
|
101
103
|
|
|
102
|
-
export { type DialectFns, PgDateTruncUnit, PgExtractField, postgresqlV6ContextFns };
|
|
104
|
+
export { DISTINCT_BRAND, type DialectFns, PgDateTruncUnit, PgExtractField, postgresqlV6ContextFns };
|
|
@@ -122,12 +122,12 @@ var postgresqlContextFns = (quoteFn) => ({
|
|
|
122
122
|
var postgresqlDialect = {
|
|
123
123
|
name: "postgresql",
|
|
124
124
|
needsBooleanCoercion: () => false,
|
|
125
|
-
quote: (id, _isAlias) => `"${id}"`,
|
|
126
|
-
quoteTableIdentifier: (name, _isAlias) => `"${name}"`,
|
|
125
|
+
quote: (id, _isAlias) => `"${id.replace(/"/g, '""')}"`,
|
|
126
|
+
quoteTableIdentifier: (name, _isAlias) => `"${name.replace(/"/g, '""')}"`,
|
|
127
127
|
quoteQualifiedColumn: (ref) => {
|
|
128
|
-
if (!ref.includes(".")) return `"${ref}"`;
|
|
128
|
+
if (!ref.includes(".")) return `"${ref.replace(/"/g, '""')}"`;
|
|
129
129
|
const [table, col] = ref.split(".", 2);
|
|
130
|
-
return `"${table}"."${col}"`;
|
|
130
|
+
return `"${table.replace(/"/g, '""')}"."${col.replace(/"/g, '""')}"`;
|
|
131
131
|
},
|
|
132
132
|
quoteOrderByClause: (clause) => {
|
|
133
133
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -151,4 +151,4 @@ var postgresqlV6ContextFns = (quoteFn) => ({
|
|
|
151
151
|
floor: (col) => sqlExpr(`FLOOR(${resolveArg(col, quoteFn)})`)
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
export { postgresqlDialect, postgresqlV6ContextFns };
|
|
154
|
+
export { DISTINCT_BRAND, postgresqlDialect, postgresqlV6ContextFns };
|
|
@@ -3,7 +3,7 @@ import { Decimal } from '@prisma/client/runtime/client';
|
|
|
3
3
|
import { PgExtractField, PgDateTruncUnit } from './postgresql.js';
|
|
4
4
|
export { postgresqlDialect } from './postgresql.js';
|
|
5
5
|
import { J as JSONValue, a as JSONObject } from '../types-B0F8m0ok.js';
|
|
6
|
-
import { S as SQLExpr, a as SQLDistinct } from '../sql-expr-BGSEwzCi.js';
|
|
6
|
+
import { S as SQLExpr, a as SQLDistinct, D as DISTINCT_BRAND } from '../sql-expr-BGSEwzCi.js';
|
|
7
7
|
import { ColName, FilterCols, ColTypeOf, FilterJsonCols } from './shared.js';
|
|
8
8
|
import './types.js';
|
|
9
9
|
|
|
@@ -13,11 +13,13 @@ declare const postgresqlV7ContextFns: <TColEntries extends [string, unknown] = n
|
|
|
13
13
|
countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
|
|
14
14
|
ceil: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
|
|
15
15
|
floor: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number | Decimal>;
|
|
16
|
-
avg: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
17
|
-
sum: (col: SQLExpr<number> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
18
|
-
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<
|
|
16
|
+
avg: (col: SQLExpr<number | null> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
17
|
+
sum: (col: SQLExpr<number | null> | FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
18
|
+
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<ColTypeOf<TColEntries, Col>>;
|
|
19
19
|
length: (col: SQLExpr<string> | FilterCols<TColEntries, string>) => SQLExpr<number>;
|
|
20
|
-
stringAgg: (col: SQLExpr<
|
|
20
|
+
stringAgg: (<T extends string | null>(col: SQLDistinct<T>, sep: string) => SQLExpr<T>) & (<Col extends ColName<TColEntries>>(col: Col, sep: string) => SQLExpr<null extends ColTypeOf<TColEntries, Col> ? string | (ColTypeOf<TColEntries, Col> & null) : string>) & (<T extends string | null>(col: SQLExpr<T> & {
|
|
21
|
+
readonly [DISTINCT_BRAND]?: never;
|
|
22
|
+
}, sep: string) => SQLExpr<T>);
|
|
21
23
|
arrayAgg: (col: SQLExpr<unknown> | ColName<TColEntries>) => SQLExpr<unknown[]>;
|
|
22
24
|
stddevPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
23
25
|
stddevSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
@@ -99,4 +101,4 @@ declare const postgresqlV7ContextFns: <TColEntries extends [string, unknown] = n
|
|
|
99
101
|
};
|
|
100
102
|
type DialectFns<TColEntries extends [string, unknown] = never, _TCriteria extends object = object> = ReturnType<typeof postgresqlV7ContextFns<TColEntries>>;
|
|
101
103
|
|
|
102
|
-
export { type DialectFns, PgDateTruncUnit, PgExtractField, postgresqlV7ContextFns };
|
|
104
|
+
export { DISTINCT_BRAND, type DialectFns, PgDateTruncUnit, PgExtractField, postgresqlV7ContextFns };
|
|
@@ -122,12 +122,12 @@ var postgresqlContextFns = (quoteFn) => ({
|
|
|
122
122
|
var postgresqlDialect = {
|
|
123
123
|
name: "postgresql",
|
|
124
124
|
needsBooleanCoercion: () => false,
|
|
125
|
-
quote: (id, _isAlias) => `"${id}"`,
|
|
126
|
-
quoteTableIdentifier: (name, _isAlias) => `"${name}"`,
|
|
125
|
+
quote: (id, _isAlias) => `"${id.replace(/"/g, '""')}"`,
|
|
126
|
+
quoteTableIdentifier: (name, _isAlias) => `"${name.replace(/"/g, '""')}"`,
|
|
127
127
|
quoteQualifiedColumn: (ref) => {
|
|
128
|
-
if (!ref.includes(".")) return `"${ref}"`;
|
|
128
|
+
if (!ref.includes(".")) return `"${ref.replace(/"/g, '""')}"`;
|
|
129
129
|
const [table, col] = ref.split(".", 2);
|
|
130
|
-
return `"${table}"."${col}"`;
|
|
130
|
+
return `"${table.replace(/"/g, '""')}"."${col.replace(/"/g, '""')}"`;
|
|
131
131
|
},
|
|
132
132
|
quoteOrderByClause: (clause) => {
|
|
133
133
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -151,4 +151,4 @@ var postgresqlV7ContextFns = (quoteFn) => ({
|
|
|
151
151
|
floor: (col) => sqlExpr(`FLOOR(${resolveArg(col, quoteFn)})`)
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
export { postgresqlDialect, postgresqlV7ContextFns };
|
|
154
|
+
export { DISTINCT_BRAND, postgresqlDialect, postgresqlV7ContextFns };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dialect } from './types.js';
|
|
2
|
-
import { S as SQLExpr, a as SQLDistinct } from '../sql-expr-BGSEwzCi.js';
|
|
2
|
+
import { S as SQLExpr, a as SQLDistinct, D as DISTINCT_BRAND } from '../sql-expr-BGSEwzCi.js';
|
|
3
3
|
import { J as JSONValue, a as JSONObject } from '../types-B0F8m0ok.js';
|
|
4
4
|
import { FilterCols, ColName, ColTypeOf, FilterJsonCols } from './shared.js';
|
|
5
5
|
import '@prisma/client/runtime/client';
|
|
@@ -19,14 +19,16 @@ type PgCastTypeMap = {
|
|
|
19
19
|
type PgExtractField = 'YEAR' | 'MONTH' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'DOW' | 'DOY' | 'EPOCH' | 'WEEK' | 'QUARTER';
|
|
20
20
|
type PgDateTruncUnit = 'microseconds' | 'milliseconds' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'decade' | 'century' | 'millennium';
|
|
21
21
|
declare const postgresqlContextFns: <TColEntries extends [string, unknown] = never>(quoteFn: (ref: string) => string) => {
|
|
22
|
-
avg: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
|
|
23
|
-
sum: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
|
|
22
|
+
avg: (col: FilterCols<TColEntries, number> | SQLExpr<number | null>) => SQLExpr<number>;
|
|
23
|
+
sum: (col: FilterCols<TColEntries, number> | SQLExpr<number | null>) => SQLExpr<number>;
|
|
24
24
|
countAll: () => SQLExpr<number>;
|
|
25
25
|
count: (col: ColName<TColEntries> | "*" | SQLExpr<unknown>) => SQLExpr<number>;
|
|
26
26
|
countDistinct: (col: ColName<TColEntries>) => SQLExpr<number>;
|
|
27
|
-
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<
|
|
27
|
+
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<ColTypeOf<TColEntries, Col>>;
|
|
28
28
|
length: (col: FilterCols<TColEntries, string> | SQLExpr<string>) => SQLExpr<number>;
|
|
29
|
-
stringAgg: (col: ColName<TColEntries
|
|
29
|
+
stringAgg: ((<T extends string | null>(col: SQLDistinct<T>, sep: string) => SQLExpr<T>) & (<Col extends ColName<TColEntries>>(col: Col, sep: string) => SQLExpr<null extends ColTypeOf<TColEntries, Col> ? string | null : string>) & (<T extends string | null>(col: SQLExpr<T> & {
|
|
30
|
+
readonly [DISTINCT_BRAND]?: never;
|
|
31
|
+
}, sep: string) => SQLExpr<T>));
|
|
30
32
|
arrayAgg: (col: ColName<TColEntries> | SQLExpr<unknown>) => SQLExpr<unknown[]>;
|
|
31
33
|
stddevPop: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
32
34
|
stddevSamp: (col: FilterCols<TColEntries, number>) => SQLExpr<number>;
|
|
@@ -143,12 +143,12 @@ var supportedJoinMethods = [
|
|
|
143
143
|
var postgresqlDialect = {
|
|
144
144
|
name: "postgresql",
|
|
145
145
|
needsBooleanCoercion: () => false,
|
|
146
|
-
quote: (id, _isAlias) => `"${id}"`,
|
|
147
|
-
quoteTableIdentifier: (name, _isAlias) => `"${name}"`,
|
|
146
|
+
quote: (id, _isAlias) => `"${id.replace(/"/g, '""')}"`,
|
|
147
|
+
quoteTableIdentifier: (name, _isAlias) => `"${name.replace(/"/g, '""')}"`,
|
|
148
148
|
quoteQualifiedColumn: (ref) => {
|
|
149
|
-
if (!ref.includes(".")) return `"${ref}"`;
|
|
149
|
+
if (!ref.includes(".")) return `"${ref.replace(/"/g, '""')}"`;
|
|
150
150
|
const [table, col] = ref.split(".", 2);
|
|
151
|
-
return `"${table}"."${col}"`;
|
|
151
|
+
return `"${table.replace(/"/g, '""')}"."${col.replace(/"/g, '""')}"`;
|
|
152
152
|
},
|
|
153
153
|
quoteOrderByClause: (clause) => {
|
|
154
154
|
const parts = clause.trim().split(/\s+/);
|
|
@@ -13,20 +13,20 @@ type SqliteCastTypeMap = {
|
|
|
13
13
|
BLOB: Buffer;
|
|
14
14
|
};
|
|
15
15
|
declare const sqliteContextFns: <TColEntries extends [string, unknown] = never, TCriteria extends object = object>(quoteFn: (ref: string) => string, condFn: (criteria: TCriteria) => string) => {
|
|
16
|
-
avg: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
|
|
17
|
-
sum: (col: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<bigint | number>;
|
|
16
|
+
avg: (col: FilterCols<TColEntries, number> | SQLExpr<number | null>) => SQLExpr<number>;
|
|
17
|
+
sum: (col: FilterCols<TColEntries, number> | SQLExpr<number | null>) => SQLExpr<bigint | number>;
|
|
18
18
|
countAll: () => SQLExpr<bigint>;
|
|
19
19
|
count: (col: ColName<TColEntries> | "*" | SQLExpr<unknown>) => SQLExpr<bigint>;
|
|
20
20
|
countDistinct: (col: ColName<TColEntries>) => SQLExpr<bigint>;
|
|
21
|
-
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<
|
|
21
|
+
distinct: <Col extends ColName<TColEntries>>(col: Col) => SQLDistinct<ColTypeOf<TColEntries, Col>>;
|
|
22
22
|
length: (col: FilterCols<TColEntries, string> | SQLExpr<string>) => SQLExpr<bigint>;
|
|
23
|
-
groupConcat: (((col: SQLDistinct<
|
|
23
|
+
groupConcat: ((<T extends string | null>(col: SQLDistinct<T>) => SQLExpr<T>) & (<Col extends ColName<TColEntries>>(col: Col, sep?: string) => SQLExpr<null extends ColTypeOf<TColEntries, Col> ? string | null : string>) & (<T extends string | null>(col: SQLExpr<T> & {
|
|
24
24
|
readonly [DISTINCT_BRAND]?: never;
|
|
25
|
-
}
|
|
25
|
+
}, sep?: string) => SQLExpr<T>));
|
|
26
26
|
total: (col: ColName<TColEntries>) => SQLExpr<number>;
|
|
27
27
|
min: <Col extends ColName<TColEntries>>(col: Col) => SQLExpr<SqliteMinMaxResult<TColEntries, Col>>;
|
|
28
28
|
max: <Col extends ColName<TColEntries>>(col: Col) => SQLExpr<SqliteMinMaxResult<TColEntries, Col>>;
|
|
29
|
-
concat: (args_0:
|
|
29
|
+
concat: (args_0: FilterCols<TColEntries, string> | SQLExpr<string>, ...args: (FilterCols<TColEntries, string> | SQLExpr<string>)[]) => SQLExpr<string>;
|
|
30
30
|
substr: (col: FilterCols<TColEntries, string> | SQLExpr<string>, start: number, len?: number) => SQLExpr<string>;
|
|
31
31
|
instr: (col: FilterCols<TColEntries, string> | SQLExpr<string>, substr: string) => SQLExpr<bigint>;
|
|
32
32
|
char: (...codes: number[]) => SQLExpr<string>;
|
|
@@ -60,7 +60,7 @@ declare const sqliteContextFns: <TColEntries extends [string, unknown] = never,
|
|
|
60
60
|
log2: (x: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
|
|
61
61
|
log10: (x: FilterCols<TColEntries, number> | SQLExpr<number>) => SQLExpr<number>;
|
|
62
62
|
jsonExtract: (col: FilterJsonCols<TColEntries> | SQLExpr<JSONValue>, path: string) => SQLExpr<JSONValue>;
|
|
63
|
-
jsonArray: (args_0:
|
|
63
|
+
jsonArray: (args_0: SQLExpr<unknown> | ColName<TColEntries>, ...args: (SQLExpr<unknown> | ColName<TColEntries>)[]) => SQLExpr<JSONValue[]>;
|
|
64
64
|
jsonObject: (pairs: [string, ColName<TColEntries> | SQLExpr<unknown>][]) => SQLExpr<JSONObject>;
|
|
65
65
|
cast: <T extends keyof SqliteCastTypeMap>(expr: ColName<TColEntries> | SQLExpr<unknown>, type: T) => SQLExpr<SqliteCastTypeMap[T]>;
|
|
66
66
|
};
|
|
@@ -45,7 +45,7 @@ var sqliteContextFns = (quoteFn, condFn) => ({
|
|
|
45
45
|
if (isDistinct(col) && sep !== void 0) {
|
|
46
46
|
throw new Error("SQLite does not support GROUP_CONCAT(DISTINCT col, sep) \u2014 omit the separator.");
|
|
47
47
|
}
|
|
48
|
-
return sqlExpr(`GROUP_CONCAT(${inner}${sep !== void 0 ? `, '${sep
|
|
48
|
+
return sqlExpr(`GROUP_CONCAT(${inner}${sep !== void 0 ? `, '${esc(sep)}'` : ""})`);
|
|
49
49
|
},
|
|
50
50
|
total: (col) => sqlExpr(`TOTAL(${quoteFn(col)})`),
|
|
51
51
|
// SQLite MIN/MAX return bigint for integer columns — override base (number) return types
|
|
@@ -135,11 +135,11 @@ var sqliteDialect = {
|
|
|
135
135
|
name: "sqlite",
|
|
136
136
|
needsBooleanCoercion: () => true,
|
|
137
137
|
quote: (name, _isAlias) => {
|
|
138
|
-
if (_isAlias) return "`" + name + "`";
|
|
138
|
+
if (_isAlias) return "`" + name.replace(/`/g, "``") + "`";
|
|
139
139
|
return name;
|
|
140
140
|
},
|
|
141
141
|
quoteTableIdentifier: (name, _isAlias) => {
|
|
142
|
-
if (_isAlias) return "`" + name + "`";
|
|
142
|
+
if (_isAlias) return "`" + name.replace(/`/g, "``") + "`";
|
|
143
143
|
return name;
|
|
144
144
|
},
|
|
145
145
|
quoteQualifiedColumn: (ref) => {
|
package/dist/extend/extend.d.ts
CHANGED
|
@@ -237,7 +237,7 @@ type WhereCriteriaMulti<T extends TArrSources, TFields extends TFieldsType, F =
|
|
|
237
237
|
type WhereCriteria<T extends TArrSources, TFields extends TFieldsType> = T['length'] extends 1 ? T[0] extends TVirtualTableSource ? WhereCriteriaMulti<T, TFields> : WhereCriteriaSingle<TFields[GetAliasTableNames<T[0]>]> : WhereCriteriaMulti<T, TFields>;
|
|
238
238
|
type JoinWhereCriteria<Table extends string, TAlias extends string | never> = [
|
|
239
239
|
TAlias
|
|
240
|
-
] extends [never] ? WhereCriteriaMulti<[Table], Record<Table, GetFieldsFromTable<Table>>> : WhereCriteriaMulti<[[Table, TAlias]], Record<
|
|
240
|
+
] extends [never] ? WhereCriteriaMulti<[Table], Record<Table, GetFieldsFromTable<Table>>> : WhereCriteriaMulti<[[Table, TAlias]], Record<Table, GetFieldsFromTable<Table>>>;
|
|
241
241
|
type WhereCriteria_Fields<T extends Array<TTableSources>, TFields extends TFieldsType, acc = {}> = T extends readonly [infer HEAD, ...infer Rest] ? HEAD extends string ? Rest extends Array<TTableSources> ? WhereCriteria_Fields<Rest, TFields, OptionalObject<acc & (TableFieldType<HEAD, TFields[HEAD]> | SQLCondition<TableFieldType<HEAD, TFields[HEAD]>>)>> : WhereCriteria_Fields<[], TFields, OptionalObject<acc & (TableFieldType<HEAD, TFields[HEAD]> | SQLCondition<TableFieldType<HEAD, TFields[HEAD]>>)>> : HEAD extends readonly ["__cte__", infer CTE_NAME extends string] ? Rest extends Array<TTableSources> ? WhereCriteria_Fields<Rest, TFields, OptionalObject<acc & (TableFieldType<CTE_NAME, TFields[CTE_NAME]> | SQLCondition<TableFieldType<CTE_NAME, TFields[CTE_NAME]>>)>> : WhereCriteria_Fields<[], TFields, OptionalObject<acc & (TableFieldType<CTE_NAME, TFields[CTE_NAME]> | SQLCondition<TableFieldType<CTE_NAME, TFields[CTE_NAME]>>)>> : HEAD extends [infer R_NAME extends string, infer A_NAME extends string] ? Rest extends Array<TTableSources> ? WhereCriteria_Fields<Rest, TFields, OptionalObject<acc & (TableFieldType<A_NAME, TFields[R_NAME]> | SQLCondition<TableFieldType<A_NAME, TFields[R_NAME]>>)>> : WhereCriteria_Fields<[], TFields, OptionalObject<acc & (TableFieldType<A_NAME, TFields[R_NAME]> | SQLCondition<TableFieldType<A_NAME, TFields[R_NAME]>>)>> : never : acc;
|
|
242
242
|
type OnlyNull<T, R> = T extends null ? R : never;
|
|
243
243
|
type FindColsWithNull<TFields extends TFieldsType> = Prettify<{
|
|
@@ -307,6 +307,9 @@ type FieldsByTypeByTable = Prettify<{
|
|
|
307
307
|
}>;
|
|
308
308
|
type GetColumnType<Table extends TTableSources, Col1 extends keyof _db[Table extends string ? Table : `Come back to 8`]["fields"]> = RemoveNullChar<IsString<_db[Table extends string ? Table : `Come back to 9`]["fields"][Col1]>>;
|
|
309
309
|
type GetJoinOnColsType<Type extends string, TSources extends TArrSources> = GetJoinColsType<TSources[number], Type>;
|
|
310
|
+
type GetCTECols<TCTEs extends Record<string, Record<string, any>>> = {
|
|
311
|
+
[K in keyof TCTEs & string]: `${K}.${keyof TCTEs[K] & string}`;
|
|
312
|
+
}[keyof TCTEs & string];
|
|
310
313
|
type GetColsFromTableType<TDBBase extends TTableSources, Type extends string> = FieldsByTypeByTable[Loop<keyof FieldsByTypeByTable, Type>][GetRealTableNames<TDBBase>];
|
|
311
314
|
type Loop<Keys extends string, Type extends string> = Keys extends Type ? Type : never;
|
|
312
315
|
type GetJoinColsType<TDBBase extends TTableSources, Type extends string> = IterateFields<TDBBase, IsString<GetColsFromTableType<TDBBase, Type>>>;
|
|
@@ -336,7 +339,7 @@ type BaseSelectFnContext<_TSources extends TArrSources, _TFields extends TFields
|
|
|
336
339
|
ltrim: (col: GetColumnsOfType<_TSources, _TFields, string> | SQLExpr<string>) => SQLExpr<string>;
|
|
337
340
|
rtrim: (col: GetColumnsOfType<_TSources, _TFields, string> | SQLExpr<string>) => SQLExpr<string>;
|
|
338
341
|
cond: (criteria: WhereCriteria<_TSources, _TFields>) => SQLExpr<boolean>;
|
|
339
|
-
coalesce: <T>(...args: [GetColumnsOfType<_TSources, _TFields, T> | SQLExpr<T>, ...Array<GetColumnsOfType<_TSources, _TFields, T> | SQLExpr<T>>]) => SQLExpr<T
|
|
342
|
+
coalesce: <T>(...args: [GetColumnsOfType<_TSources, _TFields, T> | SQLExpr<T>, ...Array<GetColumnsOfType<_TSources, _TFields, T> | SQLExpr<T>>]) => SQLExpr<NonNullable<T>>;
|
|
340
343
|
nullif: <T>(expr1: SQLExpr<T>, expr2: SQLExpr<T>) => SQLExpr<T | null>;
|
|
341
344
|
caseWhen: <T, TElse extends SQLExpr<T> | undefined = undefined>(cases: [{
|
|
342
345
|
when: WhereCriteria<_TSources, _TFields>;
|
|
@@ -355,6 +358,7 @@ type GetJunctionTable<TSource extends TTables, TTarget extends TTables> = TSourc
|
|
|
355
358
|
type AvailableRefNames<TSource extends TTables> = TSource extends keyof M2MMap ? M2MMap[TSource][keyof M2MMap[TSource]] extends infer J ? J extends `_${infer R}` ? R : never : never : never;
|
|
356
359
|
declare class _fJoin<TSources extends TArrSources, TFields extends TFieldsType, TCTEs extends Record<string, Record<string, any>> = {}> extends _fWhere<TSources, TFields> {
|
|
357
360
|
join<const TName extends keyof TCTEs & string>(cteName: TName, local: keyof TCTEs[TName] & string, remote: GetJoinCols<TSources[number]>, opts?: {
|
|
361
|
+
where?: WhereCriteriaMulti<[readonly ["__cte__", TName]], Record<TName, TCTEs[TName]>>;
|
|
358
362
|
joinType?: JoinType;
|
|
359
363
|
}): _fJoin<[...TSources, readonly ["__cte__", TName]], TFields & Record<TName, TCTEs[TName]>, TCTEs>;
|
|
360
364
|
join<const Table extends AvailableJoins<TSources>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never, TAlias extends string = never>(options: {
|
|
@@ -370,7 +374,7 @@ declare class _fJoin<TSources extends TArrSources, TFields extends TFieldsType,
|
|
|
370
374
|
joinType?: JoinType;
|
|
371
375
|
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [never] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
372
376
|
private _joinImpl;
|
|
373
|
-
joinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>, TAlias extends string = never>(options: {
|
|
377
|
+
joinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs>, TAlias extends string = never>(options: {
|
|
374
378
|
table: Table;
|
|
375
379
|
src: TCol1;
|
|
376
380
|
on: TCol2;
|
|
@@ -378,7 +382,7 @@ declare class _fJoin<TSources extends TArrSources, TFields extends TFieldsType,
|
|
|
378
382
|
where?: JoinWhereCriteria<Table, TAlias>;
|
|
379
383
|
joinType?: JoinType;
|
|
380
384
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
381
|
-
joinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
385
|
+
joinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
382
386
|
where?: JoinWhereCriteria<Table, TAlias>;
|
|
383
387
|
joinType?: JoinType;
|
|
384
388
|
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
@@ -403,91 +407,163 @@ declare class _fJoin<TSources extends TArrSources, TFields extends TFieldsType,
|
|
|
403
407
|
TJunction,
|
|
404
408
|
[TAlias] extends [never] ? TTarget : [TTarget, TAlias]
|
|
405
409
|
], Prettify<TFields & Record<TJunction, GetFieldsFromTable<TJunction>> & Record<[TAlias] extends [never] ? TTarget : TAlias, GetFieldsFromTable<TTarget>>>>;
|
|
410
|
+
innerJoin<const TName extends keyof TCTEs & string>(cteName: TName, local: keyof TCTEs[TName] & string, remote: GetJoinCols<TSources[number]>, opts?: {
|
|
411
|
+
where?: WhereCriteriaMulti<[readonly ["__cte__", TName]], Record<TName, TCTEs[TName]>>;
|
|
412
|
+
}): _fJoin<[...TSources, readonly ["__cte__", TName]], TFields & Record<TName, TCTEs[TName]>, TCTEs>;
|
|
406
413
|
innerJoin<const Table extends AvailableJoins<TSources>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never, TAlias extends string = never>(options: {
|
|
407
414
|
table: Table;
|
|
408
415
|
src: TCol1;
|
|
409
416
|
on: find<TJoinCols, TCol1>;
|
|
410
417
|
alias?: TAlias;
|
|
418
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
419
|
+
joinType?: JoinType;
|
|
411
420
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
412
|
-
innerJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1
|
|
421
|
+
innerJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1>, options?: {
|
|
422
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
423
|
+
joinType?: JoinType;
|
|
424
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [never] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
425
|
+
leftJoin<const TName extends keyof TCTEs & string>(cteName: TName, local: keyof TCTEs[TName] & string, remote: GetJoinCols<TSources[number]>, opts?: {
|
|
426
|
+
where?: WhereCriteriaMulti<[readonly ["__cte__", TName]], Record<TName, TCTEs[TName]>>;
|
|
427
|
+
}): _fJoin<[...TSources, readonly ["__cte__", TName]], TFields & Record<TName, TCTEs[TName]>, TCTEs>;
|
|
413
428
|
leftJoin<const Table extends AvailableJoins<TSources>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never, TAlias extends string = never>(options: {
|
|
414
429
|
table: Table;
|
|
415
430
|
src: TCol1;
|
|
416
431
|
on: find<TJoinCols, TCol1>;
|
|
417
432
|
alias?: TAlias;
|
|
433
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
434
|
+
joinType?: JoinType;
|
|
418
435
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
419
|
-
leftJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1
|
|
436
|
+
leftJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1>, options?: {
|
|
437
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
438
|
+
joinType?: JoinType;
|
|
439
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [never] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
440
|
+
rightJoin<const TName extends keyof TCTEs & string>(cteName: TName, local: keyof TCTEs[TName] & string, remote: GetJoinCols<TSources[number]>, opts?: {
|
|
441
|
+
where?: WhereCriteriaMulti<[readonly ["__cte__", TName]], Record<TName, TCTEs[TName]>>;
|
|
442
|
+
}): _fJoin<[...TSources, readonly ["__cte__", TName]], TFields & Record<TName, TCTEs[TName]>, TCTEs>;
|
|
420
443
|
rightJoin<const Table extends AvailableJoins<TSources>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never, TAlias extends string = never>(options: {
|
|
421
444
|
table: Table;
|
|
422
445
|
src: TCol1;
|
|
423
446
|
on: find<TJoinCols, TCol1>;
|
|
424
447
|
alias?: TAlias;
|
|
448
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
449
|
+
joinType?: JoinType;
|
|
425
450
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
426
|
-
rightJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1
|
|
451
|
+
rightJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1>, options?: {
|
|
452
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
453
|
+
joinType?: JoinType;
|
|
454
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [never] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
455
|
+
fullJoin<const TName extends keyof TCTEs & string>(cteName: TName, local: keyof TCTEs[TName] & string, remote: GetJoinCols<TSources[number]>, opts?: {
|
|
456
|
+
where?: WhereCriteriaMulti<[readonly ["__cte__", TName]], Record<TName, TCTEs[TName]>>;
|
|
457
|
+
}): _fJoin<[...TSources, readonly ["__cte__", TName]], TFields & Record<TName, TCTEs[TName]>, TCTEs>;
|
|
427
458
|
fullJoin<const Table extends AvailableJoins<TSources>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never, TAlias extends string = never>(options: {
|
|
428
459
|
table: Table;
|
|
429
460
|
src: TCol1;
|
|
430
461
|
on: find<TJoinCols, TCol1>;
|
|
431
462
|
alias?: TAlias;
|
|
463
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
464
|
+
joinType?: JoinType;
|
|
432
465
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [undefined] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
433
|
-
fullJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1
|
|
466
|
+
fullJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>, TJoinCols extends [string, string] = ValidStringTuple<GetUnionOfRelations<MapJoinsToKnownTables<SafeJoins<Table, TSources>, TSources>>>, TCol1 extends TJoinCols[0] = never>(table: TableInput, field: TCol1, reference: find<TJoinCols, TCol1>, options?: {
|
|
467
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
468
|
+
joinType?: JoinType;
|
|
469
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [never] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
434
470
|
crossJoin<const TableInput extends `${AvailableJoins<TSources>}` | `${AvailableJoins<TSources>} ${string}`, Table extends AvailableJoins<TSources> = ExtractTableName<TableInput> & AvailableJoins<TSources>, TAlias extends string | never = ExtractAlias<TableInput>>(table: TableInput): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [never] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
435
|
-
innerJoinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>, TAlias extends string = never>(options: {
|
|
471
|
+
innerJoinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs>, TAlias extends string = never>(options: {
|
|
436
472
|
table: Table;
|
|
437
473
|
src: TCol1;
|
|
438
474
|
on: TCol2;
|
|
439
475
|
alias?: TAlias;
|
|
476
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
477
|
+
joinType?: JoinType;
|
|
440
478
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
441
|
-
innerJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2
|
|
479
|
+
innerJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
480
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
481
|
+
joinType?: JoinType;
|
|
482
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
442
483
|
innerJoinUnsafeIgnoreType<const Table extends TTables, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]>, TAlias extends string = never>(options: {
|
|
443
484
|
table: Table;
|
|
444
485
|
src: TCol1;
|
|
445
486
|
on: TCol2;
|
|
446
487
|
alias?: TAlias;
|
|
488
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
489
|
+
joinType?: JoinType;
|
|
490
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], TFields & Record<Table, GetFieldsFromTable<Table>>, TCTEs>;
|
|
491
|
+
innerJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
492
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
493
|
+
joinType?: JoinType;
|
|
447
494
|
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], TFields & Record<Table, GetFieldsFromTable<Table>>, TCTEs>;
|
|
448
|
-
|
|
449
|
-
leftJoinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>, TAlias extends string = never>(options: {
|
|
495
|
+
leftJoinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs>, TAlias extends string = never>(options: {
|
|
450
496
|
table: Table;
|
|
451
497
|
src: TCol1;
|
|
452
498
|
on: TCol2;
|
|
453
499
|
alias?: TAlias;
|
|
500
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
501
|
+
joinType?: JoinType;
|
|
454
502
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
455
|
-
leftJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2
|
|
503
|
+
leftJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
504
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
505
|
+
joinType?: JoinType;
|
|
506
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [undefined] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
456
507
|
leftJoinUnsafeIgnoreType<const Table extends TTables, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]>, TAlias extends string = never>(options: {
|
|
457
508
|
table: Table;
|
|
458
509
|
src: TCol1;
|
|
459
510
|
on: TCol2;
|
|
460
511
|
alias?: TAlias;
|
|
512
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
513
|
+
joinType?: JoinType;
|
|
461
514
|
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], TFields & Record<Table, MakeNullable<GetFieldsFromTable<Table>>>, TCTEs>;
|
|
462
|
-
leftJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2
|
|
463
|
-
|
|
515
|
+
leftJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
516
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
517
|
+
joinType?: JoinType;
|
|
518
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], TFields & Record<Table, MakeNullable<GetFieldsFromTable<Table>>>, TCTEs>;
|
|
519
|
+
rightJoinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs>, TAlias extends string = never>(options: {
|
|
464
520
|
table: Table;
|
|
465
521
|
src: TCol1;
|
|
466
522
|
on: TCol2;
|
|
467
523
|
alias?: TAlias;
|
|
524
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
525
|
+
joinType?: JoinType;
|
|
468
526
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
469
|
-
rightJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2
|
|
527
|
+
rightJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
528
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
529
|
+
joinType?: JoinType;
|
|
530
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [undefined] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
470
531
|
rightJoinUnsafeIgnoreType<const Table extends TTables, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]>, TAlias extends string = never>(options: {
|
|
471
532
|
table: Table;
|
|
472
533
|
src: TCol1;
|
|
473
534
|
on: TCol2;
|
|
474
535
|
alias?: TAlias;
|
|
536
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
537
|
+
joinType?: JoinType;
|
|
475
538
|
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], NullifyTableFields<TFields> & Record<Table, GetFieldsFromTable<Table>>, TCTEs>;
|
|
476
|
-
rightJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2
|
|
477
|
-
|
|
539
|
+
rightJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
540
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
541
|
+
joinType?: JoinType;
|
|
542
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], NullifyTableFields<TFields> & Record<Table, GetFieldsFromTable<Table>>, TCTEs>;
|
|
543
|
+
fullJoinUnsafeTypeEnforced<const Table extends TTables | `${TTables} ${string}`, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs>, TAlias extends string = never>(options: {
|
|
478
544
|
table: Table;
|
|
479
545
|
src: TCol1;
|
|
480
546
|
on: TCol2;
|
|
481
547
|
alias?: TAlias;
|
|
548
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
549
|
+
joinType?: JoinType;
|
|
482
550
|
}): _fJoinReturn<[...TSources, [TAlias] extends [undefined] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [undefined] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
483
|
-
fullJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2
|
|
551
|
+
fullJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]> | GetCTECols<TCTEs> = GetJoinOnColsType<GetColumnType<Table, TCol1>, [...TSources, Table]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
552
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
553
|
+
joinType?: JoinType;
|
|
554
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<NullifyTableFields<TFields> & Record<[TAlias] extends [undefined] ? Table : TAlias, MakeNullable<GetFieldsFromTable<Table>>>>, TCTEs>;
|
|
484
555
|
fullJoinUnsafeIgnoreType<const Table extends TTables, TCol1 extends GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]>, TAlias extends string = never>(options: {
|
|
485
556
|
table: Table;
|
|
486
557
|
src: TCol1;
|
|
487
558
|
on: TCol2;
|
|
488
559
|
alias?: TAlias;
|
|
560
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
561
|
+
joinType?: JoinType;
|
|
562
|
+
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], NullifyTableFields<TFields> & Record<Table, MakeNullable<GetFieldsFromTable<Table>>>, TCTEs>;
|
|
563
|
+
fullJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2, options?: {
|
|
564
|
+
where?: JoinWhereCriteria<Table, TAlias>;
|
|
565
|
+
joinType?: JoinType;
|
|
489
566
|
}): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], NullifyTableFields<TFields> & Record<Table, MakeNullable<GetFieldsFromTable<Table>>>, TCTEs>;
|
|
490
|
-
fullJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>, TCol1 extends GetColsBaseTable<Table> = GetColsBaseTable<Table>, TCol2 extends GetJoinCols<TSources[number]> = GetJoinCols<TSources[number]>>(table: TableInput, field: TCol1, reference: TCol2): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], NullifyTableFields<TFields> & Record<Table, MakeNullable<GetFieldsFromTable<Table>>>, TCTEs>;
|
|
491
567
|
crossJoinUnsafeTypeEnforced<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>>(table: TableInput): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [never] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
492
568
|
crossJoinUnsafeIgnoreType<const TableInput extends TTables | `${TTables} ${string}`, Table extends TTables = ExtractTableName<TableInput>, TAlias extends string | never = ExtractAlias<TableInput>>(table: TableInput): _fJoinReturn<[...TSources, [TAlias] extends [never] ? Table : [Table, TAlias]], Prettify<TFields & Record<[TAlias] extends [never] ? Table : TAlias, GetFieldsFromTable<Table>>>, TCTEs>;
|
|
493
569
|
}
|
package/dist/extend/extend.js
CHANGED
|
@@ -300,17 +300,25 @@ var DbSelect = class {
|
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
302
|
function applyCondition(quotedField, value) {
|
|
303
|
+
const sqlVal = (v2) => {
|
|
304
|
+
if (typeof v2 === "string") return `'${esc(v2)}'`;
|
|
305
|
+
if (v2 instanceof Date) return `'${v2.toISOString()}'`;
|
|
306
|
+
if (v2 === null) return "NULL";
|
|
307
|
+
if (typeof v2 === "number" || typeof v2 === "bigint" || typeof v2 === "boolean")
|
|
308
|
+
return String(v2);
|
|
309
|
+
throw new Error(`Unsupported value type in sqlVal: ${typeof v2}`);
|
|
310
|
+
};
|
|
303
311
|
if (typeof value === "object" && value !== null && !Array.isArray(value) && "op" in value) {
|
|
304
312
|
const opObj = value;
|
|
305
313
|
switch (opObj.op) {
|
|
306
314
|
case "IN":
|
|
307
315
|
case "NOT IN": {
|
|
308
|
-
const valuesList = opObj.values.map((v2) =>
|
|
316
|
+
const valuesList = opObj.values.map((v2) => sqlVal(v2)).join(", ");
|
|
309
317
|
return `${quotedField} ${opObj.op} (${valuesList})`;
|
|
310
318
|
}
|
|
311
319
|
case "BETWEEN": {
|
|
312
320
|
const [start, end] = opObj.values;
|
|
313
|
-
return `${quotedField} BETWEEN ${
|
|
321
|
+
return `${quotedField} BETWEEN ${sqlVal(start)} AND ${sqlVal(end)}`;
|
|
314
322
|
}
|
|
315
323
|
case "LIKE":
|
|
316
324
|
case "NOT LIKE":
|
|
@@ -324,7 +332,7 @@ function applyCondition(quotedField, value) {
|
|
|
324
332
|
case "<=":
|
|
325
333
|
case "!=":
|
|
326
334
|
case "=":
|
|
327
|
-
return `${quotedField} ${opObj.op} ${
|
|
335
|
+
return `${quotedField} ${opObj.op} ${sqlVal(opObj.value)}`;
|
|
328
336
|
default:
|
|
329
337
|
throw new Error(`Unsupported operation: ${opObj.op}`);
|
|
330
338
|
}
|
|
@@ -336,10 +344,10 @@ function applyCondition(quotedField, value) {
|
|
|
336
344
|
const parts = value.map((opObj) => applyCondition(quotedField, opObj));
|
|
337
345
|
return parts.length === 1 ? parts[0] : "(" + parts.join(" OR ") + ")";
|
|
338
346
|
}
|
|
339
|
-
const valuesList = value.map((v2) =>
|
|
347
|
+
const valuesList = value.map((v2) => sqlVal(v2)).join(", ");
|
|
340
348
|
return `${quotedField} IN (${valuesList})`;
|
|
341
349
|
} else {
|
|
342
|
-
return `${quotedField} = ${
|
|
350
|
+
return `${quotedField} = ${sqlVal(value)}`;
|
|
343
351
|
}
|
|
344
352
|
}
|
|
345
353
|
function processConditions(condition, formatted = false) {
|
|
@@ -533,7 +541,7 @@ var _fSelect = class __fSelect extends _fOrderBy {
|
|
|
533
541
|
}
|
|
534
542
|
return new __fSelect(this.db, {
|
|
535
543
|
...this.values,
|
|
536
|
-
selects: [...this.values.selects, `${dialect.quoteQualifiedColumn(select)} AS ${dialect.quote(select, true)}`]
|
|
544
|
+
selects: [...this.values.selects, `${dialect.quoteQualifiedColumn(select)} AS ${dialect.quote(alias ?? select, true)}`]
|
|
537
545
|
});
|
|
538
546
|
}
|
|
539
547
|
if (colName === "*") {
|
|
@@ -847,45 +855,45 @@ var _fJoin = class __fJoin extends _fWhere {
|
|
|
847
855
|
const remoteRef = `${sourceAlias}.${srcLocalCol}`;
|
|
848
856
|
return this.joinUnsafeIgnoreType(junctionTable, srcJunctionCol, remoteRef).joinUnsafeIgnoreType(safeAlias ? `${safeTbl} ${safeAlias}` : safeTbl, tgtLocalCol, `${junctionTable}.${tgtJunctionCol}`);
|
|
849
857
|
}
|
|
850
|
-
innerJoin(tableOrOptions, field, reference) {
|
|
851
|
-
return this._joinImpl("INNER", tableOrOptions, field, reference);
|
|
858
|
+
innerJoin(tableOrOptions, field, reference, opts) {
|
|
859
|
+
return this._joinImpl("INNER", tableOrOptions, field, reference, opts);
|
|
852
860
|
}
|
|
853
|
-
leftJoin(tableOrOptions, field, reference) {
|
|
854
|
-
return this._joinImpl("LEFT", tableOrOptions, field, reference);
|
|
861
|
+
leftJoin(tableOrOptions, field, reference, opts) {
|
|
862
|
+
return this._joinImpl("LEFT", tableOrOptions, field, reference, opts);
|
|
855
863
|
}
|
|
856
|
-
rightJoin(tableOrOptions, field, reference) {
|
|
857
|
-
return this._joinImpl("RIGHT", tableOrOptions, field, reference);
|
|
864
|
+
rightJoin(tableOrOptions, field, reference, opts) {
|
|
865
|
+
return this._joinImpl("RIGHT", tableOrOptions, field, reference, opts);
|
|
858
866
|
}
|
|
859
|
-
fullJoin(tableOrOptions, field, reference) {
|
|
860
|
-
return this._joinImpl("FULL", tableOrOptions, field, reference);
|
|
867
|
+
fullJoin(tableOrOptions, field, reference, opts) {
|
|
868
|
+
return this._joinImpl("FULL", tableOrOptions, field, reference, opts);
|
|
861
869
|
}
|
|
862
870
|
// crossJoin: no ON clause — table only (with optional inline alias)
|
|
863
871
|
crossJoin(table) {
|
|
864
872
|
return this._joinImpl("CROSS", table);
|
|
865
873
|
}
|
|
866
|
-
innerJoinUnsafeTypeEnforced(tableOrOptions, field, reference) {
|
|
867
|
-
return this._joinImpl("INNER", tableOrOptions, field, reference);
|
|
874
|
+
innerJoinUnsafeTypeEnforced(tableOrOptions, field, reference, opts) {
|
|
875
|
+
return this._joinImpl("INNER", tableOrOptions, field, reference, opts);
|
|
868
876
|
}
|
|
869
|
-
innerJoinUnsafeIgnoreType(tableOrOptions, field, reference) {
|
|
870
|
-
return this._joinImpl("INNER", tableOrOptions, field, reference);
|
|
877
|
+
innerJoinUnsafeIgnoreType(tableOrOptions, field, reference, opts) {
|
|
878
|
+
return this._joinImpl("INNER", tableOrOptions, field, reference, opts);
|
|
871
879
|
}
|
|
872
|
-
leftJoinUnsafeTypeEnforced(tableOrOptions, field, reference) {
|
|
873
|
-
return this._joinImpl("LEFT", tableOrOptions, field, reference);
|
|
880
|
+
leftJoinUnsafeTypeEnforced(tableOrOptions, field, reference, opts) {
|
|
881
|
+
return this._joinImpl("LEFT", tableOrOptions, field, reference, opts);
|
|
874
882
|
}
|
|
875
|
-
leftJoinUnsafeIgnoreType(tableOrOptions, field, reference) {
|
|
876
|
-
return this._joinImpl("LEFT", tableOrOptions, field, reference);
|
|
883
|
+
leftJoinUnsafeIgnoreType(tableOrOptions, field, reference, opts) {
|
|
884
|
+
return this._joinImpl("LEFT", tableOrOptions, field, reference, opts);
|
|
877
885
|
}
|
|
878
|
-
rightJoinUnsafeTypeEnforced(tableOrOptions, field, reference) {
|
|
879
|
-
return this._joinImpl("RIGHT", tableOrOptions, field, reference);
|
|
886
|
+
rightJoinUnsafeTypeEnforced(tableOrOptions, field, reference, opts) {
|
|
887
|
+
return this._joinImpl("RIGHT", tableOrOptions, field, reference, opts);
|
|
880
888
|
}
|
|
881
|
-
rightJoinUnsafeIgnoreType(tableOrOptions, field, reference) {
|
|
882
|
-
return this._joinImpl("RIGHT", tableOrOptions, field, reference);
|
|
889
|
+
rightJoinUnsafeIgnoreType(tableOrOptions, field, reference, opts) {
|
|
890
|
+
return this._joinImpl("RIGHT", tableOrOptions, field, reference, opts);
|
|
883
891
|
}
|
|
884
|
-
fullJoinUnsafeTypeEnforced(tableOrOptions, field, reference) {
|
|
885
|
-
return this._joinImpl("FULL", tableOrOptions, field, reference);
|
|
892
|
+
fullJoinUnsafeTypeEnforced(tableOrOptions, field, reference, opts) {
|
|
893
|
+
return this._joinImpl("FULL", tableOrOptions, field, reference, opts);
|
|
886
894
|
}
|
|
887
|
-
fullJoinUnsafeIgnoreType(tableOrOptions, field, reference) {
|
|
888
|
-
return this._joinImpl("FULL", tableOrOptions, field, reference);
|
|
895
|
+
fullJoinUnsafeIgnoreType(tableOrOptions, field, reference, opts) {
|
|
896
|
+
return this._joinImpl("FULL", tableOrOptions, field, reference, opts);
|
|
889
897
|
}
|
|
890
898
|
// crossJoinUnsafeTypeEnforced — CROSS semantics, type-enforced columns
|
|
891
899
|
crossJoinUnsafeTypeEnforced(table) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prisma-ts-select",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"prisma-ts-select": "dist/bin.cjs"
|
|
@@ -28,30 +28,6 @@
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"bp": "pnpm build && pnpm version patch && pnpm pack",
|
|
33
|
-
"build": "pnpm exec rimraf dist && tsup",
|
|
34
|
-
"reset": "rm -rf prisma/migrations/ && prisma migrate dev --name init && prisma generate",
|
|
35
|
-
"start": "tsx src/index.ts",
|
|
36
|
-
"prisma-upgrade": "pnpm i --save-dev prisma@latest && pnpm i @prisma/client@latest",
|
|
37
|
-
"lint:ts": "tsc --noEmit -p tsconfig.json",
|
|
38
|
-
"lint:tsw": "pnpm tsc -w",
|
|
39
|
-
"lint": "tsc --noEmit ; eslint \"scripts/**/*.{j,t}s{,x}\" --cache --max-warnings=0",
|
|
40
|
-
"lint:s": "eslint --config .eslintrc.style.json \"scripts/**/*.{j,t}s{,x}\" --cache --max-warnings=0",
|
|
41
|
-
"lint:fix": "eslint --config .eslintrc.style.json \"scripts/**/*.{j,t}s{,x}\" --cache --max-warnings=0 --fix",
|
|
42
|
-
"p:gen": "pnpm exec prisma generate",
|
|
43
|
-
"p:dbp": "pnpm exec prisma db push",
|
|
44
|
-
"p:migrate": "pnpm exec prisma migrate dev",
|
|
45
|
-
"p:update": "pnpm add -D prisma@latest && pnpm add @prisma/client@latest",
|
|
46
|
-
"test": "node --test tests/**/*.spec.ts",
|
|
47
|
-
"test:jest": "jest",
|
|
48
|
-
"2postinstall": "node src/scripts/postinstall.js",
|
|
49
|
-
"doc": "pnpm exec markdown-toc -i README.md",
|
|
50
|
-
"mdcode-ts": "pnpm exec mdcode",
|
|
51
|
-
"readme:extract": "pnpm mdcode extract README.md",
|
|
52
|
-
"readme:update": "pnpm mdcode update --transform ./transforms/readme-sql-clean.ts README.md",
|
|
53
|
-
"readme:test": "pnpm --filter usage-sqlite-v7 test -- tests/readme"
|
|
54
|
-
},
|
|
55
31
|
"dependencies": {
|
|
56
32
|
"@prisma/generator-helper": "^6.0.0",
|
|
57
33
|
"@prisma/internals": "^6.0.0",
|
|
@@ -175,5 +151,29 @@
|
|
|
175
151
|
"publishConfig": {
|
|
176
152
|
"access": "public",
|
|
177
153
|
"name": "prisma-ts-select"
|
|
154
|
+
},
|
|
155
|
+
"scripts": {
|
|
156
|
+
"bp": "pnpm build && pnpm version patch && pnpm pack",
|
|
157
|
+
"build": "pnpm exec rimraf dist && tsup",
|
|
158
|
+
"reset": "rm -rf prisma/migrations/ && prisma migrate dev --name init && prisma generate",
|
|
159
|
+
"start": "tsx src/index.ts",
|
|
160
|
+
"prisma-upgrade": "pnpm i --save-dev prisma@latest && pnpm i @prisma/client@latest",
|
|
161
|
+
"lint:ts": "tsc --noEmit -p tsconfig.json",
|
|
162
|
+
"lint:tsw": "pnpm tsc -w",
|
|
163
|
+
"lint": "tsc --noEmit ; eslint \"scripts/**/*.{j,t}s{,x}\" --cache --max-warnings=0",
|
|
164
|
+
"lint:s": "eslint --config .eslintrc.style.json \"scripts/**/*.{j,t}s{,x}\" --cache --max-warnings=0",
|
|
165
|
+
"lint:fix": "eslint --config .eslintrc.style.json \"scripts/**/*.{j,t}s{,x}\" --cache --max-warnings=0 --fix",
|
|
166
|
+
"p:gen": "pnpm exec prisma generate",
|
|
167
|
+
"p:dbp": "pnpm exec prisma db push",
|
|
168
|
+
"p:migrate": "pnpm exec prisma migrate dev",
|
|
169
|
+
"p:update": "pnpm add -D prisma@latest && pnpm add @prisma/client@latest",
|
|
170
|
+
"test": "node --test tests/**/*.spec.ts",
|
|
171
|
+
"test:jest": "jest",
|
|
172
|
+
"2postinstall": "node src/scripts/postinstall.js",
|
|
173
|
+
"doc": "pnpm exec markdown-toc -i README.md",
|
|
174
|
+
"mdcode-ts": "pnpm exec mdcode",
|
|
175
|
+
"readme:extract": "pnpm mdcode extract README.md",
|
|
176
|
+
"readme:update": "pnpm mdcode update --transform ./transforms/readme-sql-clean.ts README.md",
|
|
177
|
+
"readme:test": "pnpm --filter usage-sqlite-v7 test -- tests/readme"
|
|
178
178
|
}
|
|
179
|
-
}
|
|
179
|
+
}
|