Commit 3306decd authored by gmantele's avatar gmantele
Browse files

[ADQL] Follow-up to the previous commit on CENTROID:

the automatic datatype detection was missing for CENTROID functions.
--
Additionally, some JUnit test files of the `adql` package has been moved to
the correct location.
parent 61063906
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ package adql.query;
 * You should have received a copy of the GNU Lesser General Public License
 * along with ADQLLibrary.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright 2012-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 * Copyright 2012-2017 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
 *                       Astronomisches Rechen Institut (ARI)
 */

@@ -35,6 +35,7 @@ import adql.query.operand.ADQLColumn;
import adql.query.operand.ADQLOperand;
import adql.query.operand.function.DefaultUDF;
import adql.query.operand.function.geometry.BoxFunction;
import adql.query.operand.function.geometry.CentroidFunction;
import adql.query.operand.function.geometry.CircleFunction;
import adql.query.operand.function.geometry.PointFunction;
import adql.query.operand.function.geometry.PolygonFunction;
@@ -46,7 +47,7 @@ import adql.search.ISearchHandler;
 * <p>The resulting object of the {@link ADQLParser} is an object of this class.</p>
 * 
 * @author Gr&eacute;gory Mantelet (CDS;ARI)
 * @version 1.4 (03/2016)
 * @version 1.4 (02/2017)
 */
public class ADQLQuery implements ADQLObject {

@@ -333,7 +334,7 @@ public class ADQLQuery implements ADQLObject {
				else{
					if (operand instanceof ADQLColumn && ((ADQLColumn)operand).getDBLink() != null)
						col = ((ADQLColumn)operand).getDBLink();
					if (col == null)
					else
						col = new DefaultDBColumn(item.getName(), null);
				}

@@ -345,7 +346,7 @@ public class ADQLQuery implements ADQLObject {
					((DefaultDBColumn)col).setDatatype(type);
				}
				// CASE: Point type:
				else if (operand instanceof PointFunction)
				else if (operand instanceof PointFunction || operand instanceof CentroidFunction)
					((DefaultDBColumn)col).setDatatype(new DBType(DBDatatype.POINT));
				// CASE: Region type:
				else if (operand instanceof RegionFunction || operand instanceof CircleFunction || operand instanceof BoxFunction || operand instanceof PolygonFunction)
+1 −1
Original line number Diff line number Diff line
package adql;
package adql.query;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+8 −10
Original line number Diff line number Diff line
package adql;
package adql.query;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
@@ -14,13 +14,6 @@ import org.junit.Test;
import adql.db.DBType;
import adql.db.DBType.DBDatatype;
import adql.db.FunctionDef;
import adql.query.ADQLObject;
import adql.query.ADQLOrder;
import adql.query.ADQLQuery;
import adql.query.ClauseADQL;
import adql.query.ClauseConstraints;
import adql.query.ClauseSelect;
import adql.query.SelectItem;
import adql.query.constraint.Comparison;
import adql.query.constraint.ComparisonOperator;
import adql.query.constraint.ConstraintsGroup;
@@ -39,7 +32,10 @@ import adql.query.operand.function.MathFunctionType;
import adql.query.operand.function.SQLFunction;
import adql.query.operand.function.SQLFunctionType;
import adql.query.operand.function.geometry.BoxFunction;
import adql.query.operand.function.geometry.CentroidFunction;
import adql.query.operand.function.geometry.CircleFunction;
import adql.query.operand.function.geometry.GeometryFunction;
import adql.query.operand.function.geometry.GeometryFunction.GeometryValue;
import adql.query.operand.function.geometry.PointFunction;
import adql.query.operand.function.geometry.PolygonFunction;
import adql.query.operand.function.geometry.RegionFunction;
@@ -195,8 +191,10 @@ public class TestADQLQuery {
		try{
			select.clear();
			select.add(new PointFunction(new StringConstant(""), new ADQLColumn("ra"), new ADQLColumn("dec")));
			assertEquals(1, query.getResultingColumns().length);
			assertEquals(DBDatatype.POINT, query.getResultingColumns()[0].getDatatype().type);
			select.add(new CentroidFunction(new GeometryValue<GeometryFunction>(new ADQLColumn("aRegion"))));
			assertEquals(2, query.getResultingColumns().length);
			for(int i = 0; i < 2; i++)
				assertEquals(DBDatatype.POINT, query.getResultingColumns()[i].getDatatype().type);
		}catch(Exception ex){
			ex.printStackTrace();
			fail("The POINT function is well defined. This error should have occurred.");
+1 −1
Original line number Diff line number Diff line
package adql;
package adql.query;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+1 −1
Original line number Diff line number Diff line
package adql;
package adql.query.constraint;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;