effect-qb 0.14.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.
- package/dist/mysql.js +61270 -4259
- package/dist/postgres/metadata.js +176 -82
- package/dist/postgres.js +5903 -3316
- package/package.json +14 -1
- package/src/internal/aggregation-validation.ts +3 -3
- package/src/internal/case-analysis.d.ts +18 -0
- package/src/internal/case-analysis.ts +4 -4
- package/src/internal/coercion/analysis.d.ts +7 -0
- package/src/internal/{coercion-analysis.ts → coercion/analysis.ts} +3 -3
- package/src/internal/coercion/errors.d.ts +17 -0
- package/src/internal/{coercion-errors.ts → coercion/errors.ts} +1 -1
- package/src/internal/coercion/kind.d.ts +4 -0
- package/src/internal/{coercion-kind.ts → coercion/kind.ts} +2 -2
- package/src/internal/{coercion-normalize.ts → coercion/normalize.ts} +1 -1
- package/src/internal/coercion/rules.d.ts +6 -0
- package/src/internal/{coercion-rules.ts → coercion/rules.ts} +2 -2
- package/src/internal/column-state.d.ts +190 -0
- package/src/internal/column-state.ts +36 -47
- package/src/internal/column.ts +21 -305
- package/src/internal/datatypes/define.d.ts +17 -0
- package/src/internal/datatypes/define.ts +18 -4
- package/src/internal/datatypes/lookup.d.ts +44 -0
- package/src/internal/datatypes/lookup.ts +61 -152
- package/src/internal/datatypes/shape.d.ts +16 -0
- package/src/internal/datatypes/shape.ts +1 -1
- package/src/internal/derived-table.d.ts +4 -0
- package/src/internal/derived-table.ts +21 -16
- package/src/internal/dsl-mutation-runtime.ts +378 -0
- package/src/internal/dsl-plan-runtime.ts +387 -0
- package/src/internal/dsl-query-runtime.ts +160 -0
- package/src/internal/dsl-transaction-ddl-runtime.ts +263 -0
- package/src/internal/executor.ts +132 -31
- package/src/internal/expression-ast.ts +15 -5
- package/src/internal/grouping-key.d.ts +3 -0
- package/src/internal/grouping-key.ts +1 -1
- package/src/internal/implication-runtime.d.ts +15 -0
- package/src/internal/implication-runtime.ts +4 -4
- package/src/internal/json/ast.d.ts +30 -0
- package/src/internal/json/ast.ts +1 -1
- package/src/internal/json/errors.d.ts +8 -0
- package/src/internal/json/path.d.ts +75 -0
- package/src/internal/json/path.ts +1 -1
- package/src/internal/json/types.d.ts +62 -0
- package/src/internal/predicate/analysis.d.ts +20 -0
- package/src/internal/{predicate-analysis.ts → predicate/analysis.ts} +3 -3
- package/src/internal/predicate/atom.d.ts +28 -0
- package/src/internal/{predicate-branches.ts → predicate/branches.ts} +2 -2
- package/src/internal/predicate/context.d.ts +67 -0
- package/src/internal/{predicate-context.ts → predicate/context.ts} +8 -5
- package/src/internal/predicate/formula.d.ts +35 -0
- package/src/internal/{predicate-formula.ts → predicate/formula.ts} +1 -1
- package/src/internal/predicate/key.d.ts +11 -0
- package/src/internal/{predicate-key.ts → predicate/key.ts} +2 -2
- package/src/internal/{predicate-nnf.ts → predicate/nnf.ts} +2 -2
- package/src/internal/predicate/normalize.d.ts +53 -0
- package/src/internal/{predicate-normalize.ts → predicate/normalize.ts} +19 -19
- package/src/internal/predicate/runtime.d.ts +31 -0
- package/src/internal/{predicate-runtime.ts → predicate/runtime.ts} +9 -6
- package/src/internal/projection-alias.d.ts +13 -0
- package/src/internal/projections.d.ts +31 -0
- package/src/internal/projections.ts +1 -1
- package/src/internal/query-ast.d.ts +217 -0
- package/src/internal/query-ast.ts +1 -1
- package/src/internal/query-requirements.d.ts +20 -0
- package/src/internal/query.d.ts +775 -0
- package/src/internal/query.ts +389 -313
- package/src/internal/renderer.ts +7 -21
- package/src/internal/row-set.d.ts +53 -0
- package/src/internal/{plan.ts → row-set.ts} +11 -9
- package/src/internal/{runtime-normalize.ts → runtime/normalize.ts} +9 -31
- package/src/internal/{runtime-schema.ts → runtime/schema.ts} +13 -38
- package/src/internal/runtime/value.d.ts +22 -0
- package/src/internal/{runtime-value.ts → runtime/value.ts} +2 -2
- package/src/internal/scalar.d.ts +107 -0
- package/src/internal/scalar.ts +191 -0
- package/src/internal/schema-derivation.d.ts +105 -0
- package/src/internal/schema-expression.d.ts +18 -0
- package/src/internal/schema-expression.ts +38 -7
- package/src/internal/table-options.d.ts +94 -0
- package/src/internal/table-options.ts +8 -2
- package/src/internal/table.d.ts +173 -0
- package/src/internal/table.ts +32 -14
- package/src/mysql/column.ts +94 -18
- package/src/mysql/datatypes/index.ts +47 -7
- package/src/mysql/errors/generated.ts +57336 -0
- package/src/mysql/errors/index.ts +1 -0
- package/src/mysql/errors/normalize.ts +55 -53
- package/src/mysql/errors/types.ts +74 -0
- package/src/mysql/executor.ts +69 -7
- package/src/mysql/function/aggregate.ts +1 -5
- package/src/mysql/function/core.ts +1 -4
- package/src/mysql/function/index.ts +0 -1
- package/src/mysql/function/string.ts +1 -5
- package/src/mysql/function/temporal.ts +12 -15
- package/src/mysql/function/window.ts +1 -6
- package/src/{internal/mysql-dialect.ts → mysql/internal/dialect.ts} +1 -1
- package/src/{internal/mysql-query.ts → mysql/internal/dsl.ts} +1024 -2082
- package/src/{internal/mysql-renderer.ts → mysql/internal/renderer.ts} +6 -6
- package/src/mysql/internal/sql-expression-renderer.ts +1455 -0
- package/src/mysql/json.ts +2 -0
- package/src/mysql/query.ts +111 -91
- package/src/mysql/renderer.ts +1 -1
- package/src/mysql/table.ts +1 -1
- package/src/mysql.ts +6 -4
- package/src/postgres/cast.ts +11 -12
- package/src/postgres/column.ts +178 -46
- package/src/postgres/datatypes/index.d.ts +515 -0
- package/src/postgres/datatypes/index.ts +22 -13
- package/src/postgres/datatypes/spec.d.ts +412 -0
- package/src/postgres/errors/generated.ts +2636 -0
- package/src/postgres/errors/index.ts +1 -0
- package/src/postgres/errors/normalize.ts +47 -62
- package/src/postgres/errors/types.ts +92 -34
- package/src/postgres/executor.ts +37 -5
- package/src/postgres/function/aggregate.ts +1 -5
- package/src/postgres/function/core.ts +12 -6
- package/src/postgres/function/index.ts +0 -1
- package/src/postgres/function/string.ts +1 -5
- package/src/postgres/function/temporal.ts +12 -15
- package/src/postgres/function/window.ts +1 -6
- package/src/{internal/postgres-dialect.ts → postgres/internal/dialect.ts} +1 -1
- package/src/{internal/postgres-query.ts → postgres/internal/dsl.ts} +1085 -2089
- package/src/{internal/postgres-renderer.ts → postgres/internal/renderer.ts} +6 -6
- package/src/postgres/internal/schema-ddl.ts +108 -0
- package/src/{internal/postgres-schema-model.ts → postgres/internal/schema-model.ts} +12 -6
- package/src/{internal → postgres/internal}/sql-expression-renderer.ts +19 -17
- package/src/postgres/{function/json.ts → json.ts} +77 -85
- package/src/postgres/metadata.ts +2 -2
- package/src/postgres/query.ts +113 -89
- package/src/postgres/renderer.ts +3 -13
- package/src/postgres/schema-expression.ts +2 -1
- package/src/postgres/schema-management.ts +1 -1
- package/src/postgres/table.ts +12 -4
- package/src/postgres/type.ts +29 -2
- package/src/postgres.ts +6 -4
- package/src/internal/expression.ts +0 -327
- package/src/internal/schema-ddl.ts +0 -55
- package/src/mysql/function/json.ts +0 -4
- package/src/mysql/private/query.ts +0 -1
- package/src/postgres/private/query.ts +0 -1
- /package/src/internal/{predicate-atom.ts → predicate/atom.ts} +0 -0
package/src/mysql/column.ts
CHANGED
|
@@ -1,22 +1,98 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema"
|
|
2
|
+
|
|
1
3
|
import * as BaseColumn from "../internal/column.js"
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
4
|
+
import { makeColumnDefinition, type ColumnDefinition } from "../internal/column-state.js"
|
|
5
|
+
import type * as Expression from "../internal/scalar.js"
|
|
6
|
+
import {
|
|
7
|
+
DecimalStringSchema,
|
|
8
|
+
LocalDateStringSchema,
|
|
9
|
+
LocalDateTimeStringSchema,
|
|
10
|
+
type DecimalString,
|
|
11
|
+
type LocalDateString,
|
|
12
|
+
type LocalDateTimeString
|
|
13
|
+
} from "../internal/runtime/value.js"
|
|
14
|
+
import { mysqlDatatypes } from "./datatypes/index.js"
|
|
15
|
+
|
|
16
|
+
const enrichDbType = <Db extends Expression.DbType.Any>(dbType: Db): Db => {
|
|
17
|
+
const candidate = (mysqlDatatypes as unknown as Record<string, (() => Expression.DbType.Any) | undefined>)[dbType.kind]
|
|
18
|
+
return typeof candidate === "function"
|
|
19
|
+
? { ...candidate(), ...dbType } as Db
|
|
20
|
+
: dbType
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const primitive = <Type, Db extends Expression.DbType.Any>(
|
|
24
|
+
schema: Schema.Schema<Type, any, any>,
|
|
25
|
+
dbType: Db
|
|
26
|
+
): ColumnDefinition<Type, Type, Type, Db, false, false, false, false, false, undefined> =>
|
|
27
|
+
makeColumnDefinition(schema as Schema.Schema<NonNullable<Type>>, {
|
|
28
|
+
dbType,
|
|
29
|
+
nullable: false,
|
|
30
|
+
hasDefault: false,
|
|
31
|
+
generated: false,
|
|
32
|
+
primaryKey: false,
|
|
33
|
+
unique: false,
|
|
34
|
+
references: undefined
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
const renderNumericDdlType = (
|
|
38
|
+
kind: string,
|
|
39
|
+
options?: BaseColumn.NumericOptions
|
|
40
|
+
): string | undefined => {
|
|
41
|
+
if (options === undefined || options.precision === undefined) {
|
|
42
|
+
return undefined
|
|
43
|
+
}
|
|
44
|
+
return options.scale === undefined
|
|
45
|
+
? `${kind}(${options.precision})`
|
|
46
|
+
: `${kind}(${options.precision},${options.scale})`
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const custom = <SchemaType extends Schema.Schema.Any, Db extends Expression.DbType.Any>(
|
|
50
|
+
schema: SchemaType,
|
|
51
|
+
dbType: Db
|
|
52
|
+
) =>
|
|
53
|
+
makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>, any, any>, {
|
|
54
|
+
dbType: enrichDbType(dbType),
|
|
55
|
+
nullable: false,
|
|
56
|
+
hasDefault: false,
|
|
57
|
+
generated: false,
|
|
58
|
+
primaryKey: false,
|
|
59
|
+
unique: false,
|
|
60
|
+
references: undefined,
|
|
61
|
+
ddlType: undefined,
|
|
62
|
+
identity: undefined
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
export const uuid = () => primitive(Schema.UUID, mysqlDatatypes.uuid())
|
|
66
|
+
export const text = () => primitive(Schema.String, mysqlDatatypes.text())
|
|
67
|
+
export const int = () => primitive(Schema.Int, mysqlDatatypes.int())
|
|
68
|
+
export const number = (options?: BaseColumn.NumericOptions) =>
|
|
69
|
+
makeColumnDefinition(DecimalStringSchema, {
|
|
70
|
+
dbType: mysqlDatatypes.decimal(),
|
|
71
|
+
nullable: false,
|
|
72
|
+
hasDefault: false,
|
|
73
|
+
generated: false,
|
|
74
|
+
primaryKey: false,
|
|
75
|
+
unique: false,
|
|
76
|
+
references: undefined,
|
|
77
|
+
ddlType: renderNumericDdlType("decimal", options),
|
|
78
|
+
identity: undefined
|
|
79
|
+
})
|
|
80
|
+
export const boolean = () => primitive(Schema.Boolean, mysqlDatatypes.boolean())
|
|
81
|
+
export const date = () => primitive(LocalDateStringSchema, mysqlDatatypes.date())
|
|
82
|
+
export const datetime = () => primitive(LocalDateTimeStringSchema, mysqlDatatypes.datetime())
|
|
83
|
+
export const timestamp = () => primitive(LocalDateTimeStringSchema, mysqlDatatypes.timestamp())
|
|
84
|
+
export const json = <SchemaType extends Schema.Schema.Any>(schema: SchemaType) =>
|
|
85
|
+
makeColumnDefinition(schema as unknown as Schema.Schema<NonNullable<Schema.Schema.Type<SchemaType>>, any, any>, {
|
|
86
|
+
dbType: { ...mysqlDatatypes.json(), variant: "json" } as Expression.DbType.Json<"mysql", "json">,
|
|
87
|
+
nullable: false,
|
|
88
|
+
hasDefault: false,
|
|
89
|
+
generated: false,
|
|
90
|
+
primaryKey: false,
|
|
91
|
+
unique: false,
|
|
92
|
+
references: undefined,
|
|
93
|
+
ddlType: undefined,
|
|
94
|
+
identity: undefined
|
|
95
|
+
})
|
|
20
96
|
|
|
21
97
|
export const nullable = BaseColumn.nullable
|
|
22
98
|
export const brand = BaseColumn.brand
|
|
@@ -1,21 +1,61 @@
|
|
|
1
1
|
import type { DatatypeModule } from "../../internal/datatypes/define.js"
|
|
2
|
-
import type * as Expression from "../../internal/
|
|
3
|
-
import { mysqlDatatypeKinds } from "./spec.js"
|
|
2
|
+
import type * as Expression from "../../internal/scalar.js"
|
|
3
|
+
import { mysqlDatatypeFamilies, mysqlDatatypeKinds } from "./spec.js"
|
|
4
|
+
|
|
5
|
+
const withMetadata = <Kind extends keyof typeof mysqlDatatypeKinds & string>(
|
|
6
|
+
kind: Kind
|
|
7
|
+
): Expression.DbType.Base<"mysql", Kind> => {
|
|
8
|
+
const kindSpec = mysqlDatatypeKinds[kind]
|
|
9
|
+
const familySpec = mysqlDatatypeFamilies[kindSpec.family as keyof typeof mysqlDatatypeFamilies]
|
|
10
|
+
return {
|
|
11
|
+
dialect: "mysql",
|
|
12
|
+
kind,
|
|
13
|
+
family: kindSpec.family,
|
|
14
|
+
runtime: kindSpec.runtime,
|
|
15
|
+
compareGroup: familySpec?.compareGroup,
|
|
16
|
+
castTargets: familySpec?.castTargets,
|
|
17
|
+
traits: familySpec?.traits
|
|
18
|
+
}
|
|
19
|
+
}
|
|
4
20
|
|
|
5
21
|
const mysqlDatatypeModule = {
|
|
6
22
|
custom: (kind: string) => ({
|
|
7
23
|
dialect: "mysql",
|
|
8
24
|
kind
|
|
25
|
+
}),
|
|
26
|
+
uuid: () => ({
|
|
27
|
+
dialect: "mysql",
|
|
28
|
+
kind: "uuid",
|
|
29
|
+
family: "uuid",
|
|
30
|
+
runtime: "string",
|
|
31
|
+
compareGroup: "uuid",
|
|
32
|
+
castTargets: ["uuid", "char", "varchar", "text"],
|
|
33
|
+
traits: {
|
|
34
|
+
textual: true
|
|
35
|
+
}
|
|
9
36
|
})
|
|
10
37
|
} as Record<string, (...args: readonly any[]) => Expression.DbType.Base<"mysql", string>>
|
|
11
38
|
|
|
12
39
|
for (const kind of Object.keys(mysqlDatatypeKinds)) {
|
|
13
|
-
mysqlDatatypeModule[kind] = () => (
|
|
14
|
-
dialect: "mysql",
|
|
15
|
-
kind
|
|
16
|
-
})
|
|
40
|
+
mysqlDatatypeModule[kind] = () => withMetadata(kind as keyof typeof mysqlDatatypeKinds & string)
|
|
17
41
|
}
|
|
18
42
|
|
|
19
|
-
|
|
43
|
+
type MysqlUuidWitness = Expression.DbType.Base<"mysql", "uuid"> & {
|
|
44
|
+
readonly family: "uuid"
|
|
45
|
+
readonly runtime: "string"
|
|
46
|
+
readonly compareGroup: "uuid"
|
|
47
|
+
readonly castTargets: readonly ["uuid", "char", "varchar", "text"]
|
|
48
|
+
readonly traits: {
|
|
49
|
+
readonly textual: true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const mysqlDatatypes = mysqlDatatypeModule as DatatypeModule<
|
|
54
|
+
"mysql",
|
|
55
|
+
typeof mysqlDatatypeKinds,
|
|
56
|
+
typeof mysqlDatatypeFamilies
|
|
57
|
+
> & {
|
|
58
|
+
readonly uuid: () => MysqlUuidWitness
|
|
59
|
+
}
|
|
20
60
|
|
|
21
61
|
export type MysqlDatatypeModule = typeof mysqlDatatypes
|