use of org.firebirdsql.gds.ng.fields.FieldDescriptor in project jaybird by FirebirdSQL.
the class FBNullFieldTest method setUp.
@Before
public void setUp() throws Exception {
fieldData = context.mock(FieldDataProvider.class);
FieldDescriptor fieldDescriptor = new RowDescriptorBuilder(1, defaultDatatypeCoder).toFieldDescriptor();
field = new FBNullField(fieldDescriptor, fieldData, Types.NULL);
}
use of org.firebirdsql.gds.ng.fields.FieldDescriptor in project jaybird by FirebirdSQL.
the class AbstractStatementTest method testStatementPrepareLongObjectNames.
@Test
public void testStatementPrepareLongObjectNames() throws Exception {
assumeTrue("Test requires 63 character identifier support", supportInfoFor(db).maxIdentifierLengthCharacters() >= 63);
String tableName = generateIdentifier('A', 63);
String column1 = generateIdentifier('B', 63);
String column2 = generateIdentifier('C', 63);
try (Connection con = FBTestProperties.getConnectionViaDriverManager()) {
DdlHelper.executeCreateTable(con, "create table " + tableName + " (" + column1 + " varchar(10) character set UTF8, " + column2 + " varchar(20) character set UTF8)");
}
allocateStatement();
statement.prepare("SELECT " + column1 + ", " + column2 + " FROM " + tableName + " where " + column1 + " = ?");
assertEquals("Unexpected StatementType", StatementType.SELECT, statement.getType());
final RowDescriptor fields = statement.getFieldDescriptor();
assertNotNull("Fields", fields);
List<FieldDescriptor> expectedFields = Arrays.asList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_VARYING | 1, 4, 0, 40, column1, null, column1, tableName, "SYSDBA"), new FieldDescriptor(1, db.getDatatypeCoder(), ISCConstants.SQL_VARYING | 1, 4, 0, 80, column2, null, column2, tableName, "SYSDBA"));
assertEquals("Unexpected values for fields", expectedFields, fields.getFieldDescriptors());
RowDescriptor parameters = statement.getParameterDescriptor();
assertNotNull("Parameters", parameters);
List<FieldDescriptor> expectedParameters = Collections.singletonList(new FieldDescriptor(0, db.getDatatypeCoder(), ISCConstants.SQL_VARYING | 1, 4, 0, 40, null, null, null, null, null));
assertEquals("Unexpected values for parameters", expectedParameters, parameters.getFieldDescriptors());
}
use of org.firebirdsql.gds.ng.fields.FieldDescriptor in project jaybird by FirebirdSQL.
the class FBCachedFetcher method determineBlobs.
/**
* Determines the columns that are blobs.
*
* @param rowDescriptor The row descriptor
* @param isBlob Boolean array with length equal to {@code rowDescriptor}, modified by this method
* @return {@code true} if there are one or more blob columns.
*/
private static boolean determineBlobs(final RowDescriptor rowDescriptor, final boolean[] isBlob) {
assert rowDescriptor.getCount() == isBlob.length : "length of isBlob should be equal to length of rowDescriptor";
boolean hasBlobs = false;
for (int i = 0; i < rowDescriptor.getCount(); i++) {
final FieldDescriptor field = rowDescriptor.getFieldDescriptor(i);
isBlob[i] = FBField.isType(field, Types.BLOB) || FBField.isType(field, Types.LONGVARBINARY) || FBField.isType(field, Types.LONGVARCHAR);
if (isBlob[i])
hasBlobs = true;
}
return hasBlobs;
}
use of org.firebirdsql.gds.ng.fields.FieldDescriptor in project jaybird by FirebirdSQL.
the class FBRowUpdater method buildSelectStatement.
private String buildSelectStatement(int[] parameterMask) {
StringBuilder columns = new StringBuilder();
boolean first = true;
for (FieldDescriptor fieldDescriptor : rowDescriptor) {
if (!first)
columns.append(',');
// DB_KEY column name instead of the correct one
if (fieldDescriptor.isDbKey()) {
columns.append("RDB$DB_KEY");
} else {
quoteStrategy.appendQuoted(fieldDescriptor.getOriginalName(), columns);
}
first = false;
}
StringBuilder sb = new StringBuilder("SELECT ");
sb.append(columns).append('\n').append("FROM ");
quoteStrategy.appendQuoted(tableName, sb).append('\n');
appendWhereClause(sb, parameterMask);
return sb.toString();
}
use of org.firebirdsql.gds.ng.fields.FieldDescriptor in project jaybird by FirebirdSQL.
the class AbstractStatementTest method test_PrepareSelectableStoredProcedure.
@Test
public void test_PrepareSelectableStoredProcedure() throws Exception {
allocateStatement();
statement.prepare(EXECUTE_SELECTABLE_STORED_PROCEDURE);
assertEquals("Unexpected StatementType", StatementType.SELECT, 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, "OUTVALUE", null, "OUTVALUE", "RANGE", "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_LONG | 1, 0, 0, 4, null, null, null, null, null), new FieldDescriptor(1, db.getDatatypeCoder(), ISCConstants.SQL_LONG | 1, 0, 0, 4, null, null, null, null, null));
assertEquals("Unexpected values for parameters", expectedParameters, parameters.getFieldDescriptors());
}
Aggregations