@drzl/analyzer 1.17.3 → 1.17.5
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 +61 -1
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +61 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -87,6 +87,7 @@ var BYTE_STRING_CLASSES = /* @__PURE__ */ new Set([
|
|
|
87
87
|
"SingleStoreBinary",
|
|
88
88
|
"SingleStoreVarBinary"
|
|
89
89
|
]);
|
|
90
|
+
var BUFFER_CLASSES = /* @__PURE__ */ new Set(["SQLiteBlobBuffer"]);
|
|
90
91
|
function describeV1Column(column) {
|
|
91
92
|
const codec = column?.codec;
|
|
92
93
|
const dataType = column?.dataType;
|
|
@@ -141,6 +142,10 @@ function describeV1Column(column) {
|
|
|
141
142
|
out.integer = false;
|
|
142
143
|
out.tsType = "number";
|
|
143
144
|
out.dbType = semantic === "float" ? "REAL" : "DOUBLE";
|
|
145
|
+
if (codec === "float4" || codec === "float8") {
|
|
146
|
+
out.allowsNaN = true;
|
|
147
|
+
out.allowsInfinity = true;
|
|
148
|
+
}
|
|
144
149
|
break;
|
|
145
150
|
}
|
|
146
151
|
case "uuid":
|
|
@@ -250,6 +255,10 @@ function describeV1Column(column) {
|
|
|
250
255
|
out.dbType = "NUMERIC";
|
|
251
256
|
out.integer = false;
|
|
252
257
|
[out.min, out.max] = JS_SAFE_INTEGER_BOUNDS;
|
|
258
|
+
if (codec === "numeric:number") {
|
|
259
|
+
out.allowsNaN = true;
|
|
260
|
+
out.allowsInfinity = false;
|
|
261
|
+
}
|
|
253
262
|
} else if (js === "string") {
|
|
254
263
|
out.tsType = "string";
|
|
255
264
|
out.dbType = codec === "varchar" ? "VARCHAR" : codec === "char" ? "CHAR" : "TEXT";
|
|
@@ -569,6 +578,11 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
569
578
|
if (inexact) [out.min, out.max] = inexact;
|
|
570
579
|
out.integer = false;
|
|
571
580
|
}
|
|
581
|
+
const nonFinite = _SchemaAnalyzer.PG_NON_FINITE[ctor];
|
|
582
|
+
if (nonFinite) {
|
|
583
|
+
out.allowsNaN = nonFinite.nan;
|
|
584
|
+
out.allowsInfinity = nonFinite.infinity;
|
|
585
|
+
}
|
|
572
586
|
if (/^(Pg)?UUID$/i.test(ctor) || /Uuid$/i.test(ctor)) out.format = "uuid";
|
|
573
587
|
return out;
|
|
574
588
|
}
|
|
@@ -580,12 +594,36 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
580
594
|
tsType: column?.config?.mode === "timestamp" ? "Date" : "number",
|
|
581
595
|
dbType: "INTEGER"
|
|
582
596
|
};
|
|
597
|
+
// Both timestamp modes of `integer()`, which are one class and one type. `timestamp` and
|
|
598
|
+
// `timestamp_ms` differ in the scale of the number on the wire, seconds against
|
|
599
|
+
// milliseconds, and `mapFromDriverValue` consumes that difference and hands back a `Date`
|
|
600
|
+
// either way; nothing downstream of the analyzer ever sees the integer. So an arm keyed on
|
|
601
|
+
// the class covers both, where the mode check that used to answer this fell through the
|
|
602
|
+
// switch to a default arm testing `config.mode === 'timestamp'` and named only the first.
|
|
603
|
+
// The second came back `unknown`, and every generator emitted a schema accepting anything.
|
|
604
|
+
//
|
|
605
|
+
// `DATE` rather than the `INTEGER` that mode check returned, so the two majors describe the
|
|
606
|
+
// column identically. `dbType` is read in exactly one place outside this file,
|
|
607
|
+
// `isIntegerColumn`, which the generators consult only for a `tsType` of `number`, so the
|
|
608
|
+
// relabel reaches no output. Measured rather than argued: emitting a `Date` column under
|
|
609
|
+
// both labels, nullable and not, through all five generators gives ten byte-identical pairs.
|
|
610
|
+
case "SQLiteTimestamp":
|
|
611
|
+
return { tsType: "Date", dbType: "DATE" };
|
|
583
612
|
case "SQLiteText":
|
|
584
613
|
return { tsType: "string", dbType: "TEXT" };
|
|
585
614
|
case "SQLiteReal":
|
|
586
615
|
return { tsType: "number", dbType: "REAL" };
|
|
616
|
+
// No 0.4x column is a `SQLiteBlob`: `sqlite-core` builds a `SQLiteBlobBuffer`, a
|
|
617
|
+
// `SQLiteBlobJson` or a `SQLiteBigInt`, one per mode, and exports no class of this name at
|
|
618
|
+
// all. The arm answers the hand-built column in sqlite-types.spec.ts and nothing drizzle
|
|
619
|
+
// produces, which is why a real `blob()` reached neither it nor anything else.
|
|
587
620
|
case "SQLiteBlob":
|
|
588
621
|
return { tsType: "Uint8Array", dbType: "BLOB" };
|
|
622
|
+
// The class a real `blob()` and `blob({ mode: 'buffer' })` both build. See `BUFFER_CLASSES`
|
|
623
|
+
// for the measurement; the answers here are v1's own for the same column, so this is the
|
|
624
|
+
// two majors agreeing rather than a new opinion.
|
|
625
|
+
case "SQLiteBlobBuffer":
|
|
626
|
+
return { tsType: "Buffer", dbType: "BYTEA" };
|
|
589
627
|
// SQLite spells a mode as a distinct class rather than as config, so `text({mode:'json'})`
|
|
590
628
|
// is a `SQLiteTextJson` and matched no arm at all: the column came back UNKNOWN, which is
|
|
591
629
|
// wider than the `any` a json column at least used to get.
|
|
@@ -867,7 +905,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
867
905
|
const sqlType = sqlKind.startsWith("MySql") && typeof col?.getSQLType === "function" ? String(col.getSQLType()).toLowerCase() : void 0;
|
|
868
906
|
const byteCap = sqlType ? MYSQL_TEXT_CAPS[sqlType] : void 0;
|
|
869
907
|
const ctorName = String(col?.constructor?.name ?? "");
|
|
870
|
-
const fallbackShape = dbType === "JSON" || dbType === "JSONB" || col?.config?.mode === "json" ? { kind: "json" } : BYTE_STRING_CLASSES.has(ctorName) ? { kind: "byteString", length: declaredLength(col) } : NUMBER_VECTOR_CLASSES.has(ctorName) ? { kind: "numberVector", length: declaredLength(col) } : BIT_STRING_CLASSES.has(ctorName) ? { kind: "bitstring", length: declaredLength(col), exact: true } : GEOMETRIC_CLASS_SHAPES[ctorName];
|
|
908
|
+
const fallbackShape = dbType === "JSON" || dbType === "JSONB" || col?.config?.mode === "json" ? { kind: "json" } : BYTE_STRING_CLASSES.has(ctorName) ? { kind: "byteString", length: declaredLength(col) } : BUFFER_CLASSES.has(ctorName) ? { kind: "buffer" } : NUMBER_VECTOR_CLASSES.has(ctorName) ? { kind: "numberVector", length: declaredLength(col) } : BIT_STRING_CLASSES.has(ctorName) ? { kind: "bitstring", length: declaredLength(col), exact: true } : GEOMETRIC_CLASS_SHAPES[ctorName];
|
|
871
909
|
if (fallbackShape?.kind === "byteString") delete constraints.maxLength;
|
|
872
910
|
const shape = (v1?.shape ?? fallbackShape)?.kind;
|
|
873
911
|
const finalTs = v1?.tsType ?? tsType;
|
|
@@ -1235,6 +1273,28 @@ _SchemaAnalyzer.INEXACT_RANGES = {
|
|
|
1235
1273
|
// column, which Postgres caps far lower: it refuses 2147483648 into a `numeric(10,2)`.
|
|
1236
1274
|
PgNumericNumber: JS_SAFE_INTEGER_BOUNDS
|
|
1237
1275
|
};
|
|
1276
|
+
/**
|
|
1277
|
+
* The Postgres number columns that hold a non-finite double, and which of the three each holds.
|
|
1278
|
+
*
|
|
1279
|
+
* The class-name half of what `describeV1Column` reads off the codec, and the two must agree: a
|
|
1280
|
+
* fact stated on one path and not the other is a schema that changes when the user upgrades
|
|
1281
|
+
* drizzle, which the cross-major diff in `verify-packed.sh` fails on. These three class names are
|
|
1282
|
+
* the same on both majors, read off real `pgTable` columns on 0.45.2 and on 1.0.0-rc.4, so this
|
|
1283
|
+
* table also answers for a v1 column and the two answers are identical rather than merely
|
|
1284
|
+
* compatible. non-finite-numbers.spec.ts asserts that agreement through the real analyzer.
|
|
1285
|
+
*
|
|
1286
|
+
* Postgres only. No MySQL, SingleStore or SQLite class belongs here: MySQL refuses all three on a
|
|
1287
|
+
* `float`/`double` and stores `0.00` for a `decimal`, and SQLite returns both infinities while
|
|
1288
|
+
* silently turning `NaN` into NULL, which is a different answer that has to arrive whole.
|
|
1289
|
+
*
|
|
1290
|
+
* `PgNumeric` is absent because its value is a string, and its pattern already accepts `NaN` and
|
|
1291
|
+
* `Infinity`. `PgNumericNumber` states `infinity: false` on purpose; see `Column.allowsNaN`.
|
|
1292
|
+
*/
|
|
1293
|
+
_SchemaAnalyzer.PG_NON_FINITE = {
|
|
1294
|
+
PgReal: { nan: true, infinity: true },
|
|
1295
|
+
PgDoublePrecision: { nan: true, infinity: true },
|
|
1296
|
+
PgNumericNumber: { nan: true, infinity: false }
|
|
1297
|
+
};
|
|
1238
1298
|
var SchemaAnalyzer = _SchemaAnalyzer;
|
|
1239
1299
|
var index_default = SchemaAnalyzer;
|
|
1240
1300
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.d.cts
CHANGED
|
@@ -62,6 +62,34 @@ interface Column {
|
|
|
62
62
|
* generators fall back to the old inference there.
|
|
63
63
|
*/
|
|
64
64
|
integer?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the column stores and returns `NaN`, and whether it does the same for an infinity.
|
|
67
|
+
*
|
|
68
|
+
* A range cannot say this. `>=`/`<=` refuses `Infinity` whatever the two numbers are, and `NaN`
|
|
69
|
+
* compares false against both ends, so a bounded float column described by its range alone
|
|
70
|
+
* refused three values Postgres stores in it and hands back on SELECT. That is a read-path
|
|
71
|
+
* defect: every read of such a row fails validation on a column behaving exactly as documented.
|
|
72
|
+
* The generators render these as a union beside the range rather than as a wider range.
|
|
73
|
+
*
|
|
74
|
+
* Measured against PostgreSQL 18.3 through PGlite, on the bound-parameter path a validator
|
|
75
|
+
* guards. `real` and `double precision` return all three unchanged. An unconstrained `numeric`
|
|
76
|
+
* does too, but a `numeric(10,2)` refuses either infinity with `22003 numeric field overflow`
|
|
77
|
+
* while still taking `NaN`, and `integer`/`bigint` refuse all three.
|
|
78
|
+
*
|
|
79
|
+
* So `numeric` in `{ mode: 'number' }` states `allowsInfinity: false` deliberately, and it is a
|
|
80
|
+
* narrowing rather than an oversight: nothing here reads a column's precision or scale, so the
|
|
81
|
+
* two `numeric` declarations are indistinguishable, and admitting the infinities would make the
|
|
82
|
+
* schema promise what the server refuses for the commoner of the two.
|
|
83
|
+
*
|
|
84
|
+
* Postgres only, today. MySQL refuses all three on a `float`/`double` and silently stores `0.00`
|
|
85
|
+
* for a `decimal`. SQLite returns both infinities and silently turns `NaN` into NULL, which is
|
|
86
|
+
* real and is filed on its own: a column needs both halves of that answer or none.
|
|
87
|
+
*
|
|
88
|
+
* Absent on every other column, including the string mode of `numeric`, which already carries the
|
|
89
|
+
* same fact as a pattern; see `COLUMN_FORMATS.numeric` in `@drzl/validation-core`.
|
|
90
|
+
*/
|
|
91
|
+
allowsNaN?: boolean;
|
|
92
|
+
allowsInfinity?: boolean;
|
|
65
93
|
/**
|
|
66
94
|
* A string column whose contents have a shape the database enforces.
|
|
67
95
|
*
|
|
@@ -451,6 +479,24 @@ declare class SchemaAnalyzer {
|
|
|
451
479
|
* `number double` on drizzle v1, which is where these pairings come from.
|
|
452
480
|
*/
|
|
453
481
|
private static readonly INEXACT_RANGES;
|
|
482
|
+
/**
|
|
483
|
+
* The Postgres number columns that hold a non-finite double, and which of the three each holds.
|
|
484
|
+
*
|
|
485
|
+
* The class-name half of what `describeV1Column` reads off the codec, and the two must agree: a
|
|
486
|
+
* fact stated on one path and not the other is a schema that changes when the user upgrades
|
|
487
|
+
* drizzle, which the cross-major diff in `verify-packed.sh` fails on. These three class names are
|
|
488
|
+
* the same on both majors, read off real `pgTable` columns on 0.45.2 and on 1.0.0-rc.4, so this
|
|
489
|
+
* table also answers for a v1 column and the two answers are identical rather than merely
|
|
490
|
+
* compatible. non-finite-numbers.spec.ts asserts that agreement through the real analyzer.
|
|
491
|
+
*
|
|
492
|
+
* Postgres only. No MySQL, SingleStore or SQLite class belongs here: MySQL refuses all three on a
|
|
493
|
+
* `float`/`double` and stores `0.00` for a `decimal`, and SQLite returns both infinities while
|
|
494
|
+
* silently turning `NaN` into NULL, which is a different answer that has to arrive whole.
|
|
495
|
+
*
|
|
496
|
+
* `PgNumeric` is absent because its value is a string, and its pattern already accepts `NaN` and
|
|
497
|
+
* `Infinity`. `PgNumericNumber` states `infinity: false` on purpose; see `Column.allowsNaN`.
|
|
498
|
+
*/
|
|
499
|
+
private static readonly PG_NON_FINITE;
|
|
454
500
|
/**
|
|
455
501
|
* Constraints the column definition already carries, which the analysis used to throw away.
|
|
456
502
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -62,6 +62,34 @@ interface Column {
|
|
|
62
62
|
* generators fall back to the old inference there.
|
|
63
63
|
*/
|
|
64
64
|
integer?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the column stores and returns `NaN`, and whether it does the same for an infinity.
|
|
67
|
+
*
|
|
68
|
+
* A range cannot say this. `>=`/`<=` refuses `Infinity` whatever the two numbers are, and `NaN`
|
|
69
|
+
* compares false against both ends, so a bounded float column described by its range alone
|
|
70
|
+
* refused three values Postgres stores in it and hands back on SELECT. That is a read-path
|
|
71
|
+
* defect: every read of such a row fails validation on a column behaving exactly as documented.
|
|
72
|
+
* The generators render these as a union beside the range rather than as a wider range.
|
|
73
|
+
*
|
|
74
|
+
* Measured against PostgreSQL 18.3 through PGlite, on the bound-parameter path a validator
|
|
75
|
+
* guards. `real` and `double precision` return all three unchanged. An unconstrained `numeric`
|
|
76
|
+
* does too, but a `numeric(10,2)` refuses either infinity with `22003 numeric field overflow`
|
|
77
|
+
* while still taking `NaN`, and `integer`/`bigint` refuse all three.
|
|
78
|
+
*
|
|
79
|
+
* So `numeric` in `{ mode: 'number' }` states `allowsInfinity: false` deliberately, and it is a
|
|
80
|
+
* narrowing rather than an oversight: nothing here reads a column's precision or scale, so the
|
|
81
|
+
* two `numeric` declarations are indistinguishable, and admitting the infinities would make the
|
|
82
|
+
* schema promise what the server refuses for the commoner of the two.
|
|
83
|
+
*
|
|
84
|
+
* Postgres only, today. MySQL refuses all three on a `float`/`double` and silently stores `0.00`
|
|
85
|
+
* for a `decimal`. SQLite returns both infinities and silently turns `NaN` into NULL, which is
|
|
86
|
+
* real and is filed on its own: a column needs both halves of that answer or none.
|
|
87
|
+
*
|
|
88
|
+
* Absent on every other column, including the string mode of `numeric`, which already carries the
|
|
89
|
+
* same fact as a pattern; see `COLUMN_FORMATS.numeric` in `@drzl/validation-core`.
|
|
90
|
+
*/
|
|
91
|
+
allowsNaN?: boolean;
|
|
92
|
+
allowsInfinity?: boolean;
|
|
65
93
|
/**
|
|
66
94
|
* A string column whose contents have a shape the database enforces.
|
|
67
95
|
*
|
|
@@ -451,6 +479,24 @@ declare class SchemaAnalyzer {
|
|
|
451
479
|
* `number double` on drizzle v1, which is where these pairings come from.
|
|
452
480
|
*/
|
|
453
481
|
private static readonly INEXACT_RANGES;
|
|
482
|
+
/**
|
|
483
|
+
* The Postgres number columns that hold a non-finite double, and which of the three each holds.
|
|
484
|
+
*
|
|
485
|
+
* The class-name half of what `describeV1Column` reads off the codec, and the two must agree: a
|
|
486
|
+
* fact stated on one path and not the other is a schema that changes when the user upgrades
|
|
487
|
+
* drizzle, which the cross-major diff in `verify-packed.sh` fails on. These three class names are
|
|
488
|
+
* the same on both majors, read off real `pgTable` columns on 0.45.2 and on 1.0.0-rc.4, so this
|
|
489
|
+
* table also answers for a v1 column and the two answers are identical rather than merely
|
|
490
|
+
* compatible. non-finite-numbers.spec.ts asserts that agreement through the real analyzer.
|
|
491
|
+
*
|
|
492
|
+
* Postgres only. No MySQL, SingleStore or SQLite class belongs here: MySQL refuses all three on a
|
|
493
|
+
* `float`/`double` and stores `0.00` for a `decimal`, and SQLite returns both infinities while
|
|
494
|
+
* silently turning `NaN` into NULL, which is a different answer that has to arrive whole.
|
|
495
|
+
*
|
|
496
|
+
* `PgNumeric` is absent because its value is a string, and its pattern already accepts `NaN` and
|
|
497
|
+
* `Infinity`. `PgNumericNumber` states `infinity: false` on purpose; see `Column.allowsNaN`.
|
|
498
|
+
*/
|
|
499
|
+
private static readonly PG_NON_FINITE;
|
|
454
500
|
/**
|
|
455
501
|
* Constraints the column definition already carries, which the analysis used to throw away.
|
|
456
502
|
*
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ var BYTE_STRING_CLASSES = /* @__PURE__ */ new Set([
|
|
|
46
46
|
"SingleStoreBinary",
|
|
47
47
|
"SingleStoreVarBinary"
|
|
48
48
|
]);
|
|
49
|
+
var BUFFER_CLASSES = /* @__PURE__ */ new Set(["SQLiteBlobBuffer"]);
|
|
49
50
|
function describeV1Column(column) {
|
|
50
51
|
const codec = column?.codec;
|
|
51
52
|
const dataType = column?.dataType;
|
|
@@ -100,6 +101,10 @@ function describeV1Column(column) {
|
|
|
100
101
|
out.integer = false;
|
|
101
102
|
out.tsType = "number";
|
|
102
103
|
out.dbType = semantic === "float" ? "REAL" : "DOUBLE";
|
|
104
|
+
if (codec === "float4" || codec === "float8") {
|
|
105
|
+
out.allowsNaN = true;
|
|
106
|
+
out.allowsInfinity = true;
|
|
107
|
+
}
|
|
103
108
|
break;
|
|
104
109
|
}
|
|
105
110
|
case "uuid":
|
|
@@ -209,6 +214,10 @@ function describeV1Column(column) {
|
|
|
209
214
|
out.dbType = "NUMERIC";
|
|
210
215
|
out.integer = false;
|
|
211
216
|
[out.min, out.max] = JS_SAFE_INTEGER_BOUNDS;
|
|
217
|
+
if (codec === "numeric:number") {
|
|
218
|
+
out.allowsNaN = true;
|
|
219
|
+
out.allowsInfinity = false;
|
|
220
|
+
}
|
|
212
221
|
} else if (js === "string") {
|
|
213
222
|
out.tsType = "string";
|
|
214
223
|
out.dbType = codec === "varchar" ? "VARCHAR" : codec === "char" ? "CHAR" : "TEXT";
|
|
@@ -528,6 +537,11 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
528
537
|
if (inexact) [out.min, out.max] = inexact;
|
|
529
538
|
out.integer = false;
|
|
530
539
|
}
|
|
540
|
+
const nonFinite = _SchemaAnalyzer.PG_NON_FINITE[ctor];
|
|
541
|
+
if (nonFinite) {
|
|
542
|
+
out.allowsNaN = nonFinite.nan;
|
|
543
|
+
out.allowsInfinity = nonFinite.infinity;
|
|
544
|
+
}
|
|
531
545
|
if (/^(Pg)?UUID$/i.test(ctor) || /Uuid$/i.test(ctor)) out.format = "uuid";
|
|
532
546
|
return out;
|
|
533
547
|
}
|
|
@@ -539,12 +553,36 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
539
553
|
tsType: column?.config?.mode === "timestamp" ? "Date" : "number",
|
|
540
554
|
dbType: "INTEGER"
|
|
541
555
|
};
|
|
556
|
+
// Both timestamp modes of `integer()`, which are one class and one type. `timestamp` and
|
|
557
|
+
// `timestamp_ms` differ in the scale of the number on the wire, seconds against
|
|
558
|
+
// milliseconds, and `mapFromDriverValue` consumes that difference and hands back a `Date`
|
|
559
|
+
// either way; nothing downstream of the analyzer ever sees the integer. So an arm keyed on
|
|
560
|
+
// the class covers both, where the mode check that used to answer this fell through the
|
|
561
|
+
// switch to a default arm testing `config.mode === 'timestamp'` and named only the first.
|
|
562
|
+
// The second came back `unknown`, and every generator emitted a schema accepting anything.
|
|
563
|
+
//
|
|
564
|
+
// `DATE` rather than the `INTEGER` that mode check returned, so the two majors describe the
|
|
565
|
+
// column identically. `dbType` is read in exactly one place outside this file,
|
|
566
|
+
// `isIntegerColumn`, which the generators consult only for a `tsType` of `number`, so the
|
|
567
|
+
// relabel reaches no output. Measured rather than argued: emitting a `Date` column under
|
|
568
|
+
// both labels, nullable and not, through all five generators gives ten byte-identical pairs.
|
|
569
|
+
case "SQLiteTimestamp":
|
|
570
|
+
return { tsType: "Date", dbType: "DATE" };
|
|
542
571
|
case "SQLiteText":
|
|
543
572
|
return { tsType: "string", dbType: "TEXT" };
|
|
544
573
|
case "SQLiteReal":
|
|
545
574
|
return { tsType: "number", dbType: "REAL" };
|
|
575
|
+
// No 0.4x column is a `SQLiteBlob`: `sqlite-core` builds a `SQLiteBlobBuffer`, a
|
|
576
|
+
// `SQLiteBlobJson` or a `SQLiteBigInt`, one per mode, and exports no class of this name at
|
|
577
|
+
// all. The arm answers the hand-built column in sqlite-types.spec.ts and nothing drizzle
|
|
578
|
+
// produces, which is why a real `blob()` reached neither it nor anything else.
|
|
546
579
|
case "SQLiteBlob":
|
|
547
580
|
return { tsType: "Uint8Array", dbType: "BLOB" };
|
|
581
|
+
// The class a real `blob()` and `blob({ mode: 'buffer' })` both build. See `BUFFER_CLASSES`
|
|
582
|
+
// for the measurement; the answers here are v1's own for the same column, so this is the
|
|
583
|
+
// two majors agreeing rather than a new opinion.
|
|
584
|
+
case "SQLiteBlobBuffer":
|
|
585
|
+
return { tsType: "Buffer", dbType: "BYTEA" };
|
|
548
586
|
// SQLite spells a mode as a distinct class rather than as config, so `text({mode:'json'})`
|
|
549
587
|
// is a `SQLiteTextJson` and matched no arm at all: the column came back UNKNOWN, which is
|
|
550
588
|
// wider than the `any` a json column at least used to get.
|
|
@@ -826,7 +864,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
826
864
|
const sqlType = sqlKind.startsWith("MySql") && typeof col?.getSQLType === "function" ? String(col.getSQLType()).toLowerCase() : void 0;
|
|
827
865
|
const byteCap = sqlType ? MYSQL_TEXT_CAPS[sqlType] : void 0;
|
|
828
866
|
const ctorName = String(col?.constructor?.name ?? "");
|
|
829
|
-
const fallbackShape = dbType === "JSON" || dbType === "JSONB" || col?.config?.mode === "json" ? { kind: "json" } : BYTE_STRING_CLASSES.has(ctorName) ? { kind: "byteString", length: declaredLength(col) } : NUMBER_VECTOR_CLASSES.has(ctorName) ? { kind: "numberVector", length: declaredLength(col) } : BIT_STRING_CLASSES.has(ctorName) ? { kind: "bitstring", length: declaredLength(col), exact: true } : GEOMETRIC_CLASS_SHAPES[ctorName];
|
|
867
|
+
const fallbackShape = dbType === "JSON" || dbType === "JSONB" || col?.config?.mode === "json" ? { kind: "json" } : BYTE_STRING_CLASSES.has(ctorName) ? { kind: "byteString", length: declaredLength(col) } : BUFFER_CLASSES.has(ctorName) ? { kind: "buffer" } : NUMBER_VECTOR_CLASSES.has(ctorName) ? { kind: "numberVector", length: declaredLength(col) } : BIT_STRING_CLASSES.has(ctorName) ? { kind: "bitstring", length: declaredLength(col), exact: true } : GEOMETRIC_CLASS_SHAPES[ctorName];
|
|
830
868
|
if (fallbackShape?.kind === "byteString") delete constraints.maxLength;
|
|
831
869
|
const shape = (v1?.shape ?? fallbackShape)?.kind;
|
|
832
870
|
const finalTs = v1?.tsType ?? tsType;
|
|
@@ -1194,6 +1232,28 @@ _SchemaAnalyzer.INEXACT_RANGES = {
|
|
|
1194
1232
|
// column, which Postgres caps far lower: it refuses 2147483648 into a `numeric(10,2)`.
|
|
1195
1233
|
PgNumericNumber: JS_SAFE_INTEGER_BOUNDS
|
|
1196
1234
|
};
|
|
1235
|
+
/**
|
|
1236
|
+
* The Postgres number columns that hold a non-finite double, and which of the three each holds.
|
|
1237
|
+
*
|
|
1238
|
+
* The class-name half of what `describeV1Column` reads off the codec, and the two must agree: a
|
|
1239
|
+
* fact stated on one path and not the other is a schema that changes when the user upgrades
|
|
1240
|
+
* drizzle, which the cross-major diff in `verify-packed.sh` fails on. These three class names are
|
|
1241
|
+
* the same on both majors, read off real `pgTable` columns on 0.45.2 and on 1.0.0-rc.4, so this
|
|
1242
|
+
* table also answers for a v1 column and the two answers are identical rather than merely
|
|
1243
|
+
* compatible. non-finite-numbers.spec.ts asserts that agreement through the real analyzer.
|
|
1244
|
+
*
|
|
1245
|
+
* Postgres only. No MySQL, SingleStore or SQLite class belongs here: MySQL refuses all three on a
|
|
1246
|
+
* `float`/`double` and stores `0.00` for a `decimal`, and SQLite returns both infinities while
|
|
1247
|
+
* silently turning `NaN` into NULL, which is a different answer that has to arrive whole.
|
|
1248
|
+
*
|
|
1249
|
+
* `PgNumeric` is absent because its value is a string, and its pattern already accepts `NaN` and
|
|
1250
|
+
* `Infinity`. `PgNumericNumber` states `infinity: false` on purpose; see `Column.allowsNaN`.
|
|
1251
|
+
*/
|
|
1252
|
+
_SchemaAnalyzer.PG_NON_FINITE = {
|
|
1253
|
+
PgReal: { nan: true, infinity: true },
|
|
1254
|
+
PgDoublePrecision: { nan: true, infinity: true },
|
|
1255
|
+
PgNumericNumber: { nan: true, infinity: false }
|
|
1256
|
+
};
|
|
1197
1257
|
var SchemaAnalyzer = _SchemaAnalyzer;
|
|
1198
1258
|
var index_default = SchemaAnalyzer;
|
|
1199
1259
|
export {
|