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

[TAP] MAJOR FIX: the type of computed columns was ALWAYS returned as VARCHAR.

This is particularly annoying for numeric functions like sqrt(...)
(example query: SELECT TOP 1 sqrt(2) as s2 FROM whatever_table).
This bug has been raised by M. Taylor.
parent 47d36bfb
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ package adql.translator; ...@@ -16,7 +16,7 @@ package adql.translator;
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>. * along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>.
* *
* Copyright 2012-2015 - UDS/Centre de Données astronomiques de Strasbourg (CDS), * Copyright 2012-2016 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI) * Astronomisches Rechen Institut (ARI)
*/ */
...@@ -50,7 +50,7 @@ import adql.query.operand.function.geometry.RegionFunction; ...@@ -50,7 +50,7 @@ import adql.query.operand.function.geometry.RegionFunction;
* </i></p> * </i></p>
* *
* @author Gr&eacute;gory Mantelet (CDS;ARI) * @author Gr&eacute;gory Mantelet (CDS;ARI)
* @version 1.4 (12/2015) * @version 1.4 (08/2016)
* *
* @see PgSphereTranslator * @see PgSphereTranslator
*/ */
...@@ -77,7 +77,7 @@ public class PostgreSQLTranslator extends JDBCTranslator { ...@@ -77,7 +77,7 @@ public class PostgreSQLTranslator extends JDBCTranslator {
* Builds a PostgreSQLTranslator which always translates in SQL all identifiers (schema, table and column) in the specified case sensitivity ; * Builds a PostgreSQLTranslator which always translates in SQL all identifiers (schema, table and column) in the specified case sensitivity ;
* in other words, schema, table and column names will all be surrounded or not by double quotes in the SQL translation. * in other words, schema, table and column names will all be surrounded or not by double quotes in the SQL translation.
* *
* @param allCaseSensitive <i>true</i> to translate all identifiers in a case sensitive manner (surrounded by double quotes), <i>false</i> for case insensitivity. * @param allCaseSensitive <i>true</i> to translate all identifiers in a case sensitive manner (surrounded by double quotes), <i>false</i> for case insensitivity.
*/ */
public PostgreSQLTranslator(final boolean allCaseSensitive){ public PostgreSQLTranslator(final boolean allCaseSensitive){
caseSensitivity = allCaseSensitive ? (byte)0x0F : (byte)0x00; caseSensitivity = allCaseSensitive ? (byte)0x0F : (byte)0x00;
...@@ -241,7 +241,7 @@ public class PostgreSQLTranslator extends JDBCTranslator { ...@@ -241,7 +241,7 @@ public class PostgreSQLTranslator extends JDBCTranslator {
else if (dbmsTypeName.equals("real") || dbmsTypeName.equals("float4")) else if (dbmsTypeName.equals("real") || dbmsTypeName.equals("float4"))
return new DBType(DBDatatype.REAL); return new DBType(DBDatatype.REAL);
// DOUBLE // DOUBLE
else if (dbmsTypeName.equals("double precision") || dbmsTypeName.equals("float8")) else if (dbmsTypeName.equals("double precision") || dbmsTypeName.equals("float8") || dbmsTypeName.equals("numeric"))
return new DBType(DBDatatype.DOUBLE); return new DBType(DBDatatype.DOUBLE);
// BINARY // BINARY
else if (dbmsTypeName.equals("bit")) else if (dbmsTypeName.equals("bit"))
......
...@@ -43,7 +43,7 @@ import uws.ISO8601Format; ...@@ -43,7 +43,7 @@ import uws.ISO8601Format;
* </i></p> * </i></p>
* *
* @author Gr&eacute;gory Mantelet (ARI) * @author Gr&eacute;gory Mantelet (ARI)
* @version 2.1 (04/2016) * @version 2.1 (08/2016)
* @since 2.0 * @since 2.0
*/ */
public class ResultSetTableIterator implements TableIterator { public class ResultSetTableIterator implements TableIterator {
...@@ -779,7 +779,7 @@ public class ResultSetTableIterator implements TableIterator { ...@@ -779,7 +779,7 @@ public class ResultSetTableIterator implements TableIterator {
dbType = translator.convertTypeFromDB(dbmsType, dbmsTypeName, dbmsTypePrefix, typeParams); dbType = translator.convertTypeFromDB(dbmsType, dbmsTypeName, dbmsTypePrefix, typeParams);
// And if unsuccessful, apply a default conversion: // And if unsuccessful, apply a default conversion:
if (dbType == null) if (dbType == null || dbType.isUnknown())
dbType = defaultTypeConversion(dbmsTypePrefix, typeParams, dbms); dbType = defaultTypeConversion(dbmsTypePrefix, typeParams, dbms);
return dbType; return dbType;
...@@ -861,7 +861,7 @@ public class ResultSetTableIterator implements TableIterator { ...@@ -861,7 +861,7 @@ public class ResultSetTableIterator implements TableIterator {
else if (dbmsTypeName.equals("real") || dbmsTypeName.equals("float4") || (dbmsTypeName.equals("float") && lengthParam <= 63)) else if (dbmsTypeName.equals("real") || dbmsTypeName.equals("float4") || (dbmsTypeName.equals("float") && lengthParam <= 63))
return new DBType(DBDatatype.REAL); return new DBType(DBDatatype.REAL);
// DOUBLE // DOUBLE
else if (dbmsTypeName.equals("double") || dbmsTypeName.equals("double precision") || dbmsTypeName.equals("float8") || (dbmsTypeName.equals("float") && lengthParam > 63)) else if (dbmsTypeName.equals("double") || dbmsTypeName.equals("double precision") || dbmsTypeName.equals("float8") || (dbmsTypeName.equals("float") && lengthParam > 63) || dbmsTypeName.equals("numeric"))
return new DBType(DBDatatype.DOUBLE); return new DBType(DBDatatype.DOUBLE);
// BINARY // BINARY
else if (dbmsTypeName.equals("bit") || dbmsTypeName.equals("binary") || dbmsTypeName.equals("raw") || ((dbmsTypeName.equals("char") || dbmsTypeName.equals("character")) && dbmsTypeName.endsWith(" for bit data"))) else if (dbmsTypeName.equals("bit") || dbmsTypeName.equals("binary") || dbmsTypeName.equals("raw") || ((dbmsTypeName.equals("char") || dbmsTypeName.equals("character")) && dbmsTypeName.endsWith(" for bit data")))
......
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