@drzl/analyzer 1.17.6 → 1.17.7
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/index.cjs +27 -3
- package/dist/index.js +27 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -106,6 +106,7 @@ function describeV1Column(column) {
|
|
|
106
106
|
const out = {};
|
|
107
107
|
switch (semantic) {
|
|
108
108
|
case "int8":
|
|
109
|
+
case "uint8":
|
|
109
110
|
case "int16":
|
|
110
111
|
case "int24":
|
|
111
112
|
case "int32":
|
|
@@ -122,6 +123,7 @@ function describeV1Column(column) {
|
|
|
122
123
|
}
|
|
123
124
|
const range = {
|
|
124
125
|
int8: ["-128", "127"],
|
|
126
|
+
uint8: ["0", "255"],
|
|
125
127
|
int16: ["-32768", "32767"],
|
|
126
128
|
int24: ["-8388608", "8388607"],
|
|
127
129
|
int32: ["-2147483648", "2147483647"],
|
|
@@ -134,7 +136,7 @@ function describeV1Column(column) {
|
|
|
134
136
|
[out.min, out.max] = range;
|
|
135
137
|
out.integer = true;
|
|
136
138
|
out.tsType = js === "bigint" ? "bigint" : "number";
|
|
137
|
-
out.dbType = semantic === "int8" ? "TINYINT" : semantic === "int16" ? "SMALLINT" : semantic === "int24" ? "MEDIUMINT" : semantic === "int32" ? "INTEGER" : "BIGINT";
|
|
139
|
+
out.dbType = semantic === "int8" || semantic === "uint8" ? "TINYINT" : semantic === "int16" ? "SMALLINT" : semantic === "int24" ? "MEDIUMINT" : semantic === "int32" ? "INTEGER" : "BIGINT";
|
|
138
140
|
break;
|
|
139
141
|
}
|
|
140
142
|
case "year":
|
|
@@ -183,6 +185,16 @@ function describeV1Column(column) {
|
|
|
183
185
|
out.dbType = codec?.startsWith("timestamp") ? "TIMESTAMP" : "DATE";
|
|
184
186
|
break;
|
|
185
187
|
case "timestamp":
|
|
188
|
+
// `datetime` is the same fact under MySQL's name for it, and it had no arm, so every column
|
|
189
|
+
// stating it fell to the bare-string arm and was labelled TEXT. The columns that reach this
|
|
190
|
+
// are the string modes of `datetime` on mssql, mysql and singlestore, plus mssql's
|
|
191
|
+
// `datetime2` and `datetimeoffset`, swept over every builder the six v1 cores export; the
|
|
192
|
+
// `{ mode: 'date' }` half of the same builders states `object date` and takes the arm above.
|
|
193
|
+
// A label only, since `dbType` is read outside this file in exactly one place,
|
|
194
|
+
// `isIntegerColumn`, which the generators consult for a `tsType` of `number`. It matters
|
|
195
|
+
// because the class-name path already answers TIMESTAMP for the same 0.4x column, and the
|
|
196
|
+
// two majors disagreeing about a column is what the cross-major diff exists to catch.
|
|
197
|
+
case "datetime":
|
|
186
198
|
out.tsType = js === "string" ? "string" : "Date";
|
|
187
199
|
out.dbType = "TIMESTAMP";
|
|
188
200
|
break;
|
|
@@ -204,13 +216,25 @@ function describeV1Column(column) {
|
|
|
204
216
|
const entity = String(column?.constructor?.[/* @__PURE__ */ Symbol.for("drizzle:entityKind")] ?? "");
|
|
205
217
|
const bytes = entity.startsWith("MySql") || entity.startsWith("SingleStore");
|
|
206
218
|
out.tsType = "string";
|
|
207
|
-
out.dbType =
|
|
219
|
+
out.dbType = bytes ? "BINARY" : "BIT";
|
|
208
220
|
out.shape = bytes ? { kind: "byteString", length: declaredLength(column) } : {
|
|
209
221
|
kind: "bitstring",
|
|
210
222
|
length: declaredLength(column),
|
|
211
223
|
// A Postgres `bit(3)` holds exactly three digits; a Cockroach `varbit(16)` holds at
|
|
212
224
|
// most that many, which is why `''` is valid there and not here.
|
|
213
|
-
|
|
225
|
+
//
|
|
226
|
+
// `codec === 'bit'` alone was Postgres's answer applied to everything, and Cockroach
|
|
227
|
+
// states no codec, so both of its builders came back `exact: false` and a `bit(3)`
|
|
228
|
+
// was indistinguishable from a `varbit(3)`. Measured on CockroachDB v24.3.5: a
|
|
229
|
+
// `bit(3)` refuses '', '1', '10' and '1011' with "bit string length n does not match
|
|
230
|
+
// type BIT(3)" and takes '101'; a `varbit(8)` takes '', '1' and '10101010' and
|
|
231
|
+
// refuses nine digits with "too large for type VARBIT(8)". `drizzle-orm/zod` at
|
|
232
|
+
// 1.0.0-rc.4 answers the same for both columns.
|
|
233
|
+
//
|
|
234
|
+
// The class rather than a prefix, because `CockroachVarbit` starts with neither
|
|
235
|
+
// `CockroachBit` nor anything else this could key on without catching the varying
|
|
236
|
+
// half too.
|
|
237
|
+
exact: codec === "bit" || entity === "CockroachBit"
|
|
214
238
|
};
|
|
215
239
|
break;
|
|
216
240
|
}
|
package/dist/index.js
CHANGED
|
@@ -65,6 +65,7 @@ function describeV1Column(column) {
|
|
|
65
65
|
const out = {};
|
|
66
66
|
switch (semantic) {
|
|
67
67
|
case "int8":
|
|
68
|
+
case "uint8":
|
|
68
69
|
case "int16":
|
|
69
70
|
case "int24":
|
|
70
71
|
case "int32":
|
|
@@ -81,6 +82,7 @@ function describeV1Column(column) {
|
|
|
81
82
|
}
|
|
82
83
|
const range = {
|
|
83
84
|
int8: ["-128", "127"],
|
|
85
|
+
uint8: ["0", "255"],
|
|
84
86
|
int16: ["-32768", "32767"],
|
|
85
87
|
int24: ["-8388608", "8388607"],
|
|
86
88
|
int32: ["-2147483648", "2147483647"],
|
|
@@ -93,7 +95,7 @@ function describeV1Column(column) {
|
|
|
93
95
|
[out.min, out.max] = range;
|
|
94
96
|
out.integer = true;
|
|
95
97
|
out.tsType = js === "bigint" ? "bigint" : "number";
|
|
96
|
-
out.dbType = semantic === "int8" ? "TINYINT" : semantic === "int16" ? "SMALLINT" : semantic === "int24" ? "MEDIUMINT" : semantic === "int32" ? "INTEGER" : "BIGINT";
|
|
98
|
+
out.dbType = semantic === "int8" || semantic === "uint8" ? "TINYINT" : semantic === "int16" ? "SMALLINT" : semantic === "int24" ? "MEDIUMINT" : semantic === "int32" ? "INTEGER" : "BIGINT";
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
101
|
case "year":
|
|
@@ -142,6 +144,16 @@ function describeV1Column(column) {
|
|
|
142
144
|
out.dbType = codec?.startsWith("timestamp") ? "TIMESTAMP" : "DATE";
|
|
143
145
|
break;
|
|
144
146
|
case "timestamp":
|
|
147
|
+
// `datetime` is the same fact under MySQL's name for it, and it had no arm, so every column
|
|
148
|
+
// stating it fell to the bare-string arm and was labelled TEXT. The columns that reach this
|
|
149
|
+
// are the string modes of `datetime` on mssql, mysql and singlestore, plus mssql's
|
|
150
|
+
// `datetime2` and `datetimeoffset`, swept over every builder the six v1 cores export; the
|
|
151
|
+
// `{ mode: 'date' }` half of the same builders states `object date` and takes the arm above.
|
|
152
|
+
// A label only, since `dbType` is read outside this file in exactly one place,
|
|
153
|
+
// `isIntegerColumn`, which the generators consult for a `tsType` of `number`. It matters
|
|
154
|
+
// because the class-name path already answers TIMESTAMP for the same 0.4x column, and the
|
|
155
|
+
// two majors disagreeing about a column is what the cross-major diff exists to catch.
|
|
156
|
+
case "datetime":
|
|
145
157
|
out.tsType = js === "string" ? "string" : "Date";
|
|
146
158
|
out.dbType = "TIMESTAMP";
|
|
147
159
|
break;
|
|
@@ -163,13 +175,25 @@ function describeV1Column(column) {
|
|
|
163
175
|
const entity = String(column?.constructor?.[/* @__PURE__ */ Symbol.for("drizzle:entityKind")] ?? "");
|
|
164
176
|
const bytes = entity.startsWith("MySql") || entity.startsWith("SingleStore");
|
|
165
177
|
out.tsType = "string";
|
|
166
|
-
out.dbType =
|
|
178
|
+
out.dbType = bytes ? "BINARY" : "BIT";
|
|
167
179
|
out.shape = bytes ? { kind: "byteString", length: declaredLength(column) } : {
|
|
168
180
|
kind: "bitstring",
|
|
169
181
|
length: declaredLength(column),
|
|
170
182
|
// A Postgres `bit(3)` holds exactly three digits; a Cockroach `varbit(16)` holds at
|
|
171
183
|
// most that many, which is why `''` is valid there and not here.
|
|
172
|
-
|
|
184
|
+
//
|
|
185
|
+
// `codec === 'bit'` alone was Postgres's answer applied to everything, and Cockroach
|
|
186
|
+
// states no codec, so both of its builders came back `exact: false` and a `bit(3)`
|
|
187
|
+
// was indistinguishable from a `varbit(3)`. Measured on CockroachDB v24.3.5: a
|
|
188
|
+
// `bit(3)` refuses '', '1', '10' and '1011' with "bit string length n does not match
|
|
189
|
+
// type BIT(3)" and takes '101'; a `varbit(8)` takes '', '1' and '10101010' and
|
|
190
|
+
// refuses nine digits with "too large for type VARBIT(8)". `drizzle-orm/zod` at
|
|
191
|
+
// 1.0.0-rc.4 answers the same for both columns.
|
|
192
|
+
//
|
|
193
|
+
// The class rather than a prefix, because `CockroachVarbit` starts with neither
|
|
194
|
+
// `CockroachBit` nor anything else this could key on without catching the varying
|
|
195
|
+
// half too.
|
|
196
|
+
exact: codec === "bit" || entity === "CockroachBit"
|
|
173
197
|
};
|
|
174
198
|
break;
|
|
175
199
|
}
|