Improvement: New DBML Parser

We are thrilled to announce the release of our new DBML parser, bringing a range of improvements and exciting features to enhance your experience!

The new parser has been rebuilt from the ground up, resulting in a more powerful and efficient parsing process. Here are the key highlights:

  • :white_check_mark: Improved Error Reporting: Previously, only one syntax error would be displayed at a time; now, you will receive more precise and detailed error messages, allowing you to locate and resolve issues with your DBML files more quickly.

  • :white_check_mark: Better Performance: The new parser is more efficient, meaning your DBML projects will load and render faster while using fewer resources. Our benchmarks measure an up to 8x increase in parsing speed.

  • :white_check_mark: Enhanced Editing Experience: Listening to your feedback, the new parser now offers more precise typing suggestions and the ability to jump to code definition.

    go-to-code-definition

    type-suggestion

  • :arrow_right: Future-proofing: The new parser has been designed with extensibility in mind, allowing us to add exciting new features in the future. Stay tuned for upcoming enhancements such as including other DBML files, object inheritance, etc.

Please note that there may be compatibility issues because the new parser has been rebuilt with a different architecture. To ensure a seamless transition, we have compiled a list of known issues along with examples (see post below) to help you quickly address them. Our support team is also ready to assist you with any questions or concerns.

Thank you for your continued support and trust in our products.

From dbx team with :heart:

7 Likes

The list of known compatibility issues and their fixes is as follows:

1. Table settings now require a white space after table names.

Example of incorrect code:

Table users[headercolor: #3498DB] { // error
    id integer [primary key]
    username varchar(255) [not null, unique]
}

Correction: add white space between table name and table settings

Table users [headercolor: #3498DB] {
    id integer [primary key]
    username varchar(255) [not null, unique]
}

Tips: you can use the text editor find and replace function (Ctrl/Cmd+F) to quickly update all such occurrences in your dbml by simply replacing (?<=[^\s])\[headercolor: with [headercolor:
unnamed


2. Note and Indexes definition can’t contain line breaks before the opening bracket {...}

Example of incorrect code:

Table user 
{
  id integer
  Indexes // error   
  {
    id [pk]
  }
  Note // error
  {
    'the user table'
  }
}

Correction: remove the line break between indexes/note and the bracket {...}

Table user 
{
  id integer
  Indexes {
    id [pk]
  }
  Note {
    'the user table'
  }
}

3. Single quotes and double quotes no longer can be used to enclose multi-line strings inside a note

Example of incorrect code:

Table orders {
    status varchar [
    note: ' // error
    💸 1 = processing, 
    ✔️ 2 = shipped, 
    ❌ 3 = cancelled,
    😔 4 = refunded
    ']
}

Correction: Replace single quotes with triple quotes for multi-line strings

Table orders {
    status varchar [
    note: '''
    💸 1 = processing, 
    ✔️ 2 = shipped, 
    ❌ 3 = cancelled,
    😔 4 = refunded
    ''']
}

If you encounter other issues, please let us know by commenting below and we will take a look.

3 Likes

Hello,
We have user defined datatypes:

Table stage.t_mapping {
mapping_name [Name] [PK, NOT NULL]
project_name [Name] [PK, NOT NULL]
mapping_json [JSON]
}

Now the diagram doesn’t compile, as it says: Invalid column type.
Please help.

Hi @Dmytro_Boiko ,

Since column type enclosed in square brackets was not part of our original language design, we were unaware that this syntax was possible. For your situation, a straightforward fix is to surround these special kinds in double quotations, as in this example:

Table stage.t_mapping {
mapping_name "[Name]" [PK, NOT NULL]
project_name "[Name]" [PK, NOT NULL]
mapping_json "[JSON]"
}

Alternatively, you also remove the square brackets from the column type to use it as standard syntax:

Table stage.t_mapping {
mapping_name Name [PK, NOT NULL]
project_name Name [PK, NOT NULL]
mapping_json JSON
}

Thanks, this worked.

I recently started using Markdown syntax in my notes. In the example below, the Code Block syntax (defined by 4 spaces at the start of the line) stopped working with the new engine. The text is now just all run together.

The other elements work fine, #'s for different heading levels and - to show a checkbox.

The only trouble is with the code block.

note:
‘’’

Development Notes

1/21/24

  • Add fields to table

1/31/2024

  • Rename field
  • Update where condition

SQL Query

SELECT  
    COLUMN1,  
    COLUMN2,  
    COLUMN3  
FROM
    TABLE

‘’’

@Thi_Nguyen Regarding new rules for quotes, it requires a change in sql2dbml: fix(notes): properly escape notes with new lines by pierresouchay · Pull Request #503 · holistics/dbml · GitHub

hi @Thi_Nguyen ,

Are you updating the vscode extension ?

Thank you for reporting the issue.

Update: We have fixed the code block issue; please check it out and let us know if you still have any issues.

Thank you for bringing this up.

Our team is looking into it.

Unfortunately, the answer is no.

We will consider creating an official VSCode extension for DBML in the future as the existing one is not our own.

The Code Block issue is resolved. Thank you.

1 Like

Hi, double quotes no longer can be used to enclose multi-line strings too.
Also you cannot have more than one note anymore.

Cheers

Hi @viansrl,

Together with the change to single quotes, we no longer support multi-line string for double quotes also.
As an alternative, please use the designated triple quotes syntax for multi-line strings.

The ability to define multiple notes in tables was not in our original intention. Therefore we no longer support it.

Thanks.

(undefined:undefined) undefined

Really not a useful message on an import with no indication where the issue lies.

you are choking on this partitioned table

create table id_to_uuid_migration_map
(
column_name key_column_name_type not null,
int_key bigint not null,
uuid_key uuid,
constraint id_to_uuid_migration_pk
primary key (column_name, int_key),
constraint id_to_uuid_migration__uuid_uniq
unique (column_name, uuid_key)
)
partition by LIST (column_name);

alter table id_to_uuid_migration_map
owner to dw_admin;

create table id_to_uuid_migration_map__member_key
partition of id_to_uuid_migration_map
(
primary key (column_name, int_key),
unique (column_name, uuid_key),
constraint id_to_uuid_migration_map__c__member_key
check (column_name = ‘member_key’::key_column_name_type)
)
FOR VALUES IN (‘member_key’);

alter table id_to_uuid_migration_map__member_key
owner to dw_admin;

Hi Donald,

This is a bug related to our PostgreSQL Parser, our team will take a look and let you know when this is fixed.

@Pierre_Souchay We released a new update for dbdiagram containing your fixes. Notes containing new lines imported from SQL should work from now on.

Thank you for contributing to DBML.