diff --git a/src/main/resources/org/schemaspy/types/mssql17-jtds.properties b/src/main/resources/org/schemaspy/types/mssql17-jtds.properties new file mode 100644 index 000000000..9cb6f8118 --- /dev/null +++ b/src/main/resources/org/schemaspy/types/mssql17-jtds.properties @@ -0,0 +1,31 @@ +# +# Copyright (C) 2020 Nils Petzaell +# +# This file is part of SchemaSpy. +# +# SchemaSpy is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SchemaSpy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with SchemaSpy. If not, see . +# +extends=mssql08-jtds + +selectViewSql=select sm.definition as view_definition from sys.objects so left join sys.sql_modules sm on so.object_id = sm.object_id where so.[type] = 'V' and so.name =:table +selectCheckConstraintsSql=select OBJECT_NAME(parent_object_id) as table_name, name AS constraint_name, definition as text from sys.check_constraints + +selectCatalogsSql=SELECT cast(value as nvarchar(max)) as catalog_comment FROM fn_listextendedproperty(N'MS_Description', default, default, default, default, default, default) +selectSchemasSql=SELECT cast(value as nvarchar(max)) as schema_comment FROM fn_listextendedproperty(N'MS_Description', N'schema', :schema, default, default, default, default) +selectTableCommentsSql=SELECT objname as table_name, cast(value as nvarchar(max)) as comments FROM fn_listextendedproperty(N'MS_Description', N'schema', :schema, 'table', null, default, default) +selectColumnCommentsSql=select x.table_name, x.column_name, x.comments from ( select t.name as table_name, c.name as column_name, cast((SELECT value from fn_listextendedproperty(N'MS_Description', N'schema', SCHEMA_NAME(t.schema_id), 'table', t.name, 'column', c.name)) as NVARCHAR(MAX)) as comments from sys.tables t left join sys.columns c on (t.object_id = c.object_id) where SCHEMA_NAME(t.schema_id) = :schema ) x where not x.comments is null +selectViewCommentsSql=SELECT objname as view_name, cast(value as nvarchar(max)) as comments FROM fn_listextendedproperty(N'MS_Description', N'schema', :schema, 'view', null, default, default) +selectViewColumnCommentsSql=select x.view_name, x.column_name, x.comments from ( select v.name as view_name, c.name as column_name, cast((SELECT value from fn_listextendedproperty(N'MS_Description', N'schema', SCHEMA_NAME(v.schema_id), 'view', v.name, 'column', c.name)) as NVARCHAR(MAX)) as comments from sys.views v left join sys.columns c on (v.object_id = c.object_id) where SCHEMA_NAME(v.schema_id) = :schema ) x where not x.comments is null + +selectRoutinesSql=SELECT i_s.routine_name, i_s.routine_type, i_s.data_type AS dtd_identifier, i_s.routine_body, i_s.routine_definition, i_s.is_deterministic, i_s.sql_data_access, NULL AS security_type, NULL AS sql_mode, (select cast(value as nvarchar(max)) from fn_listextendedproperty(N'MS_Description', N'schema', i_s.routine_schema, 'procedure', i_s.ROUTINE_NAME, default, default)) AS routine_comment FROM information_schema.routines i_s WHERE routine_schema = :schema \ No newline at end of file diff --git a/src/main/resources/org/schemaspy/types/mssql17.properties b/src/main/resources/org/schemaspy/types/mssql17.properties new file mode 100644 index 000000000..af586c6ed --- /dev/null +++ b/src/main/resources/org/schemaspy/types/mssql17.properties @@ -0,0 +1,31 @@ +# +# Copyright (C) 2020 Nils Petzaell +# +# This file is part of SchemaSpy. +# +# SchemaSpy is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# SchemaSpy is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with SchemaSpy. If not, see . +# +extends=mssql08 + +selectViewSql=select sm.definition as view_definition from sys.objects so left join sys.sql_modules sm on so.object_id = sm.object_id where so.[type] = 'V' and so.name =:table +selectCheckConstraintsSql=select OBJECT_NAME(parent_object_id) as table_name, name AS constraint_name, definition as text from sys.check_constraints + +selectCatalogsSql=SELECT cast(value as nvarchar(max)) as catalog_comment FROM fn_listextendedproperty(N'MS_Description', default, default, default, default, default, default) +selectSchemasSql=SELECT cast(value as nvarchar(max)) as schema_comment FROM fn_listextendedproperty(N'MS_Description', N'schema', :schema, default, default, default, default) +selectTableCommentsSql=SELECT objname as table_name, cast(value as nvarchar(max)) as comments FROM fn_listextendedproperty(N'MS_Description', N'schema', :schema, 'table', null, default, default) +selectColumnCommentsSql=select x.table_name, x.column_name, x.comments from ( select t.name as table_name, c.name as column_name, cast((SELECT value from fn_listextendedproperty(N'MS_Description', N'schema', SCHEMA_NAME(t.schema_id), 'table', t.name, 'column', c.name)) as NVARCHAR(MAX)) as comments from sys.tables t left join sys.columns c on (t.object_id = c.object_id) where SCHEMA_NAME(t.schema_id) = :schema ) x where not x.comments is null +selectViewCommentsSql=SELECT objname as view_name, cast(value as nvarchar(max)) as comments FROM fn_listextendedproperty(N'MS_Description', N'schema', :schema, 'view', null, default, default) +selectViewColumnCommentsSql=select x.view_name, x.column_name, x.comments from ( select v.name as view_name, c.name as column_name, cast((SELECT value from fn_listextendedproperty(N'MS_Description', N'schema', SCHEMA_NAME(v.schema_id), 'view', v.name, 'column', c.name)) as NVARCHAR(MAX)) as comments from sys.views v left join sys.columns c on (v.object_id = c.object_id) where SCHEMA_NAME(v.schema_id) = :schema ) x where not x.comments is null + +selectRoutinesSql=SELECT i_s.routine_name, i_s.routine_type, i_s.data_type AS dtd_identifier, i_s.routine_body, i_s.routine_definition, i_s.is_deterministic, i_s.sql_data_access, NULL AS security_type, NULL AS sql_mode, (select cast(value as nvarchar(max)) from fn_listextendedproperty(N'MS_Description', N'schema', i_s.routine_schema, 'procedure', i_s.ROUTINE_NAME, default, default)) AS routine_comment FROM information_schema.routines i_s WHERE routine_schema = :schema \ No newline at end of file diff --git a/src/test/java/org/schemaspy/integrationtesting/MssqlServerSuite.java b/src/test/java/org/schemaspy/integrationtesting/MssqlServerSuite.java index b08043627..b2bedba73 100644 --- a/src/test/java/org/schemaspy/integrationtesting/MssqlServerSuite.java +++ b/src/test/java/org/schemaspy/integrationtesting/MssqlServerSuite.java @@ -40,9 +40,11 @@ }) public class MssqlServerSuite { + public static final String IMAGE_NAME = "mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-16.04"; + @ClassRule public static JdbcContainerRule jdbcContainerRule = - new JdbcContainerRule<>(() -> new MSSQLContainer("microsoft/mssql-server-linux:2017-CU6")) + new JdbcContainerRule<>(() -> new MSSQLContainer(IMAGE_NAME)) .assumeDockerIsPresent() .withAssumptions(assumeDriverIsPresent()) .withInitFunctions(new SQLScriptsRunner("integrationTesting/mssqlserver/dbScripts/")); diff --git a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCheckConstraintIT.java b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCheckConstraintIT.java index 0b1e8deb6..e6aec621d 100644 --- a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCheckConstraintIT.java +++ b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCheckConstraintIT.java @@ -50,6 +50,7 @@ import static com.github.npetzall.testcontainers.junit.jdbc.JdbcAssumptions.assumeDriverIsPresent; import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.BDDMockito.given; +import static org.schemaspy.integrationtesting.MssqlServerSuite.IMAGE_NAME; @RunWith(SpringRunner.class) @SpringBootTest @@ -75,7 +76,7 @@ public class MSSQLServerCheckConstraintIT { public static JdbcContainerRule jdbcContainerRule = new SuiteOrTestJdbcContainerRule<>( MssqlServerSuite.jdbcContainerRule, - new JdbcContainerRule<>(() -> new MSSQLContainer("microsoft/mssql-server-linux:2017-CU6")) + new JdbcContainerRule<>(() -> new MSSQLContainer(IMAGE_NAME)) .assumeDockerIsPresent() .withAssumptions(assumeDriverIsPresent()) .withInitScript("integrationTesting/mssqlserver/dbScripts/check_constraint.sql") @@ -90,7 +91,7 @@ public synchronized void gatheringSchemaDetailsTest() throws SQLException, IOExc private void createDatabaseRepresentation() throws SQLException, IOException, URISyntaxException { String[] args = { - "-t", "mssql08", + "-t", "mssql17", "-db", "CheckConstraint", "-s", "CheckConstraint", "-cat", "CheckConstraint", diff --git a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCommentsIT.java b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCommentsIT.java index 3cfe7e45f..b415bb5a5 100644 --- a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCommentsIT.java +++ b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerCommentsIT.java @@ -49,6 +49,7 @@ import static com.github.npetzall.testcontainers.junit.jdbc.JdbcAssumptions.assumeDriverIsPresent; import static org.mockito.BDDMockito.given; +import static org.schemaspy.integrationtesting.MssqlServerSuite.IMAGE_NAME; /** * @author Rafal Kasa @@ -93,7 +94,7 @@ public class MSSQLServerCommentsIT { public static JdbcContainerRule jdbcContainerRule = new SuiteOrTestJdbcContainerRule<>( MssqlServerSuite.jdbcContainerRule, - new JdbcContainerRule<>(() -> new MSSQLContainer("microsoft/mssql-server-linux:2017-CU6")) + new JdbcContainerRule<>(() -> new MSSQLContainer(IMAGE_NAME)) .assumeDockerIsPresent() .withAssumptions(assumeDriverIsPresent()) .withInitScript("integrationTesting/mssqlserver/dbScripts/mssql_comments.sql") @@ -143,7 +144,7 @@ public synchronized void gatheringSchemaDetailsTest() throws SQLException, IOExc private Database createDatabaseRepresentation(String db, String schema) throws SQLException, IOException, URISyntaxException { String[] args = { - "-t", "mssql08", + "-t", "mssql17", "-db", db, "-s", schema, "-cat", "%", diff --git a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerHTMLIT.java b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerHTMLIT.java index 708578fe6..367e91c46 100644 --- a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerHTMLIT.java +++ b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerHTMLIT.java @@ -47,6 +47,7 @@ import static com.github.npetzall.testcontainers.junit.jdbc.JdbcAssumptions.assumeDriverIsPresent; import static org.assertj.core.api.Assertions.assertThat; +import static org.schemaspy.integrationtesting.MssqlServerSuite.IMAGE_NAME; /** * @author Nils Petzaell @@ -64,7 +65,7 @@ public class MSSQLServerHTMLIT { public static JdbcContainerRule jdbcContainerRule = new SuiteOrTestJdbcContainerRule<>( MssqlServerSuite.jdbcContainerRule, - new JdbcContainerRule<>(() -> new MSSQLContainer("microsoft/mssql-server-linux:2017-CU6")) + new JdbcContainerRule<>(() -> new MSSQLContainer(IMAGE_NAME)) .assumeDockerIsPresent() .withAssumptions(assumeDriverIsPresent()) .withInitScript("integrationTesting/mssqlserver/dbScripts/htmlit.sql") @@ -79,7 +80,7 @@ public class MSSQLServerHTMLIT { public void generateHTML() throws Exception { if (shouldRun.get()) { String[] args = new String[]{ - "-t", "mssql08", + "-t", "mssql17", "-db", "htmlit", "-s", "htmlit", "-cat", "htmlit", diff --git a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerRemoteTablesIT.java b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerRemoteTablesIT.java index fb3e87a2a..e56076086 100644 --- a/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerRemoteTablesIT.java +++ b/src/test/java/org/schemaspy/integrationtesting/mssqlserver/MSSQLServerRemoteTablesIT.java @@ -47,6 +47,7 @@ import static com.github.npetzall.testcontainers.junit.jdbc.JdbcAssumptions.assumeDriverIsPresent; import static org.assertj.core.api.Assertions.assertThat; +import static org.schemaspy.integrationtesting.MssqlServerSuite.IMAGE_NAME; /** * @author Rafal Kasa @@ -74,7 +75,7 @@ public class MSSQLServerRemoteTablesIT { public static JdbcContainerRule jdbcContainerRule = new SuiteOrTestJdbcContainerRule<>( MssqlServerSuite.jdbcContainerRule, - new JdbcContainerRule<>(() -> new MSSQLContainer("microsoft/mssql-server-linux:2017-CU6")) + new JdbcContainerRule<>(() -> new MSSQLContainer(IMAGE_NAME)) .assumeDockerIsPresent() .withAssumptions(assumeDriverIsPresent()) .withInitScript("integrationTesting/mssqlserver/dbScripts/mssql_remote_tables.sql") @@ -89,7 +90,7 @@ public synchronized void gatheringSchemaDetailsTest() throws SQLException, IOExc private void createDatabaseRepresentation() throws SQLException, IOException, URISyntaxException { String[] args = { - "-t", "mssql08", + "-t", "mssql17", "-db", "ACME", "-o", "target/integrationtesting/mssql", "-u", "schemaspy", diff --git a/src/test/resources/container-license-acceptance.txt b/src/test/resources/container-license-acceptance.txt index b546fb081..acd90f89c 100644 --- a/src/test/resources/container-license-acceptance.txt +++ b/src/test/resources/container-license-acceptance.txt @@ -1 +1,2 @@ -microsoft/mssql-server-linux:2017-CU6 \ No newline at end of file +microsoft/mssql-server-linux:2017-CU6 +mcr.microsoft.com/mssql/server:2019-CU3-ubuntu-16.04 \ No newline at end of file