From ac6d32dc45d3421e4957555b69d459aeeb4021ed Mon Sep 17 00:00:00 2001
From: Sonia Zorba <zorba@oats.inaf.it>
Date: Mon, 5 Feb 2018 16:09:14 +0100
Subject: [PATCH] Arraysize bugfix

---
 .../main/java/it/inaf/ia2/tsm/datalayer/ADQL.java    | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/ADQL.java b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/ADQL.java
index a91bf3d..d41958b 100644
--- a/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/ADQL.java
+++ b/TASMAN-core/src/main/java/it/inaf/ia2/tsm/datalayer/ADQL.java
@@ -47,6 +47,8 @@ public enum ADQL {
     CIRCLE,
     POLYGON;
 
+    private static final ADQL[] FIXED_LENGTH_TYPES = new ADQL[]{CHAR, BOOLEAN, SMALLINT, INTEGER, BIGINT, REAL, DOUBLE};
+
     /**
      * Returns a string representing a datatype which can't be interpreted as an
      * ADQL datatype (that is in case of not standard data types). Removes
@@ -64,7 +66,15 @@ public enum ADQL {
      * @return true if the datatype has a variable length, false otherwise.
      */
     public static boolean isVariable(ADQL adql) {
-        return adql.equals(VARCHAR) || adql.equals(VARBINARY) || adql.equals(CLOB) || adql.equals(BLOB);
+        // Since unknow data types are mapped to string, here a negative-logic is used
+        // (e.g. TIMESTAMP need to be considered as variable, in order to have
+        // arraysize *, otherwise taplib will throw an error)
+        for (ADQL value : FIXED_LENGTH_TYPES) {
+            if (adql.equals(value)) {
+                return false;
+            }
+        }
+        return true;
     }
 
     public static ADQL parse(String adqlStr) {
-- 
GitLab