MCPcopy
hub / github.com/drawdb-io/drawdb / jsonToOracleSQL

Function jsonToOracleSQL

src/utils/exportSQL/generic.js:587–662  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

585}
586
587export function jsonToOracleSQL(obj) {
588 return `${obj.tables
589 .map(
590 (table) =>
591 `${
592 table.fields.filter((f) => f.type === "ENUM" || f.type === "SET")
593 .length > 0
594 ? `${table.fields
595 .filter((f) => f.type === "ENUM" || f.type === "SET")
596 .map(
597 (f) =>
598 `CREATE DOMAIN "${f.name}_t" AS ENUM (${f.values
599 .map((v) => `'${v}'`)
600 .join(", ")});\n`,
601 )
602 .join("\n")}\n`
603 : ""
604 }${
605 table.comment === "" ? "" : `/* ${table.comment} */\n`
606 }CREATE TABLE "${table.name}" (\n${table.fields
607 .map(
608 (field) =>
609 `${field.comment === "" ? "" : ` -- ${field.comment}\n`} "${
610 field.name
611 }" ${getTypeString(field, obj.database, DB.ORACLESQL)}${
612 field.notNull ? " NOT NULL" : ""
613 }${field.increment ? " GENERATED ALWAYS AS IDENTITY" : ""}${
614 field.unique ? " UNIQUE" : ""
615 }${
616 field.default !== ""
617 ? ` DEFAULT ${parseDefault(field, obj.database)}`
618 : ""
619 }${
620 field.check === "" ||
621 !dbToTypes[obj.database][field.type].hasCheck
622 ? ""
623 : ` CHECK (${field.check})`
624 }`,
625 )
626 .join(",\n")}${
627 table.fields.filter((f) => f.primary).length > 0
628 ? `,\n PRIMARY KEY (${table.fields
629 .filter((f) => f.primary)
630 .map((f) => `"${f.name}"`)
631 .join(", ")})`
632 : ""
633 }${uniqueConstraintClause(table, (s) => `"${s}"`)}\n);\n${table.indices
634 .map(
635 (i) =>
636 `\nCREATE ${i.unique ? "UNIQUE " : ""}INDEX "${i.name}"\n ON "${
637 table.name
638 }" (${i.fields.map((f) => `"${f}"`).join(", ")});`,
639 )
640 .join("\n")}`,
641 )
642 .join("\n\n")}\n${obj.references
643 .map((r) => {
644 const { name: startName, fields: startFields } = obj.tables.find(

Callers 1

ControlPanelFunction · 0.90

Calls 4

parseDefaultFunction · 0.90
uniqueConstraintClauseFunction · 0.90
getFkColumnNamesFunction · 0.90
getTypeStringFunction · 0.85

Tested by

no test coverage detected