Skip to content
Snippets Groups Projects
Commit 7ca76c66 authored by gmantele's avatar gmantele
Browse files

[TAP] Fix unfortunate consequence of the previous modification of

ResultSetTableIterator (i.e. functions returning unknown numeric values
were not set with the right datatype but char* instead).
parent 763168d2
No related branches found
No related tags found
No related merge requests found
......@@ -581,7 +581,7 @@ public class ResultSetTableIterator implements TableIterator {
if (resultMeta != null && (i - 1) < resultMeta.length && resultMeta[i - 1] != null){
if (resultMeta[i - 1] instanceof TAPColumn)
colMeta[i - 1] = (TAPColumn)resultMeta[i - 1];
else if (resultMeta[i - 1].getDatatype() != null){
else if (resultMeta[i - 1].getDatatype() != null && !resultMeta[i - 1].getDatatype().isUnknown()){
colMeta[i - 1] = new TAPColumn(resultMeta[i - 1].getADQLName(), resultMeta[i - 1].getDatatype());
colMeta[i - 1].setDBName(resultMeta[i - 1].getDBName());
}else{
......
......@@ -198,7 +198,43 @@ public class ResultSetTableIteratorTest {
}catch(Exception ex){
ex.printStackTrace(System.err);
fail("An exception occurs while formatting dates/times.");
fail("An exception occurs while checking geometrical functions datatypes.");
}finally{
if (rs != null){
try{
rs.close();
}catch(Exception ex){}
}
}
}
@Test
public void testSQLFunctions(){
ResultSet rs = null;
try{
ADQLQuery query = (new ADQLParser()).parseQuery("SELECT COUNT(*), MIN(vmag), AVG(plx) FROM hipparcos;");
// create a valid ResultSet:
rs = DBTools.select(conn, (new PgSphereTranslator()).translate(query));
// Create the iterator:
ResultSetTableIterator rsit = new ResultSetTableIterator(rs, query.getResultingColumns());
assertTrue(rsit.nextRow());
// Fetch the metadata:
TAPColumn[] cols = rsit.getMetadata();
assertEquals(3, cols.length);
// Check that the first column is a BIGINT:
assertEquals(DBType.DBDatatype.BIGINT, cols[0].getDatatype().type);
// Check that the two next columns are REAL:
for(int i = 1; i < 3; i++)
assertEquals(DBType.DBDatatype.REAL, cols[i].getDatatype().type);
}catch(Exception ex){
ex.printStackTrace(System.err);
fail("An exception occurs while checking SQL functions datatypes");
}finally{
if (rs != null){
try{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment