Skip to content

Commit c6010b9

Browse files
committed
#882 Implement DatabaseMetaData informational methods to report schema support
1 parent b6821ee commit c6010b9

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

src/main/org/firebirdsql/jdbc/FBDatabaseMetaData.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -764,12 +764,11 @@ public boolean supportsLimitedOuterJoins() throws SQLException {
764764
/**
765765
* {@inheritDoc}
766766
*
767-
* @return the vendor term, always {@code null} because schemas are not supported by database server (see JDBC CTS
768-
* for details).
767+
* @return the vendor term; for Firebird 5.0 and older always {@code null} because schemas are not supported
769768
*/
770769
@Override
771770
public String getSchemaTerm() throws SQLException {
772-
return null;
771+
return firebirdSupportInfo.supportsSchemas() ? "SCHEMA" : null;
773772
}
774773

775774
@Override
@@ -814,27 +813,27 @@ public String getCatalogSeparator() throws SQLException {
814813

815814
@Override
816815
public boolean supportsSchemasInDataManipulation() throws SQLException {
817-
return false;
816+
return firebirdSupportInfo.supportsSchemas();
818817
}
819818

820819
@Override
821820
public boolean supportsSchemasInProcedureCalls() throws SQLException {
822-
return false;
821+
return firebirdSupportInfo.supportsSchemas();
823822
}
824823

825824
@Override
826825
public boolean supportsSchemasInTableDefinitions() throws SQLException {
827-
return false;
826+
return firebirdSupportInfo.supportsSchemas();
828827
}
829828

830829
@Override
831830
public boolean supportsSchemasInIndexDefinitions() throws SQLException {
832-
return false;
831+
return firebirdSupportInfo.supportsSchemas();
833832
}
834833

835834
@Override
836835
public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
837-
return false;
836+
return firebirdSupportInfo.supportsSchemas();
838837
}
839838

840839
/**
@@ -1031,7 +1030,7 @@ public int getMaxIndexLength() throws SQLException {
10311030

10321031
@Override
10331032
public int getMaxSchemaNameLength() throws SQLException {
1034-
return 0; //No schemas
1033+
return firebirdSupportInfo.supportsSchemas() ? getMaxObjectNameLength() : 0;
10351034
}
10361035

10371036
/**

src/test/org/firebirdsql/jdbc/FBDatabaseMetaDataTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import org.firebirdsql.common.DdlHelper;
1111
import org.firebirdsql.common.extension.UsesDatabaseExtension;
12+
import org.firebirdsql.util.FirebirdSupportInfo;
1213
import org.junit.jupiter.api.AfterAll;
1314
import org.junit.jupiter.api.BeforeAll;
1415
import org.junit.jupiter.api.Test;
@@ -809,6 +810,32 @@ void testGetIdentifierQuoteString_dialect3Db(String connectionDialect, String ex
809810
}
810811
}
811812

813+
@Test
814+
void testGetSchemaTerm() throws Exception {
815+
final String expected = getDefaultSupportInfo().supportsSchemas() ? "SCHEMA" : null;
816+
assertEquals(expected, dmd.getSchemaTerm(), "schemaTerm");
817+
}
818+
819+
@Test
820+
void testGetMaxSchemaNameLength() throws Exception {
821+
FirebirdSupportInfo supportInfo = getDefaultSupportInfo();
822+
final int expected = getDefaultSupportInfo().supportsSchemas()
823+
? supportInfo.maxIdentifierLengthCharacters() : 0;
824+
assertEquals(expected, dmd.getMaxSchemaNameLength(), "maxSchemaNameLength");
825+
}
826+
827+
@Test
828+
void testSupportsSchemasInXXX() {
829+
final boolean expected = getDefaultSupportInfo().supportsSchemas();
830+
assertAll(
831+
() -> assertEquals(expected, dmd.supportsSchemasInDataManipulation(), "DataManipulation"),
832+
() -> assertEquals(expected, dmd.supportsSchemasInIndexDefinitions(), "IndexDefinitions"),
833+
() -> assertEquals(expected, dmd.supportsSchemasInPrivilegeDefinitions(), "PrivilegeDefinitions"),
834+
() -> assertEquals(expected, dmd.supportsSchemasInProcedureCalls(), "ProcedureCalls"),
835+
() -> assertEquals(expected, dmd.supportsSchemasInTableDefinitions(), "TableDefinitions")
836+
);
837+
}
838+
812839
@SuppressWarnings("SameParameterValue")
813840
private void createPackage(String packageName, String procedureName) throws Exception {
814841
try (Statement stmt = connection.createStatement()) {

0 commit comments

Comments
 (0)