-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Hi,
I'm not sure if this is an issue, a feature request or a request for documentation. I'm quite new to NORMA and I'm liking the tool but I'm struggling to understand the full functionality and feel like I'm lacking some docs to review.
I'm generating PostgreSQL from an ORM model and recently noticed that a number of the constraints expressed in the model do not have a counterpart in the SQL and so can be violated in the database. I'm wondering whether I am doing something wrong that is causing the constraints to not be expressed in the SQL, or if not all constraints are supported by the code generation tool. If there are constraints that can be expressed in the model that cannot be translated into SQL, it would be good to understand what type(s) of constraint these are, so that I can implement it in the database or avoid relying on it.
As an example, consider this model:
Generating Postgres code from the above model gives the following:
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE;
CREATE SCHEMA IF NOT EXISTS ORMModel1;
SET search_path TO ORMMODEL1,"$user",public;
CREATE TABLE ORMModel1.ObjectType
(
objectTypeId SERIAL NOT NULL,
fact1 CHARACTER VARYING,
fact2 CHARACTER VARYING,
CONSTRAINT ObjectType_PK PRIMARY KEY(objectTypeId)
);
COMMIT WORK;
Note that the exor constraint is not enforced. I would have expected the generated code to look something like this (code amended by me):
START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE;
CREATE SCHEMA IF NOT EXISTS ORMModel1;
SET search_path TO ORMMODEL1,"$user",public;
CREATE TABLE ORMModel1.ObjectType (
objectTypeId SERIAL NOT NULL,
fact1 CHARACTER VARYING,
fact2 CHARACTER VARYING,
CONSTRAINT ObjectType_PK PRIMARY KEY (objectTypeId),
CONSTRAINT ExclusiveOrConstraint1 CHECK (
(fact1 IS NOT NULL AND fact2 IS NULL) OR (fact1 IS NULL AND fact2 IS NOT NULL)
)
);
COMMIT WORK;
Is there a way to get NORMA to generate code like this?
Documentation for NORMA that I've found and have been using is mostly the powerpoints found on orm.net under the Resources tab and some stack exchange questions. Are there other documentation resources? Information on the Pro tool is at youtube.com/@ORMSolutions. ORM Foundation seems to have been replaced with a scam site.
