-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails on comment after closing brace in Table spec #27
Comments
The comments are evaluated prior to the object being defined. So this should evaluate:
Additionally, you can use the Project DBML object to store metadata:
You can access it via the |
Sorry for a very late reply: I was afk most of the previous weeks due to moving. I've fixed the error in 1.0.8, thanks a lot for reporting! As @mjfii pointed out, currently PyDBML attaches the comments, which are put directly before the Table, into the parsed Table object. Same behavior is true for any other entity: a comment before the entity gets into the parsed object. To illustrate it on @mjfii 's example: >>> from pydbml import PyDBML
>>> source = '''
... // maria: [engine: innodb, charset: utf8]
... Table nameSuffixOptions {
... id int(11) [primary key, increment]
... suffix varchar(7) [not null]
... sortOrder int(11) [not null]
... createdAt timestamp [default: `CURRENT_TIMESTAMP`]
... // maria: [ onupdate: `CURRENT_TIMESTAMP`]
... updatedAt timestamp [default: `CURRENT_TIMESTAMP`]
... note: 'Options for name suffixes: Sr., Jr., etc'
... }
... '''
>>> parsed = PyDBML(source)
>>> parsed.tables[0].comment # the table object has the comment attribute
'maria: [engine: innodb, charset: utf8]'
>>> parsed.tables[0]['updatedAt']
<Column 'updatedAt', 'timestamp'>
>>> parsed.tables[0]['updatedAt'].comment # the column `updatedAt` also has the comment, defined right before it
'maria: [ onupdate: `CURRENT_TIMESTAMP`]' |
The error:
pyparsing.exceptions.ParseException: Expected {LineEnd | StringEnd}, found '/' (at char 1112), (line:31, col:3)
Expected behavior:
Personally, I'd like if the comments were put in the
<Database>
object attached to the table or column as appropriate, as I need to extend dbml for mariadb features they don't support. But at a minimum, it seems like having the parser ignoring comments totally is better than failing.This dbml snippet will reproduce:
The text was updated successfully, but these errors were encountered: