holistics/dbml

Proposal: Make Ref syntax resilient to line breaks

Closed this issue · 1 comments

Objective:

Make it possible to break a Ref foreign key definition into multiple lines if needed.

Syntax:

Currently it's only possible to define a foreign key in a single line:

Ref "FK_DependentTable_MainTable_ColumnName" {
    "schema"."DependentTable"."ColumnName" > "schema"."MainTable"."ColumnName"
}

The problem happens when there's a composite key with 3-4 columns:

Ref "FK_DependentTable_MainTable_MultipleColumns" {
    "schema"."DependentTable".("ColumnName1", "ColumnName2", "ColumnName3") > "schema"."MainTable".("ColumnName1", "ColumnName2", "ColumnName3")
}

With enough luck, it's possible to score for a 200-300 characters line, which is not comfortable to edit or even view.

The proposal is to allow breaking the line at least before or after the </>/<> symbols:

Ref "FK_DependentTable_MainTable_MultipleColumns" {
    "schema"."DependentTable".("ColumnName1", "ColumnName2", "ColumnName3") >
        "schema"."MainTable".("ColumnName1", "ColumnName2", "ColumnName3")
}

Currently it is not possible and leads to a parsing error:

(Line:Character) Expected " " or valid name but "\n" found.

Well, current version of the DBML parser supports line breaks now. Closing this issue as not relevant anymore.