@drzl/analyzer 1.17.2 → 1.17.4
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 +55 -3
- package/dist/index.d.cts +46 -0
- package/dist/index.d.ts +46 -0
- package/dist/index.js +55 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -71,10 +71,16 @@ var GEOMETRIC_CLASS_SHAPES = {
|
|
|
71
71
|
// The object modes. `line({ mode: 'abc' })` is a `PgLineABC` and not a `PgLineObject`, and any
|
|
72
72
|
// mode but `'tuple'` builds the object class: `point({ mode: 'abc' })` is a `PgPointObject` too.
|
|
73
73
|
PgPointObject: { kind: "numberObject", fields: ["x", "y"] },
|
|
74
|
-
PgLineABC: { kind: "numberObject", fields: ["a", "b", "c"] }
|
|
74
|
+
PgLineABC: { kind: "numberObject", fields: ["a", "b", "c"] },
|
|
75
|
+
// `geometry()` and `geometry({ mode: 'xy' })` are two classes, not one class with a flag, and
|
|
76
|
+
// the fuzzer found both unnamed on this path. Their driver mappers disagree the same way the
|
|
77
|
+
// point ones do: the default hands back `[1, 2]` and the xy mode hands back `{ x: 1, y: 2 }`.
|
|
78
|
+
PgGeometry: { kind: "tuple", length: 2 },
|
|
79
|
+
PgGeometryObject: { kind: "numberObject", fields: ["x", "y"] }
|
|
75
80
|
};
|
|
76
81
|
var V1_ONLY_ENTITY_KINDS = /^(?:MsSql|Cockroach)/;
|
|
77
|
-
var NUMBER_VECTOR_CLASSES = /* @__PURE__ */ new Set(["PgVector", "PgHalfVector"]);
|
|
82
|
+
var NUMBER_VECTOR_CLASSES = /* @__PURE__ */ new Set(["PgVector", "PgHalfVector", "SingleStoreVector"]);
|
|
83
|
+
var BIT_STRING_CLASSES = /* @__PURE__ */ new Set(["PgBinaryVector"]);
|
|
78
84
|
var BYTE_STRING_CLASSES = /* @__PURE__ */ new Set([
|
|
79
85
|
"MySqlBinary",
|
|
80
86
|
"MySqlVarBinary",
|
|
@@ -135,6 +141,10 @@ function describeV1Column(column) {
|
|
|
135
141
|
out.integer = false;
|
|
136
142
|
out.tsType = "number";
|
|
137
143
|
out.dbType = semantic === "float" ? "REAL" : "DOUBLE";
|
|
144
|
+
if (codec === "float4" || codec === "float8") {
|
|
145
|
+
out.allowsNaN = true;
|
|
146
|
+
out.allowsInfinity = true;
|
|
147
|
+
}
|
|
138
148
|
break;
|
|
139
149
|
}
|
|
140
150
|
case "uuid":
|
|
@@ -244,6 +254,10 @@ function describeV1Column(column) {
|
|
|
244
254
|
out.dbType = "NUMERIC";
|
|
245
255
|
out.integer = false;
|
|
246
256
|
[out.min, out.max] = JS_SAFE_INTEGER_BOUNDS;
|
|
257
|
+
if (codec === "numeric:number") {
|
|
258
|
+
out.allowsNaN = true;
|
|
259
|
+
out.allowsInfinity = false;
|
|
260
|
+
}
|
|
247
261
|
} else if (js === "string") {
|
|
248
262
|
out.tsType = "string";
|
|
249
263
|
out.dbType = codec === "varchar" ? "VARCHAR" : codec === "char" ? "CHAR" : "TEXT";
|
|
@@ -563,6 +577,11 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
563
577
|
if (inexact) [out.min, out.max] = inexact;
|
|
564
578
|
out.integer = false;
|
|
565
579
|
}
|
|
580
|
+
const nonFinite = _SchemaAnalyzer.PG_NON_FINITE[ctor];
|
|
581
|
+
if (nonFinite) {
|
|
582
|
+
out.allowsNaN = nonFinite.nan;
|
|
583
|
+
out.allowsInfinity = nonFinite.infinity;
|
|
584
|
+
}
|
|
566
585
|
if (/^(Pg)?UUID$/i.test(ctor) || /Uuid$/i.test(ctor)) out.format = "uuid";
|
|
567
586
|
return out;
|
|
568
587
|
}
|
|
@@ -632,7 +651,18 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
632
651
|
// one is declared, as the codec path already did for `vector`.
|
|
633
652
|
case "PgVector":
|
|
634
653
|
case "PgHalfVector":
|
|
654
|
+
case "SingleStoreVector":
|
|
635
655
|
return { tsType: "number[]", dbType: "VECTOR" };
|
|
656
|
+
// `BIT` rather than `TEXT`, which a first version of this arm returned. v1's codec says `BIT`
|
|
657
|
+
// for the same column, and the cross-major diff said so: naming the class made ten of its
|
|
658
|
+
// twelve entries go stale and left `c_bit.dbType` and its nullable twin standing, which is
|
|
659
|
+
// that check distinguishing a fix from a half fix.
|
|
660
|
+
case "PgBinaryVector":
|
|
661
|
+
return { tsType: "string", dbType: "BIT" };
|
|
662
|
+
case "PgGeometry":
|
|
663
|
+
return { tsType: "[number, number]", dbType: "GEOMETRY" };
|
|
664
|
+
case "PgGeometryObject":
|
|
665
|
+
return { tsType: "{ x: number; y: number }", dbType: "GEOMETRY" };
|
|
636
666
|
case "PgSparseVector":
|
|
637
667
|
return { tsType: "string", dbType: "TEXT" };
|
|
638
668
|
case "PgInteger":
|
|
@@ -850,7 +880,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
850
880
|
const sqlType = sqlKind.startsWith("MySql") && typeof col?.getSQLType === "function" ? String(col.getSQLType()).toLowerCase() : void 0;
|
|
851
881
|
const byteCap = sqlType ? MYSQL_TEXT_CAPS[sqlType] : void 0;
|
|
852
882
|
const ctorName = String(col?.constructor?.name ?? "");
|
|
853
|
-
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) } : GEOMETRIC_CLASS_SHAPES[ctorName];
|
|
883
|
+
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];
|
|
854
884
|
if (fallbackShape?.kind === "byteString") delete constraints.maxLength;
|
|
855
885
|
const shape = (v1?.shape ?? fallbackShape)?.kind;
|
|
856
886
|
const finalTs = v1?.tsType ?? tsType;
|
|
@@ -1218,6 +1248,28 @@ _SchemaAnalyzer.INEXACT_RANGES = {
|
|
|
1218
1248
|
// column, which Postgres caps far lower: it refuses 2147483648 into a `numeric(10,2)`.
|
|
1219
1249
|
PgNumericNumber: JS_SAFE_INTEGER_BOUNDS
|
|
1220
1250
|
};
|
|
1251
|
+
/**
|
|
1252
|
+
* The Postgres number columns that hold a non-finite double, and which of the three each holds.
|
|
1253
|
+
*
|
|
1254
|
+
* The class-name half of what `describeV1Column` reads off the codec, and the two must agree: a
|
|
1255
|
+
* fact stated on one path and not the other is a schema that changes when the user upgrades
|
|
1256
|
+
* drizzle, which the cross-major diff in `verify-packed.sh` fails on. These three class names are
|
|
1257
|
+
* the same on both majors, read off real `pgTable` columns on 0.45.2 and on 1.0.0-rc.4, so this
|
|
1258
|
+
* table also answers for a v1 column and the two answers are identical rather than merely
|
|
1259
|
+
* compatible. non-finite-numbers.spec.ts asserts that agreement through the real analyzer.
|
|
1260
|
+
*
|
|
1261
|
+
* Postgres only. No MySQL, SingleStore or SQLite class belongs here: MySQL refuses all three on a
|
|
1262
|
+
* `float`/`double` and stores `0.00` for a `decimal`, and SQLite returns both infinities while
|
|
1263
|
+
* silently turning `NaN` into NULL, which is a different answer that has to arrive whole.
|
|
1264
|
+
*
|
|
1265
|
+
* `PgNumeric` is absent because its value is a string, and its pattern already accepts `NaN` and
|
|
1266
|
+
* `Infinity`. `PgNumericNumber` states `infinity: false` on purpose; see `Column.allowsNaN`.
|
|
1267
|
+
*/
|
|
1268
|
+
_SchemaAnalyzer.PG_NON_FINITE = {
|
|
1269
|
+
PgReal: { nan: true, infinity: true },
|
|
1270
|
+
PgDoublePrecision: { nan: true, infinity: true },
|
|
1271
|
+
PgNumericNumber: { nan: true, infinity: false }
|
|
1272
|
+
};
|
|
1221
1273
|
var SchemaAnalyzer = _SchemaAnalyzer;
|
|
1222
1274
|
var index_default = SchemaAnalyzer;
|
|
1223
1275
|
// 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
|
@@ -30,10 +30,16 @@ var GEOMETRIC_CLASS_SHAPES = {
|
|
|
30
30
|
// The object modes. `line({ mode: 'abc' })` is a `PgLineABC` and not a `PgLineObject`, and any
|
|
31
31
|
// mode but `'tuple'` builds the object class: `point({ mode: 'abc' })` is a `PgPointObject` too.
|
|
32
32
|
PgPointObject: { kind: "numberObject", fields: ["x", "y"] },
|
|
33
|
-
PgLineABC: { kind: "numberObject", fields: ["a", "b", "c"] }
|
|
33
|
+
PgLineABC: { kind: "numberObject", fields: ["a", "b", "c"] },
|
|
34
|
+
// `geometry()` and `geometry({ mode: 'xy' })` are two classes, not one class with a flag, and
|
|
35
|
+
// the fuzzer found both unnamed on this path. Their driver mappers disagree the same way the
|
|
36
|
+
// point ones do: the default hands back `[1, 2]` and the xy mode hands back `{ x: 1, y: 2 }`.
|
|
37
|
+
PgGeometry: { kind: "tuple", length: 2 },
|
|
38
|
+
PgGeometryObject: { kind: "numberObject", fields: ["x", "y"] }
|
|
34
39
|
};
|
|
35
40
|
var V1_ONLY_ENTITY_KINDS = /^(?:MsSql|Cockroach)/;
|
|
36
|
-
var NUMBER_VECTOR_CLASSES = /* @__PURE__ */ new Set(["PgVector", "PgHalfVector"]);
|
|
41
|
+
var NUMBER_VECTOR_CLASSES = /* @__PURE__ */ new Set(["PgVector", "PgHalfVector", "SingleStoreVector"]);
|
|
42
|
+
var BIT_STRING_CLASSES = /* @__PURE__ */ new Set(["PgBinaryVector"]);
|
|
37
43
|
var BYTE_STRING_CLASSES = /* @__PURE__ */ new Set([
|
|
38
44
|
"MySqlBinary",
|
|
39
45
|
"MySqlVarBinary",
|
|
@@ -94,6 +100,10 @@ function describeV1Column(column) {
|
|
|
94
100
|
out.integer = false;
|
|
95
101
|
out.tsType = "number";
|
|
96
102
|
out.dbType = semantic === "float" ? "REAL" : "DOUBLE";
|
|
103
|
+
if (codec === "float4" || codec === "float8") {
|
|
104
|
+
out.allowsNaN = true;
|
|
105
|
+
out.allowsInfinity = true;
|
|
106
|
+
}
|
|
97
107
|
break;
|
|
98
108
|
}
|
|
99
109
|
case "uuid":
|
|
@@ -203,6 +213,10 @@ function describeV1Column(column) {
|
|
|
203
213
|
out.dbType = "NUMERIC";
|
|
204
214
|
out.integer = false;
|
|
205
215
|
[out.min, out.max] = JS_SAFE_INTEGER_BOUNDS;
|
|
216
|
+
if (codec === "numeric:number") {
|
|
217
|
+
out.allowsNaN = true;
|
|
218
|
+
out.allowsInfinity = false;
|
|
219
|
+
}
|
|
206
220
|
} else if (js === "string") {
|
|
207
221
|
out.tsType = "string";
|
|
208
222
|
out.dbType = codec === "varchar" ? "VARCHAR" : codec === "char" ? "CHAR" : "TEXT";
|
|
@@ -522,6 +536,11 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
522
536
|
if (inexact) [out.min, out.max] = inexact;
|
|
523
537
|
out.integer = false;
|
|
524
538
|
}
|
|
539
|
+
const nonFinite = _SchemaAnalyzer.PG_NON_FINITE[ctor];
|
|
540
|
+
if (nonFinite) {
|
|
541
|
+
out.allowsNaN = nonFinite.nan;
|
|
542
|
+
out.allowsInfinity = nonFinite.infinity;
|
|
543
|
+
}
|
|
525
544
|
if (/^(Pg)?UUID$/i.test(ctor) || /Uuid$/i.test(ctor)) out.format = "uuid";
|
|
526
545
|
return out;
|
|
527
546
|
}
|
|
@@ -591,7 +610,18 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
591
610
|
// one is declared, as the codec path already did for `vector`.
|
|
592
611
|
case "PgVector":
|
|
593
612
|
case "PgHalfVector":
|
|
613
|
+
case "SingleStoreVector":
|
|
594
614
|
return { tsType: "number[]", dbType: "VECTOR" };
|
|
615
|
+
// `BIT` rather than `TEXT`, which a first version of this arm returned. v1's codec says `BIT`
|
|
616
|
+
// for the same column, and the cross-major diff said so: naming the class made ten of its
|
|
617
|
+
// twelve entries go stale and left `c_bit.dbType` and its nullable twin standing, which is
|
|
618
|
+
// that check distinguishing a fix from a half fix.
|
|
619
|
+
case "PgBinaryVector":
|
|
620
|
+
return { tsType: "string", dbType: "BIT" };
|
|
621
|
+
case "PgGeometry":
|
|
622
|
+
return { tsType: "[number, number]", dbType: "GEOMETRY" };
|
|
623
|
+
case "PgGeometryObject":
|
|
624
|
+
return { tsType: "{ x: number; y: number }", dbType: "GEOMETRY" };
|
|
595
625
|
case "PgSparseVector":
|
|
596
626
|
return { tsType: "string", dbType: "TEXT" };
|
|
597
627
|
case "PgInteger":
|
|
@@ -809,7 +839,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
809
839
|
const sqlType = sqlKind.startsWith("MySql") && typeof col?.getSQLType === "function" ? String(col.getSQLType()).toLowerCase() : void 0;
|
|
810
840
|
const byteCap = sqlType ? MYSQL_TEXT_CAPS[sqlType] : void 0;
|
|
811
841
|
const ctorName = String(col?.constructor?.name ?? "");
|
|
812
|
-
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) } : GEOMETRIC_CLASS_SHAPES[ctorName];
|
|
842
|
+
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];
|
|
813
843
|
if (fallbackShape?.kind === "byteString") delete constraints.maxLength;
|
|
814
844
|
const shape = (v1?.shape ?? fallbackShape)?.kind;
|
|
815
845
|
const finalTs = v1?.tsType ?? tsType;
|
|
@@ -1177,6 +1207,28 @@ _SchemaAnalyzer.INEXACT_RANGES = {
|
|
|
1177
1207
|
// column, which Postgres caps far lower: it refuses 2147483648 into a `numeric(10,2)`.
|
|
1178
1208
|
PgNumericNumber: JS_SAFE_INTEGER_BOUNDS
|
|
1179
1209
|
};
|
|
1210
|
+
/**
|
|
1211
|
+
* The Postgres number columns that hold a non-finite double, and which of the three each holds.
|
|
1212
|
+
*
|
|
1213
|
+
* The class-name half of what `describeV1Column` reads off the codec, and the two must agree: a
|
|
1214
|
+
* fact stated on one path and not the other is a schema that changes when the user upgrades
|
|
1215
|
+
* drizzle, which the cross-major diff in `verify-packed.sh` fails on. These three class names are
|
|
1216
|
+
* the same on both majors, read off real `pgTable` columns on 0.45.2 and on 1.0.0-rc.4, so this
|
|
1217
|
+
* table also answers for a v1 column and the two answers are identical rather than merely
|
|
1218
|
+
* compatible. non-finite-numbers.spec.ts asserts that agreement through the real analyzer.
|
|
1219
|
+
*
|
|
1220
|
+
* Postgres only. No MySQL, SingleStore or SQLite class belongs here: MySQL refuses all three on a
|
|
1221
|
+
* `float`/`double` and stores `0.00` for a `decimal`, and SQLite returns both infinities while
|
|
1222
|
+
* silently turning `NaN` into NULL, which is a different answer that has to arrive whole.
|
|
1223
|
+
*
|
|
1224
|
+
* `PgNumeric` is absent because its value is a string, and its pattern already accepts `NaN` and
|
|
1225
|
+
* `Infinity`. `PgNumericNumber` states `infinity: false` on purpose; see `Column.allowsNaN`.
|
|
1226
|
+
*/
|
|
1227
|
+
_SchemaAnalyzer.PG_NON_FINITE = {
|
|
1228
|
+
PgReal: { nan: true, infinity: true },
|
|
1229
|
+
PgDoublePrecision: { nan: true, infinity: true },
|
|
1230
|
+
PgNumericNumber: { nan: true, infinity: false }
|
|
1231
|
+
};
|
|
1180
1232
|
var SchemaAnalyzer = _SchemaAnalyzer;
|
|
1181
1233
|
var index_default = SchemaAnalyzer;
|
|
1182
1234
|
export {
|