Skip to content

Add the EMC group for matching Rules #1

@Neewolag

Description

@Neewolag

Curently, the Expand Migrate Contract patern requires to encapsulate each step in different --noqa flags.

Example:

-- Expend column
ALTER TABLE customer
    ADD COLUMN last_connection_at_utc timestamp without time zone;

-- Migrate data in new column: datetime in Europe/Paris is converted to UTC
--noqa: disable=LL01
UPDATE customer
SET last_connection_at_utc = (last_connection_at::timestamp without time zone AT TIME ZONE 'Europe/Paris')::timestamp without time zone;
--noqa: enable=LL01

-- Contract column
--noqa: disable=LL06
ALTER TABLE customer
    DROP COLUMN last_connection_at;
--noqa: enable=LL06
--noqa: disable=LL05
ALTER TABLE customer
    RENAME COLUMN last_connection_at_utc TO last_connection_at;
--noqa: enable=LL05

This makes the usage of SQLFluff tideous. This could be improved by adding the Rules involved in the usage of the patern (LL01, LL05 & LL06 in our example) to a new group called EMC. This would enable you to encapsulate the whole pattern.

Example:

--noqa: disable=EMC
-- Expend column
ALTER TABLE customer
    ADD COLUMN last_connection_at_utc timestamp without time zone;

-- Migrate data in new column: datetime in Europe/Paris is converted to UTC
UPDATE customer
SET last_connection_at_utc = (last_connection_at::timestamp without time zone AT TIME ZONE 'Europe/Paris')::timestamp without time zone;

-- Contract column
ALTER TABLE customer
    DROP COLUMN last_connection_at;
ALTER TABLE customer
    RENAME COLUMN last_connection_at_utc TO last_connection_at;
--noqa: enable=EMC

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions