You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@empire-db.apache.org by do...@apache.org on 2020/02/18 12:48:51 UTC

[empire-db] branch master updated: EMPIREDB-304 Bugfix enum in cmd params

This is an automated email from the ASF dual-hosted git repository.

doebele pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/empire-db.git


The following commit(s) were added to refs/heads/master by this push:
     new c1ea08b  EMPIREDB-304 Bugfix enum in cmd params
     new 4dde9f1  Merge branch 'master' of https://gitbox.apache.org/repos/asf/empire-db
c1ea08b is described below

commit c1ea08b5bcdbf0b8338ac88a1936b7147cc668eb
Author: Rainer Döbele <do...@apache.org>
AuthorDate: Tue Feb 18 13:48:30 2020 +0100

    EMPIREDB-304
    Bugfix enum in cmd params
---
 .../src/main/java/org/apache/empire/db/DBCmdParam.java  | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java b/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java
index 2d1c266..0d70f12 100644
--- a/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java
+++ b/empire-db/src/main/java/org/apache/empire/db/DBCmdParam.java
@@ -56,12 +56,14 @@ public class DBCmdParam extends DBExpr
      * @return the (possibly wrapped) value
      */
     protected Object getCmdParamValue(Object value)
-    {        
+    {
+        // check null
+        if (value == null)
+            return null;
+        // check type
         switch (type)
         {
             case BLOB:
-                if (value == null)
-                    return null;
                 if (value instanceof DBBlobData)
                     return value;
                 if (value instanceof byte[])
@@ -69,8 +71,6 @@ public class DBCmdParam extends DBExpr
                 // create a blob data
                 return new DBBlobData(value.toString());
             case CLOB:
-                if (value == null)
-                    return null;
                 if (value instanceof DBClobData)
                     return value;
                 // create a clob data
@@ -78,6 +78,13 @@ public class DBCmdParam extends DBExpr
             case BOOL:
             	return ObjectUtils.getBoolean(value);
             default:
+                // check for enum
+                if (value.getClass().isEnum())
+                {   // convert enum
+                    Enum<?> enumValue = ((Enum<?>)value);
+                    return (type.isNumeric() ? enumValue.ordinal() : enumValue.name());
+                }
+                // use as is
                 return value;
         }
     }