effect-qb 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/README.md +6 -1431
  2. package/dist/mysql.js +61945 -3611
  3. package/dist/postgres/metadata.js +2818 -0
  4. package/dist/postgres.js +9942 -5591
  5. package/package.json +21 -10
  6. package/src/internal/aggregation-validation.ts +3 -3
  7. package/src/internal/case-analysis.d.ts +18 -0
  8. package/src/internal/case-analysis.ts +4 -4
  9. package/src/internal/coercion/analysis.d.ts +7 -0
  10. package/src/internal/{coercion-analysis.ts → coercion/analysis.ts} +3 -3
  11. package/src/internal/coercion/errors.d.ts +17 -0
  12. package/src/internal/{coercion-errors.ts → coercion/errors.ts} +1 -1
  13. package/src/internal/coercion/kind.d.ts +4 -0
  14. package/src/internal/{coercion-kind.ts → coercion/kind.ts} +2 -2
  15. package/src/internal/{coercion-normalize.ts → coercion/normalize.ts} +1 -1
  16. package/src/internal/coercion/rules.d.ts +6 -0
  17. package/src/internal/{coercion-rules.ts → coercion/rules.ts} +2 -2
  18. package/src/internal/column-state.d.ts +190 -0
  19. package/src/internal/column-state.ts +119 -56
  20. package/src/internal/column.ts +387 -149
  21. package/src/internal/datatypes/define.d.ts +17 -0
  22. package/src/internal/datatypes/define.ts +18 -34
  23. package/src/internal/datatypes/lookup.d.ts +44 -0
  24. package/src/internal/datatypes/lookup.ts +61 -152
  25. package/src/internal/datatypes/shape.d.ts +16 -0
  26. package/src/internal/datatypes/shape.ts +1 -1
  27. package/src/internal/derived-table.d.ts +4 -0
  28. package/src/internal/derived-table.ts +21 -16
  29. package/src/internal/dsl-mutation-runtime.ts +378 -0
  30. package/src/internal/dsl-plan-runtime.ts +387 -0
  31. package/src/internal/dsl-query-runtime.ts +160 -0
  32. package/src/internal/dsl-transaction-ddl-runtime.ts +263 -0
  33. package/src/internal/executor.ts +173 -38
  34. package/src/internal/expression-ast.ts +19 -5
  35. package/src/internal/grouping-key.d.ts +3 -0
  36. package/src/internal/grouping-key.ts +1 -1
  37. package/src/internal/implication-runtime.d.ts +15 -0
  38. package/src/internal/implication-runtime.ts +171 -0
  39. package/src/internal/json/ast.d.ts +30 -0
  40. package/src/internal/json/ast.ts +1 -1
  41. package/src/internal/json/errors.d.ts +8 -0
  42. package/src/internal/json/path.d.ts +75 -0
  43. package/src/internal/json/path.ts +1 -1
  44. package/src/internal/json/types.d.ts +62 -0
  45. package/src/internal/predicate/analysis.d.ts +20 -0
  46. package/src/internal/{predicate-analysis.ts → predicate/analysis.ts} +13 -3
  47. package/src/internal/predicate/atom.d.ts +28 -0
  48. package/src/internal/{predicate-branches.ts → predicate/branches.ts} +2 -2
  49. package/src/internal/predicate/context.d.ts +67 -0
  50. package/src/internal/{predicate-context.ts → predicate/context.ts} +111 -32
  51. package/src/internal/predicate/formula.d.ts +35 -0
  52. package/src/internal/{predicate-formula.ts → predicate/formula.ts} +32 -20
  53. package/src/internal/predicate/key.d.ts +11 -0
  54. package/src/internal/{predicate-key.ts → predicate/key.ts} +2 -2
  55. package/src/internal/{predicate-nnf.ts → predicate/nnf.ts} +2 -2
  56. package/src/internal/predicate/normalize.d.ts +53 -0
  57. package/src/internal/predicate/normalize.ts +273 -0
  58. package/src/internal/predicate/runtime.d.ts +31 -0
  59. package/src/internal/predicate/runtime.ts +679 -0
  60. package/src/internal/projection-alias.d.ts +13 -0
  61. package/src/internal/projections.d.ts +31 -0
  62. package/src/internal/projections.ts +1 -1
  63. package/src/internal/query-ast.d.ts +217 -0
  64. package/src/internal/query-ast.ts +1 -1
  65. package/src/internal/query-requirements.d.ts +20 -0
  66. package/src/internal/query.d.ts +775 -0
  67. package/src/internal/query.ts +767 -275
  68. package/src/internal/renderer.ts +7 -21
  69. package/src/internal/row-set.d.ts +53 -0
  70. package/src/internal/{plan.ts → row-set.ts} +23 -11
  71. package/src/internal/{runtime-normalize.ts → runtime/normalize.ts} +9 -31
  72. package/src/internal/{runtime-schema.ts → runtime/schema.ts} +84 -55
  73. package/src/internal/runtime/value.d.ts +22 -0
  74. package/src/internal/{runtime-value.ts → runtime/value.ts} +2 -2
  75. package/src/internal/scalar.d.ts +107 -0
  76. package/src/internal/scalar.ts +191 -0
  77. package/src/internal/schema-derivation.d.ts +105 -0
  78. package/src/internal/schema-derivation.ts +93 -21
  79. package/src/internal/schema-expression.d.ts +18 -0
  80. package/src/internal/schema-expression.ts +75 -0
  81. package/src/internal/table-options.d.ts +94 -0
  82. package/src/internal/table-options.ts +94 -8
  83. package/src/internal/table.d.ts +173 -0
  84. package/src/internal/table.ts +135 -54
  85. package/src/mysql/column.ts +95 -18
  86. package/src/mysql/datatypes/index.ts +58 -3
  87. package/src/mysql/errors/generated.ts +57336 -0
  88. package/src/mysql/errors/index.ts +1 -0
  89. package/src/mysql/errors/normalize.ts +55 -53
  90. package/src/mysql/errors/types.ts +74 -0
  91. package/src/mysql/executor.ts +69 -7
  92. package/src/mysql/function/aggregate.ts +1 -5
  93. package/src/mysql/function/core.ts +1 -3
  94. package/src/mysql/function/index.ts +1 -1
  95. package/src/mysql/function/string.ts +1 -5
  96. package/src/mysql/function/temporal.ts +12 -15
  97. package/src/mysql/function/window.ts +1 -6
  98. package/src/{internal/mysql-dialect.ts → mysql/internal/dialect.ts} +1 -1
  99. package/src/mysql/internal/dsl.ts +6115 -0
  100. package/src/{internal/mysql-renderer.ts → mysql/internal/renderer.ts} +6 -6
  101. package/src/mysql/internal/sql-expression-renderer.ts +1455 -0
  102. package/src/mysql/json.ts +2 -0
  103. package/src/mysql/query.ts +111 -86
  104. package/src/mysql/renderer.ts +1 -1
  105. package/src/mysql/table.ts +1 -1
  106. package/src/mysql.ts +6 -4
  107. package/src/postgres/cast.ts +30 -0
  108. package/src/postgres/column.ts +178 -20
  109. package/src/postgres/datatypes/index.d.ts +515 -0
  110. package/src/postgres/datatypes/index.ts +49 -5
  111. package/src/postgres/datatypes/spec.d.ts +412 -0
  112. package/src/postgres/errors/generated.ts +2636 -0
  113. package/src/postgres/errors/index.ts +1 -0
  114. package/src/postgres/errors/normalize.ts +47 -62
  115. package/src/postgres/errors/types.ts +92 -34
  116. package/src/postgres/executor.ts +37 -5
  117. package/src/postgres/function/aggregate.ts +1 -5
  118. package/src/postgres/function/core.ts +20 -2
  119. package/src/postgres/function/index.ts +1 -1
  120. package/src/postgres/function/string.ts +1 -5
  121. package/src/postgres/function/temporal.ts +12 -15
  122. package/src/postgres/function/window.ts +1 -6
  123. package/src/{internal/postgres-dialect.ts → postgres/internal/dialect.ts} +1 -1
  124. package/src/{internal/query-factory.ts → postgres/internal/dsl.ts} +1568 -2120
  125. package/src/{internal/postgres-renderer.ts → postgres/internal/renderer.ts} +6 -6
  126. package/src/postgres/internal/schema-ddl.ts +108 -0
  127. package/src/postgres/internal/schema-model.ts +150 -0
  128. package/src/{internal → postgres/internal}/sql-expression-renderer.ts +112 -46
  129. package/src/postgres/json.ts +493 -0
  130. package/src/postgres/metadata.ts +31 -0
  131. package/src/postgres/query.ts +113 -86
  132. package/src/postgres/renderer.ts +3 -13
  133. package/src/postgres/schema-expression.ts +17 -0
  134. package/src/postgres/schema-management.ts +204 -0
  135. package/src/postgres/schema.ts +35 -0
  136. package/src/postgres/table.ts +316 -42
  137. package/src/postgres/type.ts +31 -0
  138. package/src/postgres.ts +20 -4
  139. package/CHANGELOG.md +0 -134
  140. package/src/internal/expression.ts +0 -327
  141. package/src/internal/predicate-normalize.ts +0 -202
  142. package/src/mysql/function/json.ts +0 -4
  143. package/src/mysql/private/query.ts +0 -13
  144. package/src/postgres/function/json.ts +0 -4
  145. package/src/postgres/private/query.ts +0 -13
  146. /package/src/internal/{predicate-atom.ts → predicate/atom.ts} +0 -0
@@ -0,0 +1,2 @@
1
+ /** MySQL JSON expression helpers. */
2
+ export { json } from "./internal/dsl.js"
@@ -1,4 +1,7 @@
1
1
  import {
2
+ type AnyTableFunctionSource,
3
+ type AnyUnnestSource,
4
+ type AnyValuesSource,
2
5
  type CapabilitiesOfPlan,
3
6
  type CompletePlan,
4
7
  type DialectCompatiblePlan,
@@ -35,93 +38,115 @@ import {
35
38
  type StatementOfPlan,
36
39
  type StringExpressionInput
37
40
  } from "../internal/query.js"
38
- import { mysqlQuery } from "./private/query.js"
41
+ import {
42
+ type PublicNonStructuredFromApi,
43
+ type PublicStructuredFromConstraint,
44
+ type PublicStructuredFromResult,
45
+ type as mysqlType,
46
+ values,
47
+ unnest,
48
+ select,
49
+ insert,
50
+ from as dslFrom
51
+ } from "./internal/dsl.js"
52
+
53
+ export {
54
+ literal,
55
+ column,
56
+ cast,
57
+ eq,
58
+ neq,
59
+ lt,
60
+ lte,
61
+ gt,
62
+ gte,
63
+ isNull,
64
+ isNotNull,
65
+ like,
66
+ ilike,
67
+ regexMatch,
68
+ regexIMatch,
69
+ regexNotMatch,
70
+ regexNotIMatch,
71
+ and,
72
+ or,
73
+ not,
74
+ all,
75
+ any,
76
+ case_ as case,
77
+ match,
78
+ in_ as in,
79
+ notIn,
80
+ between,
81
+ contains,
82
+ containedBy,
83
+ overlaps,
84
+ exists,
85
+ isDistinctFrom,
86
+ isNotDistinctFrom,
87
+ excluded,
88
+ as,
89
+ with_ as with,
90
+ withRecursive,
91
+ lateral,
92
+ scalar,
93
+ inSubquery,
94
+ compareAny,
95
+ compareAll,
96
+ generateSeries,
97
+ values,
98
+ unnest,
99
+ select,
100
+ returning,
101
+ onConflict,
102
+ insert,
103
+ update,
104
+ upsert,
105
+ delete_ as delete,
106
+ truncate,
107
+ merge,
108
+ transaction,
109
+ commit,
110
+ rollback,
111
+ savepoint,
112
+ rollbackTo,
113
+ releaseSavepoint,
114
+ createTable,
115
+ dropTable,
116
+ createIndex,
117
+ dropIndex,
118
+ union,
119
+ unionAll,
120
+ intersect,
121
+ intersectAll,
122
+ except,
123
+ exceptAll,
124
+ where,
125
+ having,
126
+ innerJoin,
127
+ leftJoin,
128
+ rightJoin,
129
+ fullJoin,
130
+ crossJoin,
131
+ distinct,
132
+ distinctOn,
133
+ limit,
134
+ offset,
135
+ lock,
136
+ orderBy,
137
+ groupBy
138
+ } from "./internal/dsl.js"
139
+ export { mysqlType as type }
140
+
141
+ type StructuredSource = AnyValuesSource | AnyUnnestSource | AnyTableFunctionSource
142
+
143
+ type StructuredFromApi = <CurrentSource extends StructuredSource>(
144
+ source: CurrentSource
145
+ ) => <PlanValue extends QueryPlan<any, any, any, any, any, any, any, any, any, any>>(
146
+ plan: PlanValue & PublicStructuredFromConstraint<PlanValue, CurrentSource, "mysql">
147
+ ) => PublicStructuredFromResult<PlanValue, CurrentSource, "mysql">
39
148
 
40
- export const literal = mysqlQuery.literal
41
- export const cast = mysqlQuery.cast
42
- export const type = mysqlQuery.type
43
- export const eq = mysqlQuery.eq
44
- export const neq = mysqlQuery.neq
45
- export const lt = mysqlQuery.lt
46
- export const lte = mysqlQuery.lte
47
- export const gt = mysqlQuery.gt
48
- export const gte = mysqlQuery.gte
49
- export const isNull = mysqlQuery.isNull
50
- export const isNotNull = mysqlQuery.isNotNull
51
- export const like = mysqlQuery.like
52
- export const ilike = mysqlQuery.ilike
53
- export const and = mysqlQuery.and
54
- export const or = mysqlQuery.or
55
- export const not = mysqlQuery.not
56
- export const all = mysqlQuery.all
57
- export const any = mysqlQuery.any
58
- const case_ = mysqlQuery.case
59
- export const match = mysqlQuery.match
60
- export const in_ = mysqlQuery.in
61
- export const notIn = mysqlQuery.notIn
62
- export const between = mysqlQuery.between
63
- export const contains = mysqlQuery.contains
64
- export const containedBy = mysqlQuery.containedBy
65
- export const overlaps = mysqlQuery.overlaps
66
- export const exists = mysqlQuery.exists
67
- export const isDistinctFrom = mysqlQuery.isDistinctFrom
68
- export const isNotDistinctFrom = mysqlQuery.isNotDistinctFrom
69
- export const excluded = mysqlQuery.excluded
70
- export const as = mysqlQuery.as
71
- export const with_ = mysqlQuery.with
72
- export const withRecursive = mysqlQuery.withRecursive
73
- export const lateral = mysqlQuery.lateral
74
- export const scalar = mysqlQuery.scalar
75
- export const inSubquery = mysqlQuery.inSubquery
76
- export const compareAny = mysqlQuery.compareAny
77
- export const compareAll = mysqlQuery.compareAll
78
- export const values = mysqlQuery.values
79
- export const unnest = mysqlQuery.unnest
80
- export const generateSeries = mysqlQuery.generateSeries
81
- export const returning = mysqlQuery.returning
82
- export const onConflict = mysqlQuery.onConflict
83
- export const insert = mysqlQuery.insert
84
- export const update = mysqlQuery.update
85
- export const upsert = mysqlQuery.upsert
86
- export const delete_ = mysqlQuery.delete
87
- export const truncate = mysqlQuery.truncate
88
- export const merge = mysqlQuery.merge
89
- export const transaction = mysqlQuery.transaction
90
- export const commit = mysqlQuery.commit
91
- export const rollback = mysqlQuery.rollback
92
- export const savepoint = mysqlQuery.savepoint
93
- export const rollbackTo = mysqlQuery.rollbackTo
94
- export const releaseSavepoint = mysqlQuery.releaseSavepoint
95
- export const createTable = mysqlQuery.createTable
96
- export const dropTable = mysqlQuery.dropTable
97
- export const createIndex = mysqlQuery.createIndex
98
- export const dropIndex = mysqlQuery.dropIndex
99
- export const union = mysqlQuery.union
100
- export const unionAll = mysqlQuery.unionAll
101
- export const intersect = mysqlQuery.intersect
102
- export const intersectAll = mysqlQuery.intersectAll
103
- export const except = mysqlQuery.except
104
- export const exceptAll = mysqlQuery.exceptAll
105
- export const select = mysqlQuery.select
106
- export const where = mysqlQuery.where
107
- export const having = mysqlQuery.having
108
- export const from = mysqlQuery.from
109
- export const innerJoin = mysqlQuery.innerJoin
110
- export const leftJoin = mysqlQuery.leftJoin
111
- export const rightJoin = mysqlQuery.rightJoin
112
- export const fullJoin = mysqlQuery.fullJoin
113
- export const crossJoin = mysqlQuery.crossJoin
114
- export const distinct = mysqlQuery.distinct
115
- export const distinctOn = mysqlQuery.distinctOn
116
- export const limit = mysqlQuery.limit
117
- export const offset = mysqlQuery.offset
118
- export const lock = mysqlQuery.lock
119
- export const orderBy = mysqlQuery.orderBy
120
- export const groupBy = mysqlQuery.groupBy
121
- export { case_ as case }
122
- export { in_ as in }
123
- export { with_ as with }
124
- export { delete_ as delete }
149
+ export const from: StructuredFromApi & PublicNonStructuredFromApi = dslFrom as StructuredFromApi & PublicNonStructuredFromApi
125
150
 
126
151
  export type {
127
152
  CapabilitiesOfPlan,
@@ -1,5 +1,5 @@
1
1
  import * as CoreRenderer from "../internal/renderer.js"
2
- import { renderMysqlPlan } from "../internal/mysql-renderer.js"
2
+ import { renderMysqlPlan } from "./internal/renderer.js"
3
3
 
4
4
  /** MySQL-specialized rendered query shape. */
5
5
  export type RenderedQuery<Row> = CoreRenderer.RenderedQuery<Row, "mysql">
@@ -1,6 +1,6 @@
1
1
  import type * as Schema from "effect/Schema"
2
2
 
3
- import type * as Expression from "../internal/expression.js"
3
+ import type * as Expression from "../internal/scalar.js"
4
4
  import { ColumnTypeId, type AnyColumnDefinition } from "../internal/column-state.js"
5
5
  import * as BaseTable from "../internal/table.js"
6
6
 
package/src/mysql.ts CHANGED
@@ -4,14 +4,16 @@ export * as Column from "./mysql/column.js"
4
4
  export * as Datatypes from "./mysql/datatypes/index.js"
5
5
  /** MySQL error catalog and error normalization helpers. */
6
6
  export * as Errors from "./mysql/errors/index.js"
7
- /** Shared scalar SQL expression interfaces and DB-type descriptors. */
8
- export * as Expression from "./internal/expression.js"
7
+ /** Shared scalar SQL interfaces and DB-type descriptors. */
8
+ export * as Scalar from "./internal/scalar.js"
9
9
  /** MySQL-specialized SQL function expressions. */
10
10
  export * as Function from "./mysql/function/index.js"
11
+ /** MySQL-specialized JSON expression helpers. */
12
+ export * as Json from "./mysql/json.js"
11
13
  /** MySQL-specialized typed query execution contracts. */
12
14
  export * as Executor from "./mysql/executor.js"
13
- /** Shared logical query-plan interfaces. */
14
- export * as Plan from "./internal/plan.js"
15
+ /** Shared logical row-set interfaces. */
16
+ export * as RowSet from "./internal/row-set.js"
15
17
  /** MySQL-specialized query-construction DSL. */
16
18
  export * as Query from "./mysql/query.js"
17
19
  /** MySQL-specialized table-definition DSL. */
@@ -0,0 +1,30 @@
1
+ import type * as Expression from "../internal/scalar.js"
2
+ import type { ExpressionInput } from "../internal/query.js"
3
+ import { cast as postgresCast } from "./internal/dsl.js"
4
+
5
+ type CastInput = ExpressionInput
6
+ type CastTarget = Expression.DbType.Any
7
+ type CastExpression<Target extends CastTarget> = Expression.Scalar<
8
+ Expression.RuntimeOfDbType<Target>,
9
+ Target,
10
+ Expression.Nullability,
11
+ Target["dialect"],
12
+ Expression.ScalarKind,
13
+ Expression.BindingId
14
+ >
15
+
16
+ const to: {
17
+ <Value extends CastInput, Target extends CastTarget>(
18
+ value: Value,
19
+ target: Target
20
+ ): CastExpression<Target>
21
+ <Target extends CastTarget>(
22
+ target: Target
23
+ ): <Value extends CastInput>(value: Value) => CastExpression<Target>
24
+ } = ((...args: [CastInput, CastTarget] | [CastTarget]) =>
25
+ args.length === 1
26
+ ? ((value: CastInput) => postgresCast(value as never, args[0] as never))
27
+ : postgresCast(args[0] as never, args[1] as never)) as unknown as typeof to
28
+
29
+ /** Postgres cast helpers. */
30
+ export const cast = { to }
@@ -1,20 +1,178 @@
1
- export {
2
- boolean,
3
- date,
4
- default_ as default,
5
- generated,
6
- int,
7
- json,
8
- nullable,
9
- number,
10
- primaryKey,
11
- references,
12
- schema,
13
- text,
14
- timestamp,
15
- custom,
16
- unique,
17
- uuid
18
- } from "../internal/column.js"
19
-
20
- export type { Any, AnyBound } from "../internal/column.js"
1
+ import * as Schema from "effect/Schema"
2
+
3
+ import * as BaseColumn from "../internal/column.js"
4
+ import { makeColumnDefinition, type ColumnDefinition } from "../internal/column-state.js"
5
+ import type * as Expression from "../internal/scalar.js"
6
+ import {
7
+ BigIntStringSchema,
8
+ DecimalStringSchema,
9
+ InstantStringSchema,
10
+ LocalDateStringSchema,
11
+ LocalDateTimeStringSchema,
12
+ LocalTimeStringSchema,
13
+ OffsetTimeStringSchema,
14
+ type BigIntString,
15
+ type DecimalString,
16
+ type InstantString,
17
+ type LocalDateString,
18
+ type LocalDateTimeString,
19
+ type LocalTimeString,
20
+ type OffsetTimeString
21
+ } from "../internal/runtime/value.js"
22
+ import { postgresDatatypes } from "./datatypes/index.js"
23
+
24
+ const enrichDbType = <Db extends Expression.DbType.Any>(dbType: Db): Db => {
25
+ const candidate = (postgresDatatypes as unknown as Record<string, (() => Expression.DbType.Any) | undefined>)[dbType.kind]
26
+ return typeof candidate === "function"
27
+ ? { ...candidate(), ...dbType } as Db
28
+ : dbType
29
+ }
30
+
31
+ const primitive = <Type, Db extends Expression.DbType.Any>(
32
+ schema: Schema.Schema<Type, any, any>,
33
+ dbType: Db
34
+ ): ColumnDefinition<Type, Type, Type, Db, false, false, false, false, false, undefined> =>
35
+ makeColumnDefinition(schema as Schema.Schema<NonNullable<Type>>, {
36
+ dbType,
37
+ nullable: false,
38
+ hasDefault: false,
39
+ generated: false,
40
+ primaryKey: false,
41
+ unique: false,
42
+ references: undefined
43
+ })
44
+
45
+ const renderNumericDdlType = (
46
+ kind: string,
47
+ options?: BaseColumn.NumericOptions
48
+ ): string | undefined => {
49
+ if (options === undefined || options.precision === undefined) {
50
+ return undefined
51
+ }
52
+ return options.scale === undefined
53
+ ? `${kind}(${options.precision})`
54
+ : `${kind}(${options.precision},${options.scale})`
55
+ }
56
+
57
+ const boundedString = (length?: number): Schema.Schema<string> =>
58
+ length === undefined
59
+ ? Schema.String
60
+ : Schema.String.pipe(Schema.maxLength(length))
61
+
62
+ export const custom = <SchemaType extends Schema.Schema.Any, Db extends Expression.DbType.Any>(
63
+ schema: SchemaType,
64
+ dbType: Db
65
+ ) =>
66
+ makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>, any, any>, {
67
+ dbType: enrichDbType(dbType),
68
+ nullable: false,
69
+ hasDefault: false,
70
+ generated: false,
71
+ primaryKey: false,
72
+ unique: false,
73
+ references: undefined,
74
+ ddlType: undefined,
75
+ identity: undefined
76
+ })
77
+
78
+ export const uuid = () => primitive(Schema.UUID, postgresDatatypes.uuid())
79
+ export const text = () => primitive(Schema.String, postgresDatatypes.text())
80
+ export const int = () => primitive(Schema.Int, postgresDatatypes.int4())
81
+ export const int2 = () => primitive(Schema.Int, postgresDatatypes.int2())
82
+ export const int8 = () => primitive(BigIntStringSchema, postgresDatatypes.int8())
83
+ export const number = (options?: BaseColumn.NumericOptions) =>
84
+ makeColumnDefinition(DecimalStringSchema, {
85
+ dbType: postgresDatatypes.numeric(),
86
+ nullable: false,
87
+ hasDefault: false,
88
+ generated: false,
89
+ primaryKey: false,
90
+ unique: false,
91
+ references: undefined,
92
+ ddlType: renderNumericDdlType("numeric", options),
93
+ identity: undefined
94
+ })
95
+ export const float4 = () => primitive(Schema.Number, postgresDatatypes.float4())
96
+ export const float8 = () => primitive(Schema.Number, postgresDatatypes.float8())
97
+ export const boolean = () => primitive(Schema.Boolean, postgresDatatypes.boolean())
98
+ export const date = () => primitive(LocalDateStringSchema, postgresDatatypes.date())
99
+ export const timestamp = () => primitive(LocalDateTimeStringSchema, postgresDatatypes.timestamp())
100
+ export const time = () => primitive(LocalTimeStringSchema, postgresDatatypes.time())
101
+ export const timetz = () => primitive(OffsetTimeStringSchema, postgresDatatypes.timetz())
102
+ export const timestamptz = () => primitive(InstantStringSchema, postgresDatatypes.timestamptz())
103
+ export const interval = () => primitive(Schema.String, postgresDatatypes.interval())
104
+ export const bytea = () => primitive(Schema.Uint8ArrayFromSelf, postgresDatatypes.bytea())
105
+ export const name = () => primitive(Schema.String, postgresDatatypes.name())
106
+ export const oid = () => primitive(Schema.Int, postgresDatatypes.oid())
107
+ export const regclass = () => primitive(Schema.String, postgresDatatypes.regclass())
108
+ export const bit = () => primitive(Schema.String, postgresDatatypes.bit())
109
+ export const varbit = () => primitive(Schema.String, postgresDatatypes.varbit())
110
+ export const xml = () => primitive(Schema.String, postgresDatatypes.xml())
111
+ export const pg_lsn = () => primitive(Schema.String, postgresDatatypes.pg_lsn())
112
+ export const char = (length = 1) =>
113
+ makeColumnDefinition(boundedString(length), {
114
+ dbType: postgresDatatypes.char(),
115
+ nullable: false,
116
+ hasDefault: false,
117
+ generated: false,
118
+ primaryKey: false,
119
+ unique: false,
120
+ references: undefined,
121
+ ddlType: `char(${length})`,
122
+ identity: undefined
123
+ })
124
+ export const varchar = (length?: number) =>
125
+ makeColumnDefinition(boundedString(length), {
126
+ dbType: postgresDatatypes.varchar(),
127
+ nullable: false,
128
+ hasDefault: false,
129
+ generated: false,
130
+ primaryKey: false,
131
+ unique: false,
132
+ references: undefined,
133
+ ddlType: length === undefined ? "varchar" : `varchar(${length})`,
134
+ identity: undefined
135
+ })
136
+ export const json = <SchemaType extends Schema.Schema.Any>(schema: SchemaType) =>
137
+ makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>, any, any>, {
138
+ dbType: postgresDatatypes.json(),
139
+ nullable: false,
140
+ hasDefault: false,
141
+ generated: false,
142
+ primaryKey: false,
143
+ unique: false,
144
+ references: undefined,
145
+ ddlType: undefined,
146
+ identity: undefined
147
+ })
148
+ export const jsonb = <SchemaType extends Schema.Schema.Any>(schema: SchemaType) =>
149
+ makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>, any, any>, {
150
+ dbType: postgresDatatypes.jsonb(),
151
+ nullable: false,
152
+ hasDefault: false,
153
+ generated: false,
154
+ primaryKey: false,
155
+ unique: false,
156
+ references: undefined,
157
+ ddlType: undefined,
158
+ identity: undefined
159
+ })
160
+
161
+ export const nullable = BaseColumn.nullable
162
+ export const brand = BaseColumn.brand
163
+ export const primaryKey = BaseColumn.primaryKey
164
+ export const unique = BaseColumn.unique
165
+ const default_ = BaseColumn.default_
166
+ export const generated = BaseColumn.generated
167
+ export const ddlType = BaseColumn.ddlType
168
+ export const array = BaseColumn.array
169
+ export const identityAlways = BaseColumn.identityAlways
170
+ export const identityByDefault = BaseColumn.identityByDefault
171
+ export const foreignKey = BaseColumn.foreignKey
172
+ export const index = BaseColumn.index
173
+ export const references = BaseColumn.references
174
+ export const schema = BaseColumn.schema
175
+ export { default_ as default }
176
+
177
+ export type Any = BaseColumn.Any
178
+ export type AnyBound = BaseColumn.AnyBound