holistics / holistics/dbml

sql2dbml fail to generate note if dbo specified

Open
#489 1 comment 0 reactions 1 assignee Claimed by @huydo862003 View on GitHub
bug
Dominant language
JavaScript
Stars
3.7k
Forks
233
Avg merge
1d 23h
Merged PRs (30d)
4

Description

Hi,

When you explicitly specify the dbo schema in front of the table, if comments are added to a column with EXEC sp_addextendedproperty (by specifying the dbo schema), these will not appear in the "note" of the columns concerned in the generated dbml via sql2dbml

Let's take the DDL noschema_specified_is_OK.sql
```
>>> cat ok.sql
CREATE TABLE mytable(
a int
)
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'This is the description of my column',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'mytable',
@level2type = N'Column', @level2name = 'a'
GO

>>> sql2dbml --mssql noschema_specified_is_OK.sql
Table "mytable" {
"a" int [note: 'This is the description of my column']
}
```
All is fine here.

Now try with specified_schema_is_OK.sql
```
>>> cat specified_schema_is_OK.sql
CREATE TABLE myschema.mytable(
a int
)
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'This is the description of my column',
@level0type = N'Schema', @level0name = 'myschema',
@level1type = N'Table', @level1name = 'mytable',
@level2type = N'Column', @level2name = 'a'
GO

>>> sql2dbml --mssql specified_schema_is_OK.sql
Table "myschema"."mytable" {
"a" int [note: 'This is the description of my column']
}
```
All is fine here.

Now try with replacing **myschema** by **dbo** in file specified_dbo_is_NOK.sql
```
>>> cat specified_dbo_is_NOK.sql
CREATE TABLE dbo.mytable(
a int
)
GO

EXEC sp_addextendedproperty
@name = N'Column_Description',
@value = 'This is the description of my column',
@level0type = N'Schema', @level0name = 'dbo',
@level1type = N'Table', @level1name = 'mytable',
@level2type = N'Column', @level2name = 'a'
GO

>>> sql2dbml --mssql specified_dbo_is_NOK.sql
Table "dbo"."mytable" {
"a" int
}
```
In this case, there is a problem, the note corresponding to column's a comment doesn't appears

```
>>>sql2dbml --version
3.0.0
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.