Search in sources :

Example 11 with FirebirdSupportInfo

use of org.firebirdsql.util.FirebirdSupportInfo in project jaybird by FirebirdSQL.

the class AbstractStatementTest method testSelect_NoParameters_Describe.

@Test
public void testSelect_NoParameters_Describe() throws Exception {
    allocateStatement();
    statement.prepare("SELECT RDB$DESCRIPTION AS \"Description\", RDB$RELATION_ID, RDB$SECURITY_CLASS, RDB$CHARACTER_SET_NAME " + "FROM RDB$DATABASE");
    assertEquals("Unexpected StatementType", StatementType.SELECT, statement.getType());
    final RowDescriptor fields = statement.getFieldDescriptor();
    assertNotNull("Fields", fields);
    final FirebirdSupportInfo supportInfo = supportInfoFor(db);
    final int metadataCharSetId = supportInfo.reportedMetadataCharacterSetId();
    List<FieldDescriptor> expectedFields = Arrays.asList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_BLOB | 1, 1, supportInfo.reportsBlobCharSetInDescriptor() ? metadataCharSetId : 0, 8, "Description", null, "RDB$DESCRIPTION", "RDB$DATABASE", "SYSDBA"), new FieldDescriptor(1, db.getDatatypeCoder(), ISCConstants.SQL_SHORT | 1, 0, 0, 2, "RDB$RELATION_ID", null, "RDB$RELATION_ID", "RDB$DATABASE", "SYSDBA"), new FieldDescriptor(2, db.getDatatypeCoder(), ISCConstants.SQL_TEXT | 1, metadataCharSetId, 0, supportInfo.maxReportedIdentifierLengthBytes(), "RDB$SECURITY_CLASS", null, "RDB$SECURITY_CLASS", "RDB$DATABASE", "SYSDBA"), new FieldDescriptor(3, db.getDatatypeCoder(), ISCConstants.SQL_TEXT | 1, metadataCharSetId, 0, supportInfo.maxReportedIdentifierLengthBytes(), "RDB$CHARACTER_SET_NAME", null, "RDB$CHARACTER_SET_NAME", "RDB$DATABASE", "SYSDBA"));
    assertEquals("Unexpected values for fields", expectedFields, fields.getFieldDescriptors());
    assertNotNull("Parameters", statement.getParameterDescriptor());
    assertEquals("Unexpected parameter count", 0, statement.getParameterDescriptor().getCount());
}
Also used : FirebirdSupportInfo(org.firebirdsql.util.FirebirdSupportInfo) RowDescriptor(org.firebirdsql.gds.ng.fields.RowDescriptor) FieldDescriptor(org.firebirdsql.gds.ng.fields.FieldDescriptor) Test(org.junit.Test)

Aggregations

FirebirdSupportInfo (org.firebirdsql.util.FirebirdSupportInfo)11 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 FieldDescriptor (org.firebirdsql.gds.ng.fields.FieldDescriptor)2 RowDescriptor (org.firebirdsql.gds.ng.fields.RowDescriptor)2 Connection (java.sql.Connection)1 Statement (java.sql.Statement)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1 Matchers.isEmptyOrNullString (org.hamcrest.Matchers.isEmptyOrNullString)1