PyDBML icon indicating copy to clipboard operation
PyDBML copied to clipboard

Not all comments are preserved & unclear expectations on comment preservation

Open LanHikari22 opened this issue 4 months ago • 0 comments

Hi,

I notice that when doing

// User Table has a comment
// It can even handle multiline
Table Users {
  id integer [primary key]

  // dbmt %signal is_valid_username allow=[insert, update]
  // dbmt %signal log_new_users notify=[insert]
  // dbmt %signal log_update_username notify=[update]
  username varchar

  role varchar

  // dbmt %signal get_date_now override=[insert]
  created_at varchar
}

The parser recognizes that the Users table has the comment "User Table has a comment\nIt can even handle multiline".

I expected the same behavior for columns. But It does not seem the dbmt comments are preserved anywhere. Not on the table nor any column.

I can see that a single line comment on the same line as the column does get recognized:

  username varchar // a comment on the same line works

Then the column username would have a comment "a comment on the same line works".

So what's the expectation with this? It would be good to document it. I didn't see any enforcing details in the dbml spec either besides just stating that comments exist in // and /* */ form.

More details on my investigation can be found in my dev notes.

Thanks, Mohammed

LanHikari22 avatar Aug 15 '25 09:08 LanHikari22