@typesql/drizzle 0.1.0 → 0.1.2
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/CHANGELOG.md +18 -0
- package/README.md +5 -5
- package/dist/from-drizzle.d.ts +1 -1
- package/package.json +22 -4
- package/src/from-drizzle.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @typesql/drizzle
|
|
2
2
|
|
|
3
|
+
## 0.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- npm package pages link to the documentation site and the issue tracker, and list keywords.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies:
|
|
10
|
+
- @typesql/core@0.1.2
|
|
11
|
+
|
|
12
|
+
## 0.1.1
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Docs, package descriptions and error messages spell the project name TypeSQL.
|
|
17
|
+
|
|
18
|
+
- Updated dependencies:
|
|
19
|
+
- @typesql/core@0.1.1
|
|
20
|
+
|
|
3
21
|
## 0.1.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @typesql/drizzle
|
|
2
2
|
|
|
3
|
-
Use your Drizzle ORM schema as a
|
|
3
|
+
Use your Drizzle ORM schema as a TypeSQL schema. `FromDrizzle<typeof schema>` turns
|
|
4
4
|
`pgTable`, `pgView`, `pgMaterializedView`, `pgEnum` and `pgSchema` definitions into the
|
|
5
5
|
`DB` type that `createSql` expects, entirely at the type level: no code generation, and the
|
|
6
6
|
SQL you write is checked against the same tables Drizzle manages.
|
|
@@ -113,7 +113,7 @@ tables (`FromDrizzle<{ users: typeof users; posts: typeof posts }>`).
|
|
|
113
113
|
|
|
114
114
|
## What gets converted
|
|
115
115
|
|
|
116
|
-
| Drizzle |
|
|
116
|
+
| Drizzle | TypeSQL |
|
|
117
117
|
|---|---|
|
|
118
118
|
| `pgTable("users", …)` | `DB["users"]`, keyed by the SQL table name, not the export name |
|
|
119
119
|
| `displayName: text("display_name")` | column `display_name`; columns without an explicit name use the key |
|
|
@@ -128,7 +128,7 @@ tables (`FromDrizzle<{ users: typeof users; posts: typeof posts }>`).
|
|
|
128
128
|
## Column types
|
|
129
129
|
|
|
130
130
|
The Postgres type comes from Drizzle's column kind. Drizzle's `mode` options change the JS
|
|
131
|
-
value Drizzle produces, but
|
|
131
|
+
value Drizzle produces, but TypeSQL queries go straight to the driver, so the row type comes
|
|
132
132
|
from the type map: `bigint({ mode: "number" })` is `int8`, a `string` under node-postgres.
|
|
133
133
|
|
|
134
134
|
| Drizzle | Postgres |
|
|
@@ -157,7 +157,7 @@ from the type map: `bigint({ mode: "number" })` is `int8`, a `string` under node
|
|
|
157
157
|
| `customType(…)` | `unknown`, unless pinned with `pgType` |
|
|
158
158
|
| `.array()`, `.array().array()` | `T[]`, `T[][]` |
|
|
159
159
|
|
|
160
|
-
Types
|
|
160
|
+
Types TypeSQL has no TS mapping for (`geometry`, `vector`, …) read as `unknown` unless your
|
|
161
161
|
type map has an entry for them.
|
|
162
162
|
|
|
163
163
|
### `timestamp` with time zone, and other types Drizzle's types do not record
|
|
@@ -209,7 +209,7 @@ createSql<typeof schema, DefaultTypeMap, { casing: "snake_case" }>(db);
|
|
|
209
209
|
## Limitations
|
|
210
210
|
|
|
211
211
|
- **Generated-always columns** (`generatedAlwaysAs`, `generatedAlwaysAsIdentity`) are treated
|
|
212
|
-
as columns with a default.
|
|
212
|
+
as columns with a default. TypeSQL has no read-only columns, so an `INSERT` that sets one
|
|
213
213
|
type-checks but fails in Postgres (unless `OVERRIDING SYSTEM VALUE` for identities).
|
|
214
214
|
- **`$onUpdate` / `$onUpdateFn`** mark the column as having a default in Drizzle's types, with
|
|
215
215
|
no way to tell them from a SQL default, so such a column is optional in `INSERT` even
|
package/dist/from-drizzle.d.ts
CHANGED
|
@@ -150,7 +150,7 @@ type Flat<T> = {
|
|
|
150
150
|
[K in keyof T]: T[K];
|
|
151
151
|
} & {};
|
|
152
152
|
/**
|
|
153
|
-
* A
|
|
153
|
+
* A TypeSQL schema from Drizzle `pg-core` definitions: `FromDrizzle<typeof schema>` with
|
|
154
154
|
* `import * as schema from "./schema"`. Also accepts a record of tables or a single table.
|
|
155
155
|
*
|
|
156
156
|
* Keys are SQL names (tables, columns, `pgSchema` namespaces); views become `View<…>`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typesql/drizzle",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Use Drizzle ORM table definitions as a
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Use Drizzle ORM table definitions as a TypeSQL schema.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -28,20 +28,38 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@typesql/core": "0.1.
|
|
31
|
+
"@typesql/core": "0.1.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"drizzle-orm": ">=0.45"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/pg": "^8.23.1",
|
|
38
|
-
"@typesql/pg": "0.1.
|
|
38
|
+
"@typesql/pg": "0.1.2",
|
|
39
39
|
"drizzle-orm": "^0.45.4",
|
|
40
40
|
"pg": "^8.23.1",
|
|
41
41
|
"postgres": "^3.4.9",
|
|
42
42
|
"typescript": "7.0.2",
|
|
43
43
|
"vitest": "^5.0.4"
|
|
44
44
|
},
|
|
45
|
+
"homepage": "https://typesql.karsli.net/adapters/drizzle",
|
|
46
|
+
"bugs": {
|
|
47
|
+
"url": "https://github.com/ismailkarsli/typesql/issues"
|
|
48
|
+
},
|
|
49
|
+
"author": "İsmail Karslı",
|
|
50
|
+
"keywords": [
|
|
51
|
+
"sql",
|
|
52
|
+
"postgres",
|
|
53
|
+
"postgresql",
|
|
54
|
+
"typescript",
|
|
55
|
+
"type-safe",
|
|
56
|
+
"type-level",
|
|
57
|
+
"raw-sql",
|
|
58
|
+
"no-codegen",
|
|
59
|
+
"drizzle",
|
|
60
|
+
"drizzle-orm",
|
|
61
|
+
"orm"
|
|
62
|
+
],
|
|
45
63
|
"scripts": {
|
|
46
64
|
"build": "tsc -p tsconfig.build.json",
|
|
47
65
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
package/src/from-drizzle.ts
CHANGED
|
@@ -145,7 +145,7 @@ type Build<S, Opts, E = Enums<S>> =
|
|
|
145
145
|
type Flat<T> = { [K in keyof T]: T[K] } & {};
|
|
146
146
|
|
|
147
147
|
/**
|
|
148
|
-
* A
|
|
148
|
+
* A TypeSQL schema from Drizzle `pg-core` definitions: `FromDrizzle<typeof schema>` with
|
|
149
149
|
* `import * as schema from "./schema"`. Also accepts a record of tables or a single table.
|
|
150
150
|
*
|
|
151
151
|
* Keys are SQL names (tables, columns, `pgSchema` namespaces); views become `View<…>`;
|