Skip to content
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

sql2dbml fail to generate note if dbo specified #489

Open
benjdv opened this issue Jan 9, 2024 · 1 comment
Open

sql2dbml fail to generate note if dbo specified #489

benjdv opened this issue Jan 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@benjdv
Copy link

benjdv commented Jan 9, 2024

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
@benjdv benjdv changed the title sql2dbml dbo comment fail if dbo specified sql2dbml dbo comment fail to generate note if dbo specified Jan 9, 2024
@benjdv benjdv changed the title sql2dbml dbo comment fail to generate note if dbo specified sql2dbml fail to generate note if dbo specified Jan 9, 2024
@nguyenalter
Copy link
Contributor

Hi @benjdv,

Thank you for reporting the issue. It's a bug that handles dbo schema inconsistently in our MSSQL parser. We will look into it soon.

Regards.

@nguyenalter nguyenalter added the bug Something isn't working label Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants