effect-qb 0.12.3
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/README.md +1294 -0
- package/dist/mysql.js +57575 -0
- package/dist/postgres.js +6303 -0
- package/package.json +42 -0
- package/src/internal/aggregation-validation.ts +57 -0
- package/src/internal/case-analysis.ts +50 -0
- package/src/internal/coercion-analysis.ts +30 -0
- package/src/internal/coercion-errors.ts +29 -0
- package/src/internal/coercion-kind.ts +32 -0
- package/src/internal/coercion-normalize.ts +7 -0
- package/src/internal/coercion-rules.ts +25 -0
- package/src/internal/column-state.ts +453 -0
- package/src/internal/column.ts +417 -0
- package/src/internal/datatypes/define.ts +44 -0
- package/src/internal/datatypes/lookup.ts +280 -0
- package/src/internal/datatypes/shape.ts +72 -0
- package/src/internal/derived-table.ts +149 -0
- package/src/internal/dialect.ts +30 -0
- package/src/internal/executor.ts +390 -0
- package/src/internal/expression-ast.ts +349 -0
- package/src/internal/expression.ts +325 -0
- package/src/internal/grouping-key.ts +82 -0
- package/src/internal/json/ast.ts +63 -0
- package/src/internal/json/errors.ts +13 -0
- package/src/internal/json/path.ts +227 -0
- package/src/internal/json/shape.ts +1 -0
- package/src/internal/json/types.ts +386 -0
- package/src/internal/mysql-dialect.ts +39 -0
- package/src/internal/mysql-renderer.ts +37 -0
- package/src/internal/plan.ts +64 -0
- package/src/internal/postgres-dialect.ts +34 -0
- package/src/internal/postgres-renderer.ts +40 -0
- package/src/internal/predicate-analysis.ts +71 -0
- package/src/internal/predicate-atom.ts +43 -0
- package/src/internal/predicate-branches.ts +40 -0
- package/src/internal/predicate-context.ts +279 -0
- package/src/internal/predicate-formula.ts +100 -0
- package/src/internal/predicate-key.ts +28 -0
- package/src/internal/predicate-nnf.ts +12 -0
- package/src/internal/predicate-normalize.ts +202 -0
- package/src/internal/projection-alias.ts +15 -0
- package/src/internal/projections.ts +101 -0
- package/src/internal/query-ast.ts +297 -0
- package/src/internal/query-factory.ts +6757 -0
- package/src/internal/query-requirements.ts +40 -0
- package/src/internal/query.ts +1590 -0
- package/src/internal/renderer.ts +102 -0
- package/src/internal/runtime-normalize.ts +344 -0
- package/src/internal/runtime-schema.ts +428 -0
- package/src/internal/runtime-value.ts +85 -0
- package/src/internal/schema-derivation.ts +131 -0
- package/src/internal/sql-expression-renderer.ts +1353 -0
- package/src/internal/table-options.ts +225 -0
- package/src/internal/table.ts +674 -0
- package/src/mysql/column.ts +30 -0
- package/src/mysql/datatypes/index.ts +6 -0
- package/src/mysql/datatypes/spec.ts +180 -0
- package/src/mysql/errors/catalog.ts +51662 -0
- package/src/mysql/errors/fields.ts +21 -0
- package/src/mysql/errors/index.ts +18 -0
- package/src/mysql/errors/normalize.ts +232 -0
- package/src/mysql/errors/requirements.ts +73 -0
- package/src/mysql/executor.ts +134 -0
- package/src/mysql/query.ts +189 -0
- package/src/mysql/renderer.ts +19 -0
- package/src/mysql/table.ts +157 -0
- package/src/mysql.ts +18 -0
- package/src/postgres/column.ts +20 -0
- package/src/postgres/datatypes/index.ts +8 -0
- package/src/postgres/datatypes/spec.ts +264 -0
- package/src/postgres/errors/catalog.ts +452 -0
- package/src/postgres/errors/fields.ts +48 -0
- package/src/postgres/errors/index.ts +4 -0
- package/src/postgres/errors/normalize.ts +209 -0
- package/src/postgres/errors/requirements.ts +65 -0
- package/src/postgres/errors/types.ts +38 -0
- package/src/postgres/executor.ts +131 -0
- package/src/postgres/query.ts +189 -0
- package/src/postgres/renderer.ts +29 -0
- package/src/postgres/table.ts +157 -0
- package/src/postgres.ts +18 -0
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { pipeArguments, type Pipeable } from "effect/Pipeable"
|
|
2
|
+
import * as Schema from "effect/Schema"
|
|
3
|
+
|
|
4
|
+
import * as Expression from "./expression.js"
|
|
5
|
+
import * as ExpressionAst from "./expression-ast.js"
|
|
6
|
+
|
|
7
|
+
/** Symbol used to attach column-definition metadata. */
|
|
8
|
+
export const ColumnTypeId: unique symbol = Symbol.for("effect-qb/Column")
|
|
9
|
+
/** Symbol used to attach bound-column provenance. */
|
|
10
|
+
export const BoundColumnTypeId: unique symbol = Symbol.for("effect-qb/BoundColumn")
|
|
11
|
+
|
|
12
|
+
export type ColumnTypeId = typeof ColumnTypeId
|
|
13
|
+
export type BoundColumnTypeId = typeof BoundColumnTypeId
|
|
14
|
+
|
|
15
|
+
/** Lazy reference to another bound column. */
|
|
16
|
+
export interface ColumnReference<Target = unknown> {
|
|
17
|
+
readonly target: () => Target
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Complete static state tracked for a column definition. */
|
|
21
|
+
export interface ColumnState<
|
|
22
|
+
Select,
|
|
23
|
+
Insert,
|
|
24
|
+
Update,
|
|
25
|
+
Db extends Expression.DbType.Any,
|
|
26
|
+
Nullable extends boolean,
|
|
27
|
+
HasDefault extends boolean,
|
|
28
|
+
Generated extends boolean,
|
|
29
|
+
PrimaryKey extends boolean,
|
|
30
|
+
Unique extends boolean,
|
|
31
|
+
Ref,
|
|
32
|
+
Source = never,
|
|
33
|
+
Dependencies extends Expression.SourceDependencies = {}
|
|
34
|
+
> {
|
|
35
|
+
readonly select: Select
|
|
36
|
+
readonly insert: Insert
|
|
37
|
+
readonly update: Update
|
|
38
|
+
readonly dbType: Db
|
|
39
|
+
readonly nullable: Nullable
|
|
40
|
+
readonly hasDefault: HasDefault
|
|
41
|
+
readonly generated: Generated
|
|
42
|
+
readonly primaryKey: PrimaryKey
|
|
43
|
+
readonly unique: Unique
|
|
44
|
+
readonly references: Ref
|
|
45
|
+
readonly source: Source
|
|
46
|
+
readonly dependencies: Dependencies
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Unbound column definition produced by the `Column` DSL. */
|
|
50
|
+
export interface ColumnDefinition<
|
|
51
|
+
Select,
|
|
52
|
+
Insert,
|
|
53
|
+
Update,
|
|
54
|
+
Db extends Expression.DbType.Any,
|
|
55
|
+
Nullable extends boolean,
|
|
56
|
+
HasDefault extends boolean,
|
|
57
|
+
Generated extends boolean,
|
|
58
|
+
PrimaryKey extends boolean,
|
|
59
|
+
Unique extends boolean,
|
|
60
|
+
Ref,
|
|
61
|
+
Source = never,
|
|
62
|
+
Dependencies extends Expression.SourceDependencies = {}
|
|
63
|
+
> extends Pipeable, Expression.Expression<
|
|
64
|
+
Select,
|
|
65
|
+
Db,
|
|
66
|
+
Nullable extends true ? "maybe" : "never",
|
|
67
|
+
Db["dialect"],
|
|
68
|
+
"scalar",
|
|
69
|
+
Source,
|
|
70
|
+
Dependencies
|
|
71
|
+
> {
|
|
72
|
+
readonly pipe: Pipeable["pipe"]
|
|
73
|
+
readonly [ColumnTypeId]: ColumnState<
|
|
74
|
+
Select,
|
|
75
|
+
Insert,
|
|
76
|
+
Update,
|
|
77
|
+
Db,
|
|
78
|
+
Nullable,
|
|
79
|
+
HasDefault,
|
|
80
|
+
Generated,
|
|
81
|
+
PrimaryKey,
|
|
82
|
+
Unique,
|
|
83
|
+
Ref,
|
|
84
|
+
Source,
|
|
85
|
+
Dependencies
|
|
86
|
+
>
|
|
87
|
+
readonly schema: Schema.Schema<NonNullable<Select>, any, any>
|
|
88
|
+
readonly metadata: {
|
|
89
|
+
readonly dbType: Db
|
|
90
|
+
readonly nullable: Nullable
|
|
91
|
+
readonly hasDefault: HasDefault
|
|
92
|
+
readonly generated: Generated
|
|
93
|
+
readonly primaryKey: PrimaryKey
|
|
94
|
+
readonly unique: Unique
|
|
95
|
+
readonly references: Ref
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Column definition bound to a concrete table and column name. */
|
|
100
|
+
export interface BoundColumn<
|
|
101
|
+
Select,
|
|
102
|
+
Insert,
|
|
103
|
+
Update,
|
|
104
|
+
Db extends Expression.DbType.Any,
|
|
105
|
+
Nullable extends boolean,
|
|
106
|
+
HasDefault extends boolean,
|
|
107
|
+
Generated extends boolean,
|
|
108
|
+
PrimaryKey extends boolean,
|
|
109
|
+
Unique extends boolean,
|
|
110
|
+
Ref,
|
|
111
|
+
TableName extends string,
|
|
112
|
+
ColumnName extends string,
|
|
113
|
+
BaseTableName extends string = TableName
|
|
114
|
+
> extends ColumnDefinition<
|
|
115
|
+
Select,
|
|
116
|
+
Insert,
|
|
117
|
+
Update,
|
|
118
|
+
Db,
|
|
119
|
+
Nullable,
|
|
120
|
+
HasDefault,
|
|
121
|
+
Generated,
|
|
122
|
+
PrimaryKey,
|
|
123
|
+
Unique,
|
|
124
|
+
Ref,
|
|
125
|
+
Expression.ColumnSource<TableName, ColumnName, BaseTableName>,
|
|
126
|
+
Record<TableName, true>
|
|
127
|
+
> {
|
|
128
|
+
readonly [BoundColumnTypeId]: {
|
|
129
|
+
readonly tableName: TableName
|
|
130
|
+
readonly columnName: ColumnName
|
|
131
|
+
readonly baseTableName: BaseTableName
|
|
132
|
+
readonly schemaName?: string
|
|
133
|
+
}
|
|
134
|
+
readonly [Expression.TypeId]: Expression.State<
|
|
135
|
+
Select,
|
|
136
|
+
Db,
|
|
137
|
+
Nullable extends true ? "maybe" : "never",
|
|
138
|
+
Db["dialect"],
|
|
139
|
+
"scalar",
|
|
140
|
+
Expression.ColumnSource<TableName, ColumnName, BaseTableName>,
|
|
141
|
+
Record<TableName, true>,
|
|
142
|
+
"propagate"
|
|
143
|
+
>
|
|
144
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.ColumnNode<TableName, ColumnName>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Convenience alias for any column definition. */
|
|
148
|
+
export type AnyColumnDefinition = ColumnDefinition<
|
|
149
|
+
any,
|
|
150
|
+
any,
|
|
151
|
+
any,
|
|
152
|
+
Expression.DbType.Any,
|
|
153
|
+
boolean,
|
|
154
|
+
boolean,
|
|
155
|
+
boolean,
|
|
156
|
+
boolean,
|
|
157
|
+
boolean,
|
|
158
|
+
any,
|
|
159
|
+
any
|
|
160
|
+
>
|
|
161
|
+
/** Convenience alias for any bound column. */
|
|
162
|
+
export type AnyBoundColumn = BoundColumn<
|
|
163
|
+
any,
|
|
164
|
+
any,
|
|
165
|
+
any,
|
|
166
|
+
Expression.DbType.Any,
|
|
167
|
+
boolean,
|
|
168
|
+
boolean,
|
|
169
|
+
boolean,
|
|
170
|
+
boolean,
|
|
171
|
+
boolean,
|
|
172
|
+
any,
|
|
173
|
+
string,
|
|
174
|
+
string
|
|
175
|
+
>
|
|
176
|
+
|
|
177
|
+
const ColumnProto = {
|
|
178
|
+
pipe(this: unknown) {
|
|
179
|
+
return pipeArguments(this, arguments)
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** Constructs a runtime column-definition object from schema and metadata. */
|
|
184
|
+
export const makeColumnDefinition = <
|
|
185
|
+
Select,
|
|
186
|
+
Insert,
|
|
187
|
+
Update,
|
|
188
|
+
Db extends Expression.DbType.Any,
|
|
189
|
+
Nullable extends boolean,
|
|
190
|
+
HasDefault extends boolean,
|
|
191
|
+
Generated extends boolean,
|
|
192
|
+
PrimaryKey extends boolean,
|
|
193
|
+
Unique extends boolean,
|
|
194
|
+
Ref,
|
|
195
|
+
Source = never,
|
|
196
|
+
Dependencies extends Expression.SourceDependencies = {}
|
|
197
|
+
>(
|
|
198
|
+
schema: Schema.Schema<NonNullable<Select>, any, any>,
|
|
199
|
+
metadata: ColumnDefinition<
|
|
200
|
+
Select,
|
|
201
|
+
Insert,
|
|
202
|
+
Update,
|
|
203
|
+
Db,
|
|
204
|
+
Nullable,
|
|
205
|
+
HasDefault,
|
|
206
|
+
Generated,
|
|
207
|
+
PrimaryKey,
|
|
208
|
+
Unique,
|
|
209
|
+
Ref,
|
|
210
|
+
Source,
|
|
211
|
+
Dependencies
|
|
212
|
+
>["metadata"]
|
|
213
|
+
): ColumnDefinition<
|
|
214
|
+
Select,
|
|
215
|
+
Insert,
|
|
216
|
+
Update,
|
|
217
|
+
Db,
|
|
218
|
+
Nullable,
|
|
219
|
+
HasDefault,
|
|
220
|
+
Generated,
|
|
221
|
+
PrimaryKey,
|
|
222
|
+
Unique,
|
|
223
|
+
Ref,
|
|
224
|
+
Source,
|
|
225
|
+
Dependencies
|
|
226
|
+
> => {
|
|
227
|
+
const column = Object.create(ColumnProto)
|
|
228
|
+
column.schema = schema
|
|
229
|
+
column.metadata = metadata
|
|
230
|
+
column[Expression.TypeId] = {
|
|
231
|
+
runtime: undefined as Select,
|
|
232
|
+
dbType: metadata.dbType,
|
|
233
|
+
runtimeSchema: schema,
|
|
234
|
+
nullability: (metadata.nullable ? "maybe" : "never") as Nullable extends true ? "maybe" : "never",
|
|
235
|
+
dialect: metadata.dbType.dialect,
|
|
236
|
+
aggregation: "scalar",
|
|
237
|
+
source: undefined as Source,
|
|
238
|
+
sourceNullability: "propagate" as const,
|
|
239
|
+
dependencies: {} as Dependencies
|
|
240
|
+
}
|
|
241
|
+
column[ColumnTypeId] = {
|
|
242
|
+
select: undefined as Select,
|
|
243
|
+
insert: undefined as Insert,
|
|
244
|
+
update: undefined as Update,
|
|
245
|
+
dbType: metadata.dbType,
|
|
246
|
+
nullable: metadata.nullable,
|
|
247
|
+
hasDefault: metadata.hasDefault,
|
|
248
|
+
generated: metadata.generated,
|
|
249
|
+
primaryKey: metadata.primaryKey,
|
|
250
|
+
unique: metadata.unique,
|
|
251
|
+
references: metadata.references,
|
|
252
|
+
source: undefined as Source,
|
|
253
|
+
dependencies: {} as Dependencies
|
|
254
|
+
}
|
|
255
|
+
return column
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export const remapColumnDefinition = <
|
|
259
|
+
Select,
|
|
260
|
+
Insert,
|
|
261
|
+
Update,
|
|
262
|
+
Db extends Expression.DbType.Any,
|
|
263
|
+
Nullable extends boolean,
|
|
264
|
+
HasDefault extends boolean,
|
|
265
|
+
Generated extends boolean,
|
|
266
|
+
PrimaryKey extends boolean,
|
|
267
|
+
Unique extends boolean,
|
|
268
|
+
Ref,
|
|
269
|
+
Source = never,
|
|
270
|
+
Dependencies extends Expression.SourceDependencies = {}
|
|
271
|
+
>(
|
|
272
|
+
column: ColumnDefinition<
|
|
273
|
+
Select,
|
|
274
|
+
Insert,
|
|
275
|
+
Update,
|
|
276
|
+
Db,
|
|
277
|
+
Nullable,
|
|
278
|
+
HasDefault,
|
|
279
|
+
Generated,
|
|
280
|
+
PrimaryKey,
|
|
281
|
+
Unique,
|
|
282
|
+
Ref,
|
|
283
|
+
Source,
|
|
284
|
+
Dependencies
|
|
285
|
+
>,
|
|
286
|
+
options: {
|
|
287
|
+
readonly schema?: Schema.Schema.Any
|
|
288
|
+
readonly metadata?: ColumnDefinition<
|
|
289
|
+
Select,
|
|
290
|
+
Insert,
|
|
291
|
+
Update,
|
|
292
|
+
Db,
|
|
293
|
+
Nullable,
|
|
294
|
+
HasDefault,
|
|
295
|
+
Generated,
|
|
296
|
+
PrimaryKey,
|
|
297
|
+
Unique,
|
|
298
|
+
Ref,
|
|
299
|
+
Source,
|
|
300
|
+
Dependencies
|
|
301
|
+
>["metadata"]
|
|
302
|
+
} = {}
|
|
303
|
+
): ColumnDefinition<
|
|
304
|
+
Select,
|
|
305
|
+
Insert,
|
|
306
|
+
Update,
|
|
307
|
+
Db,
|
|
308
|
+
Nullable,
|
|
309
|
+
HasDefault,
|
|
310
|
+
Generated,
|
|
311
|
+
PrimaryKey,
|
|
312
|
+
Unique,
|
|
313
|
+
Ref,
|
|
314
|
+
Source,
|
|
315
|
+
Dependencies
|
|
316
|
+
> => {
|
|
317
|
+
const schema = options.schema ?? column.schema
|
|
318
|
+
const metadata = options.metadata ?? column.metadata
|
|
319
|
+
const next = Object.create(ColumnProto)
|
|
320
|
+
next.schema = schema
|
|
321
|
+
next.metadata = metadata
|
|
322
|
+
next[Expression.TypeId] = {
|
|
323
|
+
...column[Expression.TypeId],
|
|
324
|
+
runtime: undefined as Select,
|
|
325
|
+
dbType: metadata.dbType,
|
|
326
|
+
runtimeSchema: schema,
|
|
327
|
+
nullability: (metadata.nullable ? "maybe" : "never") as Nullable extends true ? "maybe" : "never",
|
|
328
|
+
dialect: metadata.dbType.dialect
|
|
329
|
+
}
|
|
330
|
+
next[ColumnTypeId] = {
|
|
331
|
+
...column[ColumnTypeId],
|
|
332
|
+
select: undefined as Select,
|
|
333
|
+
insert: undefined as Insert,
|
|
334
|
+
update: undefined as Update,
|
|
335
|
+
dbType: metadata.dbType,
|
|
336
|
+
nullable: metadata.nullable,
|
|
337
|
+
hasDefault: metadata.hasDefault,
|
|
338
|
+
generated: metadata.generated,
|
|
339
|
+
primaryKey: metadata.primaryKey,
|
|
340
|
+
unique: metadata.unique,
|
|
341
|
+
references: metadata.references
|
|
342
|
+
}
|
|
343
|
+
if (ExpressionAst.TypeId in column) {
|
|
344
|
+
next[ExpressionAst.TypeId] = (column as unknown as {
|
|
345
|
+
readonly [ExpressionAst.TypeId]: ExpressionAst.Any
|
|
346
|
+
})[ExpressionAst.TypeId]
|
|
347
|
+
}
|
|
348
|
+
if (BoundColumnTypeId in column) {
|
|
349
|
+
next[BoundColumnTypeId] = (column as unknown as {
|
|
350
|
+
readonly [BoundColumnTypeId]: {
|
|
351
|
+
readonly tableName: string
|
|
352
|
+
readonly columnName: string
|
|
353
|
+
readonly baseTableName: string
|
|
354
|
+
readonly schemaName?: string
|
|
355
|
+
}
|
|
356
|
+
})[BoundColumnTypeId]
|
|
357
|
+
}
|
|
358
|
+
return next
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
/** Attaches table/column provenance to an existing column definition. */
|
|
362
|
+
export const bindColumn = <
|
|
363
|
+
TableName extends string,
|
|
364
|
+
ColumnName extends string,
|
|
365
|
+
BaseTableName extends string,
|
|
366
|
+
SchemaName extends string | undefined,
|
|
367
|
+
Column extends AnyColumnDefinition
|
|
368
|
+
>(
|
|
369
|
+
tableName: TableName,
|
|
370
|
+
columnName: ColumnName,
|
|
371
|
+
column: Column,
|
|
372
|
+
baseTableName: BaseTableName,
|
|
373
|
+
schemaName?: SchemaName
|
|
374
|
+
): BoundColumnFrom<Column, TableName, ColumnName, BaseTableName> => {
|
|
375
|
+
const bound = Object.create(ColumnProto)
|
|
376
|
+
bound.schema = column.schema
|
|
377
|
+
bound.metadata = column.metadata
|
|
378
|
+
bound[Expression.TypeId] = {
|
|
379
|
+
runtime: undefined as SelectType<Column>,
|
|
380
|
+
dbType: column.metadata.dbType,
|
|
381
|
+
runtimeSchema: column.schema,
|
|
382
|
+
nullability: (column.metadata.nullable ? "maybe" : "never") as IsNullable<Column> extends true ? "maybe" : "never",
|
|
383
|
+
dialect: column.metadata.dbType.dialect,
|
|
384
|
+
aggregation: "scalar",
|
|
385
|
+
source: {
|
|
386
|
+
tableName,
|
|
387
|
+
columnName,
|
|
388
|
+
baseTableName
|
|
389
|
+
},
|
|
390
|
+
sourceNullability: "propagate" as const,
|
|
391
|
+
dependencies: {
|
|
392
|
+
[tableName]: true
|
|
393
|
+
} as Record<TableName, true>
|
|
394
|
+
}
|
|
395
|
+
bound[ExpressionAst.TypeId] = {
|
|
396
|
+
kind: "column",
|
|
397
|
+
tableName,
|
|
398
|
+
columnName
|
|
399
|
+
} satisfies ExpressionAst.ColumnNode<TableName, ColumnName>
|
|
400
|
+
bound[ColumnTypeId] = column[ColumnTypeId]
|
|
401
|
+
bound[BoundColumnTypeId] = {
|
|
402
|
+
tableName,
|
|
403
|
+
columnName,
|
|
404
|
+
baseTableName,
|
|
405
|
+
schemaName
|
|
406
|
+
}
|
|
407
|
+
return bound
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/** Extracts the internal state record for a column. */
|
|
411
|
+
export type ColumnStateOf<Column extends AnyColumnDefinition> = Column[typeof ColumnTypeId]
|
|
412
|
+
/** Extracts the read/select type of a column. */
|
|
413
|
+
export type SelectType<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["select"]
|
|
414
|
+
/** Extracts the insert type of a column. */
|
|
415
|
+
export type InsertType<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["insert"]
|
|
416
|
+
/** Extracts the update type of a column. */
|
|
417
|
+
export type UpdateType<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["update"]
|
|
418
|
+
/** Extracts whether a column is nullable. */
|
|
419
|
+
export type IsNullable<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["nullable"]
|
|
420
|
+
/** Extracts whether a column has a server-side default. */
|
|
421
|
+
export type HasDefault<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["hasDefault"]
|
|
422
|
+
/** Extracts whether a column is generated by the database. */
|
|
423
|
+
export type IsGenerated<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["generated"]
|
|
424
|
+
/** Extracts whether a column is part of a primary key. */
|
|
425
|
+
export type IsPrimaryKey<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["primaryKey"]
|
|
426
|
+
/** Extracts whether a column is unique. */
|
|
427
|
+
export type IsUnique<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["unique"]
|
|
428
|
+
/** Extracts a column's foreign-key reference metadata. */
|
|
429
|
+
export type ReferencesOf<Column extends AnyColumnDefinition> = ColumnStateOf<Column>["references"]
|
|
430
|
+
/** Extracts the non-null select type of a column. */
|
|
431
|
+
export type BaseSelectType<Column extends AnyColumnDefinition> = NonNullable<SelectType<Column>>
|
|
432
|
+
|
|
433
|
+
/** Rebinds a generic column definition to a specific table and key. */
|
|
434
|
+
export type BoundColumnFrom<
|
|
435
|
+
Column extends AnyColumnDefinition,
|
|
436
|
+
TableName extends string,
|
|
437
|
+
ColumnName extends string,
|
|
438
|
+
BaseTableName extends string = TableName
|
|
439
|
+
> = BoundColumn<
|
|
440
|
+
SelectType<Column>,
|
|
441
|
+
InsertType<Column>,
|
|
442
|
+
UpdateType<Column>,
|
|
443
|
+
ColumnStateOf<Column>["dbType"],
|
|
444
|
+
IsNullable<Column>,
|
|
445
|
+
HasDefault<Column>,
|
|
446
|
+
IsGenerated<Column>,
|
|
447
|
+
IsPrimaryKey<Column>,
|
|
448
|
+
IsUnique<Column>,
|
|
449
|
+
ReferencesOf<Column>,
|
|
450
|
+
TableName,
|
|
451
|
+
ColumnName,
|
|
452
|
+
BaseTableName
|
|
453
|
+
>
|