Search in sources :

Example 21 with RowDescriptor

use of org.firebirdsql.gds.ng.fields.RowDescriptor in project jaybird by FirebirdSQL.

the class AbstractStatementTest method testSelect_WithParameters_Describe.

@Test
public void testSelect_WithParameters_Describe() throws Exception {
    allocateStatement();
    statement.prepare("SELECT a.RDB$CHARACTER_SET_NAME " + "FROM RDB$CHARACTER_SETS a " + "WHERE a.RDB$CHARACTER_SET_ID = ? OR a.RDB$BYTES_PER_CHARACTER = ?");
    assertEquals("Unexpected StatementType", StatementType.SELECT, statement.getType());
    final RowDescriptor fields = statement.getFieldDescriptor();
    assertNotNull("Fields", fields);
    final FirebirdSupportInfo supportInfo = supportInfoFor(db);
    final boolean supportsTableAlias = supportInfo.supportsTableAlias();
    final int metadataCharSetId = supportInfo.reportedMetadataCharacterSetId();
    List<FieldDescriptor> expectedFields = Collections.singletonList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_TEXT | 1, metadataCharSetId, 0, supportInfo.maxReportedIdentifierLengthBytes(), "RDB$CHARACTER_SET_NAME", supportsTableAlias ? "A" : null, "RDB$CHARACTER_SET_NAME", "RDB$CHARACTER_SETS", "SYSDBA"));
    assertEquals("Unexpected values for fields", expectedFields, fields.getFieldDescriptors());
    final RowDescriptor parameters = statement.getParameterDescriptor();
    assertNotNull("Parameters", parameters);
    List<FieldDescriptor> expectedParameters = Arrays.asList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_SHORT | 1, 0, 0, 2, null, null, null, null, null), new FieldDescriptor(1, db.getDatatypeCoder(), ISCConstants.SQL_SHORT | 1, 0, 0, 2, null, null, null, null, null));
    assertEquals("Unexpected values for parameters", expectedParameters, parameters.getFieldDescriptors());
}
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)

Example 22 with RowDescriptor

use of org.firebirdsql.gds.ng.fields.RowDescriptor 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)

Example 23 with RowDescriptor

use of org.firebirdsql.gds.ng.fields.RowDescriptor in project jaybird by FirebirdSQL.

the class AbstractStatementTest method test_PrepareInsertReturning.

@Test
public void test_PrepareInsertReturning() throws Exception {
    assumeTrue("Test requires INSERT .. RETURNING ... support", supportInfoFor(db).supportsInsertReturning());
    allocateStatement();
    statement.prepare(INSERT_RETURNING_KEY_VALUE);
    // DML {INSERT, UPDATE, DELETE} ... RETURNING is described as a stored procedure!
    assertEquals("Unexpected StatementType", StatementType.STORED_PROCEDURE, statement.getType());
    final RowDescriptor fields = statement.getFieldDescriptor();
    assertNotNull("Fields", fields);
    List<FieldDescriptor> expectedFields = Collections.singletonList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_LONG | 1, 0, 0, 4, "THEKEY", null, "THEKEY", "KEYVALUE", "SYSDBA"));
    assertEquals("Unexpected values for fields", expectedFields, fields.getFieldDescriptors());
    final RowDescriptor parameters = statement.getParameterDescriptor();
    assertNotNull("Parameters", parameters);
    List<FieldDescriptor> expectedParameters = Collections.singletonList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_VARYING | 1, 0, 0, 5, null, null, null, null, null));
    assertEquals("Unexpected values for parameters", expectedParameters, parameters.getFieldDescriptors());
}
Also used : RowDescriptor(org.firebirdsql.gds.ng.fields.RowDescriptor) FieldDescriptor(org.firebirdsql.gds.ng.fields.FieldDescriptor) Test(org.junit.Test)

Aggregations

RowDescriptor (org.firebirdsql.gds.ng.fields.RowDescriptor)23 RowValue (org.firebirdsql.gds.ng.fields.RowValue)13 RowDescriptorBuilder (org.firebirdsql.gds.ng.fields.RowDescriptorBuilder)12 RowValueBuilder (org.firebirdsql.gds.ng.fields.RowValueBuilder)10 Test (org.junit.Test)7 FieldDescriptor (org.firebirdsql.gds.ng.fields.FieldDescriptor)6 FirebirdSupportInfo (org.firebirdsql.util.FirebirdSupportInfo)2 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 SQLNonTransientException (java.sql.SQLNonTransientException)1 SQLTransientException (java.sql.SQLTransientException)1 ArrayList (java.util.ArrayList)1 Encoding (org.firebirdsql.encodings.Encoding)1 FieldValue (org.firebirdsql.gds.ng.fields.FieldValue)1 SimpleStatementListener (org.firebirdsql.gds.ng.wire.SimpleStatementListener)1 FBResultSet (org.firebirdsql.jdbc.FBResultSet)1 FieldDataProvider (org.firebirdsql.jdbc.field.FieldDataProvider)1