drawdb/test/oracle_export.test.js
lethalSopaper d95b86b7b5
Pull-request para export a Oracle (#4)
* Permito deployment en un subfolder

* Remove vercel/analytics

* Remove vercel/analytics

* Remove vercel/analytics

* Revert "Permito deployment en un subfolder"

This reverts commit e7aedc3ecf.

* Boton de oracle funciona pero no add table

* datatypes.js fixed

* export oracle funciona, falta formato adecuado

* Agregando convenciones a constraints

* Cambiando detalle de unique constraint

* Adding a test for diagram exports to oracle

* tests for constraints added

* Correccion de la funcion check

* vercel added and tests run with npm run lint

* little fixes, vercel added in datatypes and main.jsx

* Delete tatus file added by mistake

---------

Co-authored-by: Francisco-Galindo <paqui10718@gmail.com>
Co-authored-by: hansmarcus <hansmarcus14@gmail.com>
Co-authored-by: Pablo Estrada <pabloem@apache.org>
2025-02-06 23:41:42 -05:00

75 lines
1.6 KiB
JavaScript

/* eslint-env jest */
import { toOracle } from "../src/utils/exportSQL/oracle.js";
import { DB } from "../src/data/constants.js";
describe("toOracle", () => {
test("should generate correct Oracle SQL for tables with relationships", () => {
const diagram = {
database: DB.ORACLE,
tables: [
{
name: "casa",
fields: [
{
name: "id",
type: "NUMBER",
size: "10,0",
notNull: true,
unique: true,
primary: true,
default: ""
},
{
name: "xd",
type: "VARCHAR",
size: "255",
notNull: true,
default: ""
}
],
indices: []
},
{
name: "cuarto",
fields: [
{
name: "id",
type: "NUMBER",
unique: true,
primary: true,
default: ""
}
],
indices: []
}
],
references: [
{
startTableId: 0,
startFieldId: 0,
endTableId: 1,
endFieldId: 0
}
]
};
const expectedSQL = `CREATE TABLE casa (
\t"id" NUMBER(10,0) NOT NULL,
\t"xd" VARCHAR(255) NOT NULL,
\tCONSTRAINT casa_pk PRIMARY KEY("id")
);
CREATE TABLE cuarto (
\t"id" NUMBER,
\tCONSTRAINT cuarto_pk PRIMARY KEY("id")
);
ALTER TABLE casa ADD CONSTRAINT casa_id_fk
FOREIGN KEY("id") REFERENCES cuarto("id");`;
const result = toOracle(diagram);
expect(result.trim()).toBe(expectedSQL.trim());
});
});