Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation query for cardinality is not being generated when another necessity is present #326

Open
Ereski opened this issue Nov 18, 2019 · 0 comments

Comments

@Ereski
Copy link
Contributor

Ereski commented Nov 18, 2019

In this example:

Term: bar

Term: foo
    Concept Type: Integer (Type)

Fact Type: bar taints foo
    Necessity: each bar taints at least one foo
    Necessity: each bar taints a foo that is greater than 10.

sbvr-compiler does not generate a validation query for the first necessity, although the schema takes that into account:

                --
                -- Create table statements
                --

CREATE TABLE IF NOT EXISTS "bar" (
        "created at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
,       "id" SERIAL NOT NULL PRIMARY KEY
);

CREATE TABLE IF NOT EXISTS "bar-taints-foo" (
        "created at" TIMESTAMP DEFAULT CURRENT_TIMESTAMP NOT NULL
,       "bar" INTEGER NOT NULL
,       "taints-foo" INTEGER NOT NULL
,       "id" SERIAL NOT NULL PRIMARY KEY
,       FOREIGN KEY ("bar") REFERENCES "bar" ("id")
,       UNIQUE("bar", "taints-foo")
);



                --
                -- Rule validation queries
                --


-- It is necessary that each bar taints at least one foo
SELECT NOT EXISTS (
        SELECT 1
        FROM "bar" AS "bar.0"
        WHERE NOT EXISTS (
                SELECT "bar.0-taints-foo.1"."foo"
                FROM "bar-taints-foo" AS "bar.0-taints-foo.1"
                WHERE "bar.0-taints-foo.1"."bar" = "bar.0"."id"
        )
) AS "result";

If the second necessity is removed, the validation query for the first necessity is outputted as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant