@lark-apaas/db-schema-sync 0.1.17 → 0.1.18
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/bin.js +1 -1
- package/dist/{chunk-ACLG7GQP.js → chunk-7O4DEVTQ.js} +11 -7
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -1863,17 +1863,19 @@ function generateEnumCode(schema) {
|
|
|
1863
1863
|
}
|
|
1864
1864
|
|
|
1865
1865
|
// src/generator/structures/index-gen.ts
|
|
1866
|
-
function generateIndexCode(idx, tableIdentifier) {
|
|
1866
|
+
function generateIndexCode(idx, tableIdentifier, knownColumnProperties) {
|
|
1867
1867
|
const fn = idx.indexType === "unique" ? "uniqueIndex" : "index";
|
|
1868
|
-
const
|
|
1868
|
+
const propertyRefs = idx.indexColumns.map((col) => sanitizePropertyName(col));
|
|
1869
|
+
const columns = propertyRefs.map((prop) => `table.${prop}`).join(", ");
|
|
1869
1870
|
const escapedName = escapeDoubleQuote(idx.indexName);
|
|
1871
|
+
const allColumnsKnown = knownColumnProperties === void 0 ? true : propertyRefs.every((prop) => knownColumnProperties.has(prop));
|
|
1872
|
+
if (!columns || !allColumnsKnown) {
|
|
1873
|
+
return `// Complex index: ${idx.indexDef || idx.indexName}`;
|
|
1874
|
+
}
|
|
1870
1875
|
const creationType = idx.indexCreationType || "btree";
|
|
1871
|
-
if (creationType !== "btree"
|
|
1876
|
+
if (creationType !== "btree") {
|
|
1872
1877
|
return `${fn}("${escapedName}").using("${creationType}", ${columns})`;
|
|
1873
1878
|
}
|
|
1874
|
-
if (!columns) {
|
|
1875
|
-
return `// Complex index: ${idx.indexDef || idx.indexName}`;
|
|
1876
|
-
}
|
|
1877
1879
|
return `${fn}("${escapedName}").on(${columns})`;
|
|
1878
1880
|
}
|
|
1879
1881
|
|
|
@@ -1899,16 +1901,18 @@ function generateForeignKeyCode(rel, tableIdentifier, tableIdentifierMap) {
|
|
|
1899
1901
|
|
|
1900
1902
|
// src/generator/structures/table.ts
|
|
1901
1903
|
function generateTableCode(table, schemaData, registry, modifiers, tableIdentifierMap) {
|
|
1904
|
+
const knownColumnProperties = /* @__PURE__ */ new Set();
|
|
1902
1905
|
const fieldLines = table.fields.map((field) => {
|
|
1903
1906
|
const mapper = registry.resolve(field);
|
|
1904
1907
|
const typeExpr = mapper.generate(field);
|
|
1905
1908
|
const mods = applyModifiers(field, modifiers);
|
|
1906
1909
|
const propName = sanitizePropertyName(field.fieldName);
|
|
1910
|
+
knownColumnProperties.add(propName);
|
|
1907
1911
|
return ` ${propName}: ${typeExpr}${mods},`;
|
|
1908
1912
|
});
|
|
1909
1913
|
const thirdArgParts = [];
|
|
1910
1914
|
for (const idx of table.indexes) {
|
|
1911
|
-
thirdArgParts.push(generateIndexCode(idx, table.identifier));
|
|
1915
|
+
thirdArgParts.push(generateIndexCode(idx, table.identifier, knownColumnProperties));
|
|
1912
1916
|
}
|
|
1913
1917
|
for (const rel of table.relationships) {
|
|
1914
1918
|
thirdArgParts.push(generateForeignKeyCode(rel, table.identifier, tableIdentifierMap));
|
package/dist/index.js
CHANGED