drawdb/test/oracle_chk.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

47 lines
1.1 KiB
JavaScript

/* eslint-env jest */
import { toOracle } from "../src/utils/exportSQL/oracle.js";
import { DB } from "../src/data/constants.js";
describe("toOracle", () => {
test("test for check constraint in any field of a table", () => {
const diagram = {
database: DB.ORACLE,
tables: [
{
name: "salon",
fields: [
{
name: "salon_id",
type: "NUMBER",
size: "10,0",
notNull: true,
primary: true,
default: "",
},
{
name: "capacidad",
type: "NUMBER",
size: "10,0",
notNull: true,
default: "",
check: "> 0",
},
],
indices: [],
},
],
references: [],
};
const expectedSQL = `CREATE TABLE salon (
\t"salon_id" NUMBER(10,0) NOT NULL,
\t"capacidad" NUMBER(10,0) NOT NULL,
\tCONSTRAINT salon_capacidad_chk CHECK("capacidad" > 0),
\tCONSTRAINT salon_pk PRIMARY KEY("salon_id")
);`;
const result = toOracle(diagram);
expect(result.trim()).toBe(expectedSQL.trim());
});
});