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());
}
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());
}
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());
}
Aggregations