Skip to content

Automated SQL CHECK Constraint Generation #178

Description

@alan-francis

I would like to propose an enhancement to the library to automate the generation of SQL CHECK constraints, taking into consideration existing unique constraints. Currently, users manually specify CHECK constraints when creating tables, which can be cumbersome and prone to errors.

I suggest incorporating a feature into the library that simplifies the definition of SQL CHECK constraints. Users should be able to express constraints more abstractly, specifying the allowed values for a column without having to write the entire CHECK constraint manually.

Consider the following SQL table creation script with both UNIQUE and CHECK constraints:


CREATE TABLE "synthetic_table_with_constraints" (
    "text_primary_key" TEXT PRIMARY KEY NOT NULL,
    "column_unique" TEXT NOT NULL,
    "column_check" TEXT NOT NULL CHECK (column_check IN('ACTIVE','INACTIVE')),
    "created_at" DATE,
    UNIQUE("column_unique")
);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions