@drzl/analyzer 1.17.2 → 1.17.3
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 +20 -3
- package/dist/index.js +20 -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",
|
|
@@ -632,7 +638,18 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
632
638
|
// one is declared, as the codec path already did for `vector`.
|
|
633
639
|
case "PgVector":
|
|
634
640
|
case "PgHalfVector":
|
|
641
|
+
case "SingleStoreVector":
|
|
635
642
|
return { tsType: "number[]", dbType: "VECTOR" };
|
|
643
|
+
// `BIT` rather than `TEXT`, which a first version of this arm returned. v1's codec says `BIT`
|
|
644
|
+
// for the same column, and the cross-major diff said so: naming the class made ten of its
|
|
645
|
+
// twelve entries go stale and left `c_bit.dbType` and its nullable twin standing, which is
|
|
646
|
+
// that check distinguishing a fix from a half fix.
|
|
647
|
+
case "PgBinaryVector":
|
|
648
|
+
return { tsType: "string", dbType: "BIT" };
|
|
649
|
+
case "PgGeometry":
|
|
650
|
+
return { tsType: "[number, number]", dbType: "GEOMETRY" };
|
|
651
|
+
case "PgGeometryObject":
|
|
652
|
+
return { tsType: "{ x: number; y: number }", dbType: "GEOMETRY" };
|
|
636
653
|
case "PgSparseVector":
|
|
637
654
|
return { tsType: "string", dbType: "TEXT" };
|
|
638
655
|
case "PgInteger":
|
|
@@ -850,7 +867,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
850
867
|
const sqlType = sqlKind.startsWith("MySql") && typeof col?.getSQLType === "function" ? String(col.getSQLType()).toLowerCase() : void 0;
|
|
851
868
|
const byteCap = sqlType ? MYSQL_TEXT_CAPS[sqlType] : void 0;
|
|
852
869
|
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];
|
|
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];
|
|
854
871
|
if (fallbackShape?.kind === "byteString") delete constraints.maxLength;
|
|
855
872
|
const shape = (v1?.shape ?? fallbackShape)?.kind;
|
|
856
873
|
const finalTs = v1?.tsType ?? tsType;
|
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",
|
|
@@ -591,7 +597,18 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
591
597
|
// one is declared, as the codec path already did for `vector`.
|
|
592
598
|
case "PgVector":
|
|
593
599
|
case "PgHalfVector":
|
|
600
|
+
case "SingleStoreVector":
|
|
594
601
|
return { tsType: "number[]", dbType: "VECTOR" };
|
|
602
|
+
// `BIT` rather than `TEXT`, which a first version of this arm returned. v1's codec says `BIT`
|
|
603
|
+
// for the same column, and the cross-major diff said so: naming the class made ten of its
|
|
604
|
+
// twelve entries go stale and left `c_bit.dbType` and its nullable twin standing, which is
|
|
605
|
+
// that check distinguishing a fix from a half fix.
|
|
606
|
+
case "PgBinaryVector":
|
|
607
|
+
return { tsType: "string", dbType: "BIT" };
|
|
608
|
+
case "PgGeometry":
|
|
609
|
+
return { tsType: "[number, number]", dbType: "GEOMETRY" };
|
|
610
|
+
case "PgGeometryObject":
|
|
611
|
+
return { tsType: "{ x: number; y: number }", dbType: "GEOMETRY" };
|
|
595
612
|
case "PgSparseVector":
|
|
596
613
|
return { tsType: "string", dbType: "TEXT" };
|
|
597
614
|
case "PgInteger":
|
|
@@ -809,7 +826,7 @@ var _SchemaAnalyzer = class _SchemaAnalyzer {
|
|
|
809
826
|
const sqlType = sqlKind.startsWith("MySql") && typeof col?.getSQLType === "function" ? String(col.getSQLType()).toLowerCase() : void 0;
|
|
810
827
|
const byteCap = sqlType ? MYSQL_TEXT_CAPS[sqlType] : void 0;
|
|
811
828
|
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];
|
|
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];
|
|
813
830
|
if (fallbackShape?.kind === "byteString") delete constraints.maxLength;
|
|
814
831
|
const shape = (v1?.shape ?? fallbackShape)?.kind;
|
|
815
832
|
const finalTs = v1?.tsType ?? tsType;
|