Handle default function parsing
This commit is contained in:
parent
f57ff74cab
commit
1beed53cb6
14
package-lock.json
generated
14
package-lock.json
generated
@ -25,7 +25,7 @@
|
|||||||
"jsonschema": "^1.4.1",
|
"jsonschema": "^1.4.1",
|
||||||
"jspdf": "^2.5.1",
|
"jspdf": "^2.5.1",
|
||||||
"lexical": "^0.12.5",
|
"lexical": "^0.12.5",
|
||||||
"node-sql-parser": "^4.17.0",
|
"node-sql-parser": "^5.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-hotkeys-hook": "^4.4.1",
|
"react-hotkeys-hook": "^4.4.1",
|
||||||
@ -1715,6 +1715,11 @@
|
|||||||
"@babel/types": "^7.20.7"
|
"@babel/types": "^7.20.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/pegjs": {
|
||||||
|
"version": "0.10.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/pegjs/-/pegjs-0.10.6.tgz",
|
||||||
|
"integrity": "sha512-eLYXDbZWXh2uxf+w8sXS8d6KSoXTswfps6fvCUuVAGN8eRpfe7h9eSRydxiSJvo9Bf+GzifsDOr9TMQlmJdmkw=="
|
||||||
|
},
|
||||||
"node_modules/@types/prop-types": {
|
"node_modules/@types/prop-types": {
|
||||||
"version": "15.7.11",
|
"version": "15.7.11",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz",
|
||||||
@ -4368,10 +4373,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/node-sql-parser": {
|
"node_modules/node-sql-parser": {
|
||||||
"version": "4.17.0",
|
"version": "5.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-4.17.0.tgz",
|
"resolved": "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-5.0.0.tgz",
|
||||||
"integrity": "sha512-3IhovpmUBpcETnoKK/KBdkz2mz53kVG5E1dnqz1QuYvtzdxYZW5xaGGEvW9u6Yyy2ivwR3eUZrn9inmEVef02w==",
|
"integrity": "sha512-hkNU1gIT8BNe8vmcsU7uYie0gzow/6AIj5KnGRBJQSZlgEu1NNuLVS11it5gAEdpmvJHelc34BwR439Iela+zQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/pegjs": "^0.10.0",
|
||||||
"big-integer": "^1.6.48"
|
"big-integer": "^1.6.48"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
"jsonschema": "^1.4.1",
|
"jsonschema": "^1.4.1",
|
||||||
"jspdf": "^2.5.1",
|
"jspdf": "^2.5.1",
|
||||||
"lexical": "^0.12.5",
|
"lexical": "^0.12.5",
|
||||||
"node-sql-parser": "^4.17.0",
|
"node-sql-parser": "^5.0.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"react-hotkeys-hook": "^4.4.1",
|
"react-hotkeys-hook": "^4.4.1",
|
||||||
|
@ -31,7 +31,30 @@ export function astToDiagram(ast) {
|
|||||||
field.primary = false;
|
field.primary = false;
|
||||||
if (d.primary_key) field.primary = true;
|
if (d.primary_key) field.primary = true;
|
||||||
field.default = "";
|
field.default = "";
|
||||||
if (d.default_val) field.default = d.default_val.value.value.toString();
|
if (d.default_val) {
|
||||||
|
let defaultValue = "";
|
||||||
|
if (d.default_val.value.type === "function") {
|
||||||
|
defaultValue = d.default_val.value.name;
|
||||||
|
if (d.default_val.value.args) {
|
||||||
|
defaultValue +=
|
||||||
|
"(" +
|
||||||
|
d.default_val.value.args.value
|
||||||
|
.map((v) => {
|
||||||
|
if (
|
||||||
|
v.type === "single_quote_string" ||
|
||||||
|
v.type === "double_quote_string"
|
||||||
|
)
|
||||||
|
return "'" + v.value + "'";
|
||||||
|
return v.value;
|
||||||
|
})
|
||||||
|
.join(", ") +
|
||||||
|
")";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
defaultValue = d.default_val.value.value.toString();
|
||||||
|
}
|
||||||
|
field.default = defaultValue;
|
||||||
|
}
|
||||||
if (d.definition["length"]) field.size = d.definition["length"];
|
if (d.definition["length"]) field.size = d.definition["length"];
|
||||||
field.check = "";
|
field.check = "";
|
||||||
if (d.check) {
|
if (d.check) {
|
||||||
@ -135,7 +158,7 @@ export function astToDiagram(ast) {
|
|||||||
deleteConstraint[0].toUpperCase() +
|
deleteConstraint[0].toUpperCase() +
|
||||||
deleteConstraint.substring(1);
|
deleteConstraint.substring(1);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
let startTableId = -1;
|
let startTableId = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user