Skip to content

A line starting with - continues the expression on the line above #1006

Closed

Description

@Roshan1299

In an element body, a line that starts with an operator such as - is parsed as a continuation of the previous line's expression, even when that line is complete on its own (and across a blank line). For example, a Records row that starts with a negative number fails unless it is the first row:

Table scores {
  id int
  delta int
}

Records scores(id, delta) {
  1, 5
  -2, 7
}

fails with "Records can only contain simple values (literals, null, true, false, or enum references). Complex expressions are not allowed." on the -2, 7 line, because it is read as 5 - 2, 7. The same rows in the other order (-2, 7 first) export fine.

The parser already stops ( at the start of a line outside () and [] (expression_bp in packages/dbml-parse/src/core/parser/parser.ts), but an infix operator continues across the newline. Applying the same rule to every infix operator breaks 10 existing parser tests (fuzz tests on refs among them), so the fix probably has to be limited to element bodies, as discussed in #172.

This also blocks the -col syntax agreed in #172: -created_at on any line but the first of an Indexes block is read as a subtraction from the line above.

Reproduced on master at 9ffe17ac.

Activity

  1. Roshan1299 commented on Oct 17, 2026

    @Roshan1299
    ContributorAuthor

    Hi @huydo862003 , I've opened a PR here:#1007 - would appreciate a review when you get a chance!

  2. huydo862003 commented on Oct 17, 2026

    @huydo862003
    Contributor

    @Roshan1299 Hi, thank you for your PR! I'll have a look into it next week!

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