effect-qb 4.0.0-beta.66 → 4.0.0-beta.98
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 +5 -2
- package/dist/index.js +9376 -0
- package/dist/mysql.js +3921 -2573
- package/dist/postgres/metadata.js +2491 -1373
- package/dist/postgres.js +5453 -5155
- package/dist/sqlite.js +6895 -5529
- package/dist/standard.js +9330 -0
- package/package.json +9 -2
- package/src/casing.ts +71 -0
- package/src/index.ts +2 -0
- package/src/internal/casing.ts +89 -0
- package/src/internal/coercion/rules.ts +13 -1
- package/src/internal/column-state.ts +21 -15
- package/src/internal/column.ts +44 -7
- package/src/internal/datatypes/define.ts +7 -1
- package/src/internal/datatypes/enrich.ts +23 -0
- package/src/internal/datatypes/lookup.ts +81 -25
- package/src/internal/datatypes/matrix.ts +903 -0
- package/src/internal/datatypes/shape.ts +2 -0
- package/src/internal/derived-table.ts +4 -36
- package/src/{mysql/internal/sql-expression-renderer.ts → internal/dialect-renderers/mysql.ts} +552 -361
- package/src/{postgres/internal/sql-expression-renderer.ts → internal/dialect-renderers/postgres.ts} +657 -400
- package/src/{sqlite/internal/sql-expression-renderer.ts → internal/dialect-renderers/sqlite.ts} +505 -347
- package/src/internal/dialect.ts +35 -0
- package/src/internal/dsl-mutation-runtime.ts +12 -162
- package/src/internal/dsl-plan-runtime.ts +10 -138
- package/src/internal/dsl-query-runtime.ts +5 -79
- package/src/internal/dsl-transaction-ddl-runtime.ts +41 -65
- package/src/internal/executor.ts +14 -16
- package/src/internal/grouping-key.ts +87 -20
- package/src/internal/implication-runtime.ts +1 -1
- package/src/internal/json/path-access.ts +351 -0
- package/src/internal/predicate/runtime.ts +3 -0
- package/src/internal/query.d.ts +38 -11
- package/src/internal/query.ts +64 -25
- package/src/internal/renderer.ts +26 -14
- package/src/internal/runtime/normalize.ts +12 -5
- package/src/internal/scalar.ts +7 -1
- package/src/internal/schema-derivation.d.ts +7 -7
- package/src/internal/schema-derivation.ts +9 -9
- package/src/internal/schema-expression.ts +2 -2
- package/src/internal/sql-expression-renderer.ts +19 -0
- package/src/internal/standard-dsl.ts +6978 -0
- package/src/internal/table-options.ts +126 -66
- package/src/internal/table.ts +652 -219
- package/src/mysql/column-extension.ts +3 -0
- package/src/mysql/column.ts +8 -9
- package/src/mysql/datatypes/index.ts +4 -2
- package/src/mysql/datatypes/spec.ts +6 -176
- package/src/mysql/errors/normalize.ts +0 -1
- package/src/mysql/executor.ts +7 -7
- package/src/mysql/internal/dialect.ts +9 -4
- package/src/mysql/internal/dsl.ts +312 -154
- package/src/mysql/internal/renderer.ts +6 -2
- package/src/mysql/json.ts +7 -2
- package/src/mysql/query-extension.ts +16 -0
- package/src/mysql/renderer.ts +37 -3
- package/src/mysql/type.ts +60 -0
- package/src/mysql.ts +7 -13
- package/src/postgres/check.ts +1 -0
- package/src/postgres/column-extension.ts +28 -0
- package/src/postgres/column.ts +2 -8
- package/src/postgres/datatypes/index.d.ts +2 -1
- package/src/postgres/datatypes/index.ts +4 -2
- package/src/postgres/datatypes/spec.ts +6 -260
- package/src/postgres/errors/normalize.ts +0 -1
- package/src/postgres/executor.ts +7 -7
- package/src/postgres/foreign-key.ts +24 -0
- package/src/postgres/function/core.ts +1 -3
- package/src/postgres/function/index.ts +1 -17
- package/src/postgres/index.ts +1 -0
- package/src/postgres/internal/dialect.ts +9 -4
- package/src/postgres/internal/dsl.ts +306 -163
- package/src/postgres/internal/renderer.ts +6 -2
- package/src/postgres/internal/schema-ddl.ts +22 -10
- package/src/postgres/internal/schema-model.ts +238 -7
- package/src/postgres/json-extension.ts +7 -0
- package/src/postgres/json.ts +762 -173
- package/src/postgres/jsonb.ts +37 -0
- package/src/postgres/primary-key.ts +24 -0
- package/src/postgres/query-extension.ts +2 -0
- package/src/postgres/renderer.ts +37 -3
- package/src/postgres/schema-management.ts +12 -11
- package/src/postgres/schema.ts +106 -15
- package/src/postgres/table.ts +205 -530
- package/src/postgres/type.ts +93 -10
- package/src/postgres/unique.ts +32 -0
- package/src/postgres.ts +20 -16
- package/src/sqlite/column-extension.ts +3 -0
- package/src/sqlite/column.ts +8 -9
- package/src/sqlite/datatypes/index.ts +4 -2
- package/src/sqlite/datatypes/spec.ts +6 -94
- package/src/sqlite/errors/normalize.ts +0 -1
- package/src/sqlite/executor.ts +7 -7
- package/src/sqlite/internal/dialect.ts +9 -4
- package/src/sqlite/internal/dsl.ts +301 -154
- package/src/sqlite/internal/renderer.ts +6 -2
- package/src/sqlite/json.ts +8 -2
- package/src/sqlite/query-extension.ts +2 -0
- package/src/sqlite/renderer.ts +37 -3
- package/src/sqlite/type.ts +40 -0
- package/src/sqlite.ts +7 -13
- package/src/standard/cast.ts +113 -0
- package/src/standard/check.ts +17 -0
- package/src/standard/column.ts +163 -0
- package/src/standard/datatypes/index.ts +83 -0
- package/src/standard/datatypes/spec.ts +12 -0
- package/src/standard/dialect.ts +40 -0
- package/src/standard/foreign-key.ts +37 -0
- package/src/standard/function/aggregate.ts +2 -0
- package/src/standard/function/core.ts +2 -0
- package/src/standard/function/index.ts +18 -0
- package/src/standard/function/string.ts +2 -0
- package/src/standard/function/temporal.ts +78 -0
- package/src/standard/function/window.ts +2 -0
- package/src/standard/index.ts +17 -0
- package/src/standard/internal/renderer.ts +45 -0
- package/src/standard/json.ts +883 -0
- package/src/standard/primary-key.ts +17 -0
- package/src/standard/query.ts +152 -0
- package/src/standard/renderer.ts +49 -0
- package/src/standard/table.ts +151 -0
- package/src/standard/unique.ts +17 -0
- package/src/standard.ts +32 -0
- package/src/internal/aggregation-validation.ts +0 -57
- package/src/internal/table.d.ts +0 -180
- package/src/mysql/table.ts +0 -186
- package/src/postgres/cast.ts +0 -45
- package/src/sqlite/table.ts +0 -175
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as BaseTable from "../internal/table.js"
|
|
2
|
+
import type { TableOptionSpec } from "../internal/table-options.js"
|
|
3
|
+
|
|
4
|
+
type ForeignKeySpec = Extract<TableOptionSpec, { readonly kind: "foreignKey" }>
|
|
5
|
+
|
|
6
|
+
export const deferrable = <Spec extends ForeignKeySpec, TableContext extends BaseTable.TableDefinition<any, any, any, "schema", any>>(
|
|
7
|
+
option: BaseTable.TableOption<Spec, TableContext>
|
|
8
|
+
): BaseTable.TableOption<Spec & { readonly deferrable: true }, TableContext> =>
|
|
9
|
+
BaseTable.mapOption(option, (spec) => ({
|
|
10
|
+
...spec,
|
|
11
|
+
deferrable: true
|
|
12
|
+
} as Spec & { readonly deferrable: true }))
|
|
13
|
+
|
|
14
|
+
export const initiallyDeferred = <Spec extends ForeignKeySpec, TableContext extends BaseTable.TableDefinition<any, any, any, "schema", any>>(
|
|
15
|
+
option: BaseTable.TableOption<Spec, TableContext>
|
|
16
|
+
): BaseTable.TableOption<Spec & {
|
|
17
|
+
readonly deferrable: true
|
|
18
|
+
readonly initiallyDeferred: true
|
|
19
|
+
}, TableContext> =>
|
|
20
|
+
BaseTable.mapOption(option, (spec) => ({
|
|
21
|
+
...spec,
|
|
22
|
+
deferrable: true,
|
|
23
|
+
initiallyDeferred: true
|
|
24
|
+
} as Spec & { readonly deferrable: true; readonly initiallyDeferred: true }))
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { ExpressionInput } from "../query.js"
|
|
2
2
|
import {
|
|
3
|
-
call,
|
|
4
3
|
cast,
|
|
5
|
-
coalesce,
|
|
6
4
|
literal,
|
|
7
5
|
nextVal as nextValInternal,
|
|
8
6
|
type as postgresType,
|
|
@@ -11,7 +9,7 @@ import {
|
|
|
11
9
|
import { isSequenceDefinition, type SequenceDefinition } from "../schema-management.js"
|
|
12
10
|
|
|
13
11
|
/** Postgres scalar core functions. */
|
|
14
|
-
export {
|
|
12
|
+
export { uuidGenerateV4 }
|
|
15
13
|
|
|
16
14
|
const safeUnquotedIdentifier = /^[a-z_][a-z0-9_$]*$/
|
|
17
15
|
|
|
@@ -1,19 +1,3 @@
|
|
|
1
1
|
export * as core from "./core.js"
|
|
2
|
-
export * as string from "./string.js"
|
|
3
|
-
export * as aggregate from "./aggregate.js"
|
|
4
|
-
export * as window from "./window.js"
|
|
5
|
-
export * as temporal from "./temporal.js"
|
|
6
2
|
|
|
7
|
-
export {
|
|
8
|
-
export { call, uuidGenerateV4, nextVal } from "./core.js"
|
|
9
|
-
export { lower, upper, concat } from "./string.js"
|
|
10
|
-
export { count, max, min } from "./aggregate.js"
|
|
11
|
-
export { over, rowNumber, rank, denseRank } from "./window.js"
|
|
12
|
-
export {
|
|
13
|
-
currentDate,
|
|
14
|
-
currentTime,
|
|
15
|
-
currentTimestamp,
|
|
16
|
-
localTime,
|
|
17
|
-
localTimestamp,
|
|
18
|
-
now
|
|
19
|
-
} from "./temporal.js"
|
|
3
|
+
export { uuidGenerateV4, nextVal } from "./core.js"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { include, key, keys, uniqueIndex, using, where } from "./table.js"
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { quoteDoubleQuotedIdentifier, type RenderState, type RenderValueContext, type SqlDialect } from "../../internal/dialect.js"
|
|
2
|
+
import { renderExpression, renderQueryAst } from "../../internal/dialect-renderers/postgres.js"
|
|
2
3
|
import { toDriverValue } from "../../internal/runtime/driver-value-mapping.js"
|
|
4
|
+
import { standardDialect } from "../../standard/dialect.js"
|
|
3
5
|
|
|
4
|
-
const quoteIdentifier =
|
|
6
|
+
const quoteIdentifier = quoteDoubleQuotedIdentifier
|
|
5
7
|
|
|
6
8
|
const renderLiteral = (value: unknown, state: RenderState, context: RenderValueContext = {}): string => {
|
|
7
9
|
const driverValue = toDriverValue(value, {
|
|
@@ -23,11 +25,12 @@ const renderLiteral = (value: unknown, state: RenderState, context: RenderValueC
|
|
|
23
25
|
* Built-in runtime dialect implementation for Postgres.
|
|
24
26
|
*/
|
|
25
27
|
export const postgresDialect: SqlDialect<"postgres"> = {
|
|
28
|
+
...standardDialect,
|
|
26
29
|
name: "postgres",
|
|
27
30
|
quoteIdentifier,
|
|
28
31
|
renderLiteral,
|
|
29
32
|
renderTableReference(tableName, baseTableName, schemaName) {
|
|
30
|
-
const renderedBase = schemaName
|
|
33
|
+
const renderedBase = schemaName && schemaName !== "public"
|
|
31
34
|
? `${quoteIdentifier(schemaName)}.${quoteIdentifier(baseTableName)}`
|
|
32
35
|
: quoteIdentifier(baseTableName)
|
|
33
36
|
return tableName === baseTableName
|
|
@@ -36,5 +39,7 @@ export const postgresDialect: SqlDialect<"postgres"> = {
|
|
|
36
39
|
},
|
|
37
40
|
renderConcat(values) {
|
|
38
41
|
return `(${values.join(" || ")})`
|
|
39
|
-
}
|
|
42
|
+
},
|
|
43
|
+
renderQueryAst,
|
|
44
|
+
renderExpression
|
|
40
45
|
}
|